支持设置直播获取最新N个分片 `live-take-count` #218
This commit is contained in:
parent
8bf50a3f5a
commit
e3c4cbb01b
|
@ -79,6 +79,7 @@ namespace N_m3u8DL_RE.Common.Resource
|
||||||
public static string cmd_liveRecordLimit { get => GetText("cmd_liveRecordLimit"); }
|
public static string cmd_liveRecordLimit { get => GetText("cmd_liveRecordLimit"); }
|
||||||
public static string cmd_taskStartAt { get => GetText("cmd_taskStartAt"); }
|
public static string cmd_taskStartAt { get => GetText("cmd_taskStartAt"); }
|
||||||
public static string cmd_liveWaitTime { get => GetText("cmd_liveWaitTime"); }
|
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_liveFixVttByAudio { get => GetText("cmd_liveFixVttByAudio"); }
|
||||||
public static string cmd_liveRealTimeMerge { get => GetText("cmd_liveRealTimeMerge"); }
|
public static string cmd_liveRealTimeMerge { get => GetText("cmd_liveRealTimeMerge"); }
|
||||||
public static string cmd_livePerformAsVod { get => GetText("cmd_livePerformAsVod"); }
|
public static string cmd_livePerformAsVod { get => GetText("cmd_livePerformAsVod"); }
|
||||||
|
|
|
@ -346,6 +346,12 @@ namespace N_m3u8DL_RE.Common.Resource
|
||||||
zhTW: "手動設置直播列表刷新間隔",
|
zhTW: "手動設置直播列表刷新間隔",
|
||||||
enUS: "Manually set the live playlist refresh interval"
|
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
|
["cmd_customHLSMethod"] = new TextContainer
|
||||||
(
|
(
|
||||||
zhCN: "指定HLS加密方式 (AES_128|AES_128_ECB|CENC|CHACHA20|NONE|SAMPLE_AES|SAMPLE_AES_CTR|UNKNOWN)",
|
zhCN: "指定HLS加密方式 (AES_128|AES_128_ECB|CENC|CHACHA20|NONE|SAMPLE_AES|SAMPLE_AES_CTR|UNKNOWN)",
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
{
|
{
|
||||||
internal partial class CommandInvoker
|
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)")]
|
[GeneratedRegex("((best|worst)\\d*|all)")]
|
||||||
private static partial Regex ForStrRegex();
|
private static partial Regex ForStrRegex();
|
||||||
|
@ -85,6 +85,7 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
private readonly static Option<bool> LivePipeMux = new(new string[] { "--live-pipe-mux" }, description: ResString.cmd_livePipeMux, getDefaultValue: () => false);
|
private readonly static Option<bool> LivePipeMux = new(new string[] { "--live-pipe-mux" }, description: ResString.cmd_livePipeMux, getDefaultValue: () => false);
|
||||||
private readonly static Option<TimeSpan?> LiveRecordLimit = new(new string[] { "--live-record-limit" }, description: ResString.cmd_liveRecordLimit, parseArgument: ParseLiveLimit) { ArgumentHelpName = "HH:mm:ss" };
|
private readonly static Option<TimeSpan?> LiveRecordLimit = new(new string[] { "--live-record-limit" }, description: ResString.cmd_liveRecordLimit, parseArgument: ParseLiveLimit) { ArgumentHelpName = "HH:mm:ss" };
|
||||||
private readonly static Option<int?> LiveWaitTime = new(new string[] { "--live-wait-time" }, description: ResString.cmd_liveWaitTime) { ArgumentHelpName = "SEC" };
|
private readonly static Option<int?> LiveWaitTime = new(new string[] { "--live-wait-time" }, description: ResString.cmd_liveWaitTime) { ArgumentHelpName = "SEC" };
|
||||||
|
private readonly static Option<int> LiveTakeCount = new(new string[] { "--live-take-count" }, description: ResString.cmd_liveTakeCount, getDefaultValue: () => 16) { ArgumentHelpName = "NUM" };
|
||||||
private readonly static Option<bool> LiveFixVttByAudio = new(new string[] { "--live-fix-vtt-by-audio" }, description: ResString.cmd_liveFixVttByAudio, getDefaultValue: () => false);
|
private readonly static Option<bool> 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),
|
CustomProxy = bindingContext.ParseResult.GetValueForOption(CustomProxy),
|
||||||
CustomRange = bindingContext.ParseResult.GetValueForOption(CustomRange),
|
CustomRange = bindingContext.ParseResult.GetValueForOption(CustomRange),
|
||||||
LiveWaitTime = bindingContext.ParseResult.GetValueForOption(LiveWaitTime),
|
LiveWaitTime = bindingContext.ParseResult.GetValueForOption(LiveWaitTime),
|
||||||
|
LiveTakeCount = bindingContext.ParseResult.GetValueForOption(LiveTakeCount),
|
||||||
NoDateInfo = bindingContext.ParseResult.GetValueForOption(NoDateInfo),
|
NoDateInfo = bindingContext.ParseResult.GetValueForOption(NoDateInfo),
|
||||||
NoLog = bindingContext.ParseResult.GetValueForOption(NoLog),
|
NoLog = bindingContext.ParseResult.GetValueForOption(NoLog),
|
||||||
};
|
};
|
||||||
|
@ -561,7 +563,7 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption,
|
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption,
|
||||||
MuxAfterDone,
|
MuxAfterDone,
|
||||||
CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, CustomRange, TaskStartAt,
|
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
|
MuxImports, VideoFilter, AudioFilter, SubtitleFilter, DropVideoFilter, DropAudioFilter, DropSubtitleFilter, MoreHelp
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -220,6 +220,10 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
/// See: <see cref="CommandInvoker.LiveWaitTime"/>.
|
/// See: <see cref="CommandInvoker.LiveWaitTime"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? LiveWaitTime { get; set; }
|
public int? LiveWaitTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// See: <see cref="CommandInvoker.LiveTakeCount"/>.
|
||||||
|
/// </summary>
|
||||||
|
public int LiveTakeCount { get; set; }
|
||||||
public MuxOptions MuxOptions { get; set; }
|
public MuxOptions MuxOptions { get; set; }
|
||||||
//public bool LiveWriteHLS { get; set; } = true;
|
//public bool LiveWriteHLS { get; set; } = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -790,7 +790,7 @@ namespace N_m3u8DL_RE.DownloadManager
|
||||||
|
|
||||||
public async Task<bool> StartRecordAsync()
|
public async Task<bool> StartRecordAsync()
|
||||||
{
|
{
|
||||||
var takeLastCount = 15;
|
var takeLastCount = DownloaderConfig.MyOptions.LiveTakeCount;
|
||||||
ConcurrentDictionary<int, SpeedContainer> SpeedContainerDic = new(); //速度计算
|
ConcurrentDictionary<int, SpeedContainer> SpeedContainerDic = new(); //速度计算
|
||||||
ConcurrentDictionary<StreamSpec, bool?> Results = new();
|
ConcurrentDictionary<StreamSpec, bool?> Results = new();
|
||||||
//同步流
|
//同步流
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace N_m3u8DL_RE.Util
|
||||||
//取最新的N个分片
|
//取最新的N个分片
|
||||||
if (selectedSteams.Any(x => x.Playlist!.MediaParts[0].MediaSegments.Count > takeLastCount))
|
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;
|
if (skipCount < 0) skipCount = 0;
|
||||||
foreach (var item in selectedSteams)
|
foreach (var item in selectedSteams)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue