Skip to content

Commit

Permalink
feat: --status force print progress bar when loglevel is OFF #5
Browse files Browse the repository at this point in the history
  • Loading branch information
RikaCelery committed Feb 7, 2024
1 parent e76fd67 commit 5c45342
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/N_m3u8DL-RE.Common/Resource/ResString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ResString
public static string cmd_Input { get => GetText("cmd_Input"); }
public static string cmd_force_ansi_console { get => GetText("cmd_force_ansi_console"); }
public static string cmd_noansi { get => GetText("cmd_noansi"); }
public static string cmd_status { get => GetText("cmd_status"); }
public static string cmd_keys { get => GetText("cmd_keys"); }
public static string cmd_keyText { get => GetText("cmd_keyText"); }
public static string cmd_loadKeyFailed { get => GetText("cmd_loadKeyFailed"); }
Expand Down
6 changes: 6 additions & 0 deletions src/N_m3u8DL-RE.Common/Resource/StaticText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ internal class StaticText
zhTW: "關閉ansi顏色",
enUS: "Remove ANSI colors"
),
["cmd_noansi"] = new TextContainer
(
zhCN: "显示进度信息",
zhTW: "顯示進度信息",
enUS: "Print progress report during downloading"
),
["customRangeWarn"] = new TextContainer
(
zhCN: "请注意,自定义下载范围有时会导致音画不同步",
Expand Down
6 changes: 4 additions & 2 deletions src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine
{
internal partial class CommandInvoker
{
public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20231113";
public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20240207";

[GeneratedRegex("((best|worst)\\d*|all)")]
private static partial Regex ForStrRegex();
Expand Down Expand Up @@ -55,6 +55,7 @@ internal partial class CommandInvoker
private readonly static Option<bool> UseShakaPackager = new (new string[] { "--use-shaka-packager" }, description: ResString.cmd_useShakaPackager, getDefaultValue: () => false);
private readonly static Option<bool> ForceAnsiConsole = new(new string[] { "--force-ansi-console" }, description: ResString.cmd_force_ansi_console);
private readonly static Option<bool> Noansi = new(new string[] { "--noansi" }, description: ResString.cmd_noansi);
private readonly static Option<bool> Status = new(new string[] { "--status" }, description: ResString.cmd_status);
private readonly static Option<string?> DecryptionBinaryPath = new(new string[] { "--decryption-binary-path" }, description: ResString.cmd_decryptionBinaryPath) { ArgumentHelpName = "PATH" };
private readonly static Option<string?> FFmpegBinaryPath = new(new string[] { "--ffmpeg-binary-path" }, description: ResString.cmd_ffmpegBinaryPath) { ArgumentHelpName = "PATH" };
private readonly static Option<string?> BaseUrl = new(new string[] { "--base-url" }, description: ResString.cmd_baseUrl);
Expand Down Expand Up @@ -489,6 +490,7 @@ protected override MyOption GetBoundValue(BindingContext bindingContext)
Input = bindingContext.ParseResult.GetValueForArgument(Input),
ForceAnsiConsole = bindingContext.ParseResult.GetValueForOption(ForceAnsiConsole),
Noansi = bindingContext.ParseResult.GetValueForOption(Noansi),
Status = bindingContext.ParseResult.GetValueForOption(Status),
LogLevel = bindingContext.ParseResult.GetValueForOption(LogLevel),
AutoSelect = bindingContext.ParseResult.GetValueForOption(AutoSelect),
SkipMerge = bindingContext.ParseResult.GetValueForOption(SkipMerge),
Expand Down Expand Up @@ -601,7 +603,7 @@ public static async Task<int> InvokeArgs(string[] args, Func<MyOption, Task> act

var rootCommand = new RootCommand(VERSION_INFO)
{
Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, ForceAnsiConsole,Noansi,AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount,
Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, ForceAnsiConsole,Noansi,Status,AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount,
BinaryMerge, UseFFmpegConcatDemuxer, DelAfterDone, NoDateInfo, NoLog, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,
FFmpegBinaryPath,
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption,
Expand Down
4 changes: 4 additions & 0 deletions src/N_m3u8DL-RE/CommandLine/MyOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ internal class MyOption
/// </summary>
public bool Noansi { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.Status"/>.
/// </summary>
public bool Status { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.UseFFmpegConcatDemuxer"/>.
/// </summary>
public bool UseFFmpegConcatDemuxer { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/N_m3u8DL-RE/DownloadManager/HTTPLiveRecordManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public async Task<bool> StartRecordAsync()
ConcurrentDictionary<StreamSpec, bool?> Results = new();

var progress = CustomAnsiConsole.Console.Progress().AutoClear(true);
progress.AutoRefresh = DownloaderConfig.MyOptions.LogLevel != LogLevel.OFF;
progress.AutoRefresh = DownloaderConfig.MyOptions.LogLevel != LogLevel.OFF | DownloaderConfig.MyOptions.Status;

//进度条的列定义
var progressColumns = new ProgressColumn[]
Expand Down
4 changes: 2 additions & 2 deletions src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ public async Task<bool> StartDownloadAsync()
ConcurrentDictionary<StreamSpec, bool?> Results = new();

var progress = CustomAnsiConsole.Console.Progress().AutoClear(true);
progress.AutoRefresh = DownloaderConfig.MyOptions.LogLevel != LogLevel.OFF;

progress.AutoRefresh = DownloaderConfig.MyOptions.LogLevel != LogLevel.OFF | DownloaderConfig.MyOptions.Status;
//进度条的列定义
var progressColumns = new ProgressColumn[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ public async Task<bool> StartRecordAsync()
}*/

var progress = CustomAnsiConsole.Console.Progress().AutoClear(true);
progress.AutoRefresh = DownloaderConfig.MyOptions.LogLevel != LogLevel.OFF;
progress.AutoRefresh = DownloaderConfig.MyOptions.LogLevel != LogLevel.OFF | DownloaderConfig.MyOptions.Status;

//进度条的列定义
var progressColumns = new ProgressColumn[]
Expand Down

0 comments on commit 5c45342

Please sign in to comment.