From e3c4cbb01bab064c1c4a1a270b46a160a4e94ffe Mon Sep 17 00:00:00 2001 From: nilaoda Date: Fri, 7 Jul 2023 16:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0N=E4=B8=AA?= =?UTF-8?q?=E5=88=86=E7=89=87=20`live-take-count`=20#218?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Common/Resource/ResString.cs | 1 + src/N_m3u8DL-RE.Common/Resource/StaticText.cs | 6 ++++++ src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 6 ++++-- src/N_m3u8DL-RE/CommandLine/MyOption.cs | 4 ++++ src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs | 2 +- src/N_m3u8DL-RE/Util/FilterUtil.cs | 2 +- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index f88cd00..cfe59a7 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -79,6 +79,7 @@ namespace N_m3u8DL_RE.Common.Resource public static string cmd_liveRecordLimit { get => GetText("cmd_liveRecordLimit"); } public static string cmd_taskStartAt { get => GetText("cmd_taskStartAt"); } public static string cmd_liveWaitTime { get => GetText("cmd_liveWaitTime"); } + public static string cmd_liveTakeCount { get => GetText("cmd_liveTakeCount"); } public static string cmd_liveFixVttByAudio { get => GetText("cmd_liveFixVttByAudio"); } public static string cmd_liveRealTimeMerge { get => GetText("cmd_liveRealTimeMerge"); } public static string cmd_livePerformAsVod { get => GetText("cmd_livePerformAsVod"); } diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs index 8581ebf..7f5c3cf 100644 --- a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -346,6 +346,12 @@ namespace N_m3u8DL_RE.Common.Resource zhTW: "手動設置直播列表刷新間隔", enUS: "Manually set the live playlist refresh interval" ), + ["cmd_liveTakeCount"] = new TextContainer + ( + zhCN: "手动设置录制直播时首次获取分片的数量", + zhTW: "手動設置錄製直播時首次獲取分片的數量", + enUS: "Manually set the number of segments downloaded for the first time when recording live" + ), ["cmd_customHLSMethod"] = new TextContainer ( zhCN: "指定HLS加密方式 (AES_128|AES_128_ECB|CENC|CHACHA20|NONE|SAMPLE_AES|SAMPLE_AES_CTR|UNKNOWN)", diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index c7ad659..d292bdd 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine { internal partial class CommandInvoker { - public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20230628"; + public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20230707"; [GeneratedRegex("((best|worst)\\d*|all)")] private static partial Regex ForStrRegex(); @@ -85,6 +85,7 @@ namespace N_m3u8DL_RE.CommandLine private readonly static Option LivePipeMux = new(new string[] { "--live-pipe-mux" }, description: ResString.cmd_livePipeMux, getDefaultValue: () => false); private readonly static Option LiveRecordLimit = new(new string[] { "--live-record-limit" }, description: ResString.cmd_liveRecordLimit, parseArgument: ParseLiveLimit) { ArgumentHelpName = "HH:mm:ss" }; private readonly static Option LiveWaitTime = new(new string[] { "--live-wait-time" }, description: ResString.cmd_liveWaitTime) { ArgumentHelpName = "SEC" }; + private readonly static Option LiveTakeCount = new(new string[] { "--live-take-count" }, description: ResString.cmd_liveTakeCount, getDefaultValue: () => 16) { ArgumentHelpName = "NUM" }; private readonly static Option LiveFixVttByAudio = new(new string[] { "--live-fix-vtt-by-audio" }, description: ResString.cmd_liveFixVttByAudio, getDefaultValue: () => false); @@ -495,6 +496,7 @@ namespace N_m3u8DL_RE.CommandLine CustomProxy = bindingContext.ParseResult.GetValueForOption(CustomProxy), CustomRange = bindingContext.ParseResult.GetValueForOption(CustomRange), LiveWaitTime = bindingContext.ParseResult.GetValueForOption(LiveWaitTime), + LiveTakeCount = bindingContext.ParseResult.GetValueForOption(LiveTakeCount), NoDateInfo = bindingContext.ParseResult.GetValueForOption(NoDateInfo), NoLog = bindingContext.ParseResult.GetValueForOption(NoLog), }; @@ -561,7 +563,7 @@ namespace N_m3u8DL_RE.CommandLine LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption, MuxAfterDone, CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, CustomRange, TaskStartAt, - LivePerformAsVod, LiveRealTimeMerge, LiveKeepSegments, LivePipeMux, LiveFixVttByAudio, LiveRecordLimit, LiveWaitTime, + LivePerformAsVod, LiveRealTimeMerge, LiveKeepSegments, LivePipeMux, LiveFixVttByAudio, LiveRecordLimit, LiveWaitTime, LiveTakeCount, MuxImports, VideoFilter, AudioFilter, SubtitleFilter, DropVideoFilter, DropAudioFilter, DropSubtitleFilter, MoreHelp }; diff --git a/src/N_m3u8DL-RE/CommandLine/MyOption.cs b/src/N_m3u8DL-RE/CommandLine/MyOption.cs index ec2369a..c346fa1 100644 --- a/src/N_m3u8DL-RE/CommandLine/MyOption.cs +++ b/src/N_m3u8DL-RE/CommandLine/MyOption.cs @@ -220,6 +220,10 @@ namespace N_m3u8DL_RE.CommandLine /// See: . /// public int? LiveWaitTime { get; set; } + /// + /// See: . + /// + public int LiveTakeCount { get; set; } public MuxOptions MuxOptions { get; set; } //public bool LiveWriteHLS { get; set; } = true; /// diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs index 0f531aa..08fd5a9 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs @@ -790,7 +790,7 @@ namespace N_m3u8DL_RE.DownloadManager public async Task StartRecordAsync() { - var takeLastCount = 15; + var takeLastCount = DownloaderConfig.MyOptions.LiveTakeCount; ConcurrentDictionary SpeedContainerDic = new(); //速度计算 ConcurrentDictionary Results = new(); //同步流 diff --git a/src/N_m3u8DL-RE/Util/FilterUtil.cs b/src/N_m3u8DL-RE/Util/FilterUtil.cs index eb77a9a..0ad664d 100644 --- a/src/N_m3u8DL-RE/Util/FilterUtil.cs +++ b/src/N_m3u8DL-RE/Util/FilterUtil.cs @@ -172,7 +172,7 @@ namespace N_m3u8DL_RE.Util //取最新的N个分片 if (selectedSteams.Any(x => x.Playlist!.MediaParts[0].MediaSegments.Count > takeLastCount)) { - var skipCount = selectedSteams.Min(x => x.Playlist!.MediaParts[0].MediaSegments.Count) - takeLastCount; + var skipCount = selectedSteams.Min(x => x.Playlist!.MediaParts[0].MediaSegments.Count) - takeLastCount + 1; if (skipCount < 0) skipCount = 0; foreach (var item in selectedSteams) {