diff --git a/OF DL/Entities/Config.cs b/OF DL/Entities/Config.cs index 0919d74..3731b18 100644 --- a/OF DL/Entities/Config.cs +++ b/OF DL/Entities/Config.cs @@ -97,6 +97,9 @@ namespace OF_DL.Entities [ToggleableConfig] public bool IgnoreOwnMessages { get; set; } = false; + + [ToggleableConfig] + public bool DisableBrowserAuth { get; set; } = false; } public class CreatorConfig : IFileNameFormatConfig diff --git a/OF DL/Program.cs b/OF DL/Program.cs index b61ec14..ab1326b 100644 --- a/OF DL/Program.cs +++ b/OF DL/Program.cs @@ -251,6 +251,9 @@ public class Program config = new Entities.Config { + //Auth + DisableBrowserAuth = hoconConfig.GetBoolean("DisableBrowserAuth"), + // FFmpeg Settings FFmpegPath = hoconConfig.GetString("External.FFmpegPath"), @@ -363,6 +366,8 @@ public class Program { Entities.Config jsonConfig = new Entities.Config(); var hoconConfig = new StringBuilder(); + hoconConfig.AppendLine("# Auth"); + hoconConfig.AppendLine($"DisableBrowserAuth = {jsonConfig.DisableBrowserAuth.ToString().ToLower()}"); hoconConfig.AppendLine("# External Tools"); hoconConfig.AppendLine("External {"); hoconConfig.AppendLine($" FFmpegPath = \"{jsonConfig.FFmpegPath}\""); @@ -542,8 +547,22 @@ public class Program Environment.Exit(2); } - await LoadAuthFromBrowser(); - } + + if (!config!.DisableBrowserAuth) + { + await LoadAuthFromBrowser(); + } + else + { + AnsiConsole.MarkupLine($"\n[red]auth.json is missing. The file can be generated automatically when OF-DL is run in the standard, interactive mode.[/]\n"); + AnsiConsole.MarkupLine($"[red]You may also want to try using the browser extension which is documented here:[/]\n"); + AnsiConsole.MarkupLine($"[link]https://sim0n00ps.github.io/OF-DL/docs/config/auth#browser-extension[/]\n"); + AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]"); + + Console.ReadKey(); + Environment.Exit(2); + } + } } else { @@ -558,7 +577,20 @@ public class Program Environment.Exit(2); } - await LoadAuthFromBrowser(); + if (!config!.DisableBrowserAuth) + { + await LoadAuthFromBrowser(); + } + else + { + AnsiConsole.MarkupLine($"\n[red]auth.json is missing. The file can be generated automatically when OF-DL is run in the standard, interactive mode.[/]\n"); + AnsiConsole.MarkupLine($"[red]You may also want to try using the browser extension which is documented here:[/]\n"); + AnsiConsole.MarkupLine($"[link]https://sim0n00ps.github.io/OF-DL/docs/config/auth#browser-extension[/]\n"); + AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]"); + + Console.ReadKey(); + Environment.Exit(2); + } } //Added to stop cookie being filled with un-needed headers @@ -717,10 +749,10 @@ public class Program File.Delete("auth.json"); } - if (!cliNonInteractive) + if (!cliNonInteractive && !config!.DisableBrowserAuth) { - await LoadAuthFromBrowser(); - } + await LoadAuthFromBrowser(); + } if (auth == null) { @@ -2791,6 +2823,8 @@ public class Program } var hoconConfig = new StringBuilder(); + hoconConfig.AppendLine("# Auth"); + hoconConfig.AppendLine($"DisableBrowserAuth = {newConfig.DisableBrowserAuth.ToString().ToLower()}"); hoconConfig.AppendLine("# External Tools"); hoconConfig.AppendLine("External {"); hoconConfig.AppendLine($" FFmpegPath = \"{newConfig.FFmpegPath}\""); @@ -2947,6 +2981,8 @@ public class Program Log.Debug(configString); var hoconConfig = new StringBuilder(); + hoconConfig.AppendLine("# Auth"); + hoconConfig.AppendLine($"DisableBrowserAuth = {newConfig.DisableBrowserAuth.ToString().ToLower()}"); hoconConfig.AppendLine("# External Tools"); hoconConfig.AppendLine("External {"); hoconConfig.AppendLine($" FFmpegPath = \"{newConfig.FFmpegPath}\"");