Invidious is an alternative front-end to YouTube
Add CLI arguments to config file
saltycrys7a8620a570f1
diff --git a/src/invidious.cr b/src/invidious.crindex 5d19acf1..e32cb896 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -107,8 +107,6 @@ LOCALES = {YT_POOL = QUICPool.new(YT_URL, capacity: CONFIG.pool_size, timeout: 2.0)config = CONFIG-output = STDOUT-loglvl = LogLevel::DebugKemal.config.extra_options do |parser|parser.banner = "Usage: invidious [arguments]"@@ -128,12 +126,11 @@ Kemal.config.extra_options do |parser|exitendend- parser.on("-o OUTPUT", "--output=OUTPUT", "Redirect output (default: STDOUT)") do |output_arg|- FileUtils.mkdir_p(File.dirname(output_arg))- output = File.open(output_arg, mode: "a")+ parser.on("-o OUTPUT", "--output=OUTPUT", "Redirect output (default: #{config.output})") do |output|+ config.output = outputend- parser.on("-l LEVEL", "--log-level=LEVEL", "Log level, one of #{LogLevel.values} (default: #{loglvl})") do |loglvl_arg|- loglvl = LogLevel.parse(loglvl_arg)+ parser.on("-l LEVEL", "--log-level=LEVEL", "Log level, one of #{LogLevel.values} (default: #{config.log_level})") do |log_level|+ config.log_level = LogLevel.parse(log_level)endparser.on("-v", "--version", "Print version") doputs SOFTWARE.to_pretty_json@@ -143,7 +140,14 @@ endKemal::CLI.new ARGV-logger = Invidious::LogHandler.new(output, loglvl)+if config.output.upcase == "STDOUT"+ output = STDOUT+else+ FileUtils.mkdir_p(File.dirname(config.output))+ output = File.open(config.output, mode: "a")+end++logger = Invidious::LogHandler.new(output, config.log_level)# Check table integrityif CONFIG.check_tablesdiff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.crindex a6651a31..1866f8e5 100644--- a/src/invidious/helpers/helpers.cr+++ b/src/invidious/helpers/helpers.cr@@ -64,11 +64,13 @@ endclass Configinclude YAML::Serializable- property channel_threads : Int32 # Number of threads to use for crawling videos from channels (for updating subscriptions)- property feed_threads : Int32 # Number of threads to use for updating feeds+ property channel_threads : Int32 = 1 # Number of threads to use for crawling videos from channels (for updating subscriptions)+ property feed_threads : Int32 = 1 # Number of threads to use for updating feeds+ property output : String = "STDOUT" # Log file path or STDOUT+ property log_level : LogLevel = LogLevel::Debug # Default log level, valid YAML values are ints and strings, see src/invidious/helpers/logger.crproperty db : DBConfig # Database configurationproperty decrypt_polling : Bool = true # Use polling to keep decryption function up to date- property full_refresh : Bool # Used for crawling channels: threads should check all videos uploaded by a channel+ property full_refresh : Bool = false # Used for crawling channels: threads should check all videos uploaded by a channelproperty https_only : Bool? # Used to tell Invidious it is behind a proxy, so links to resources should be https://property hmac_key : String? # HMAC signing key for CSRF tokens and verifying pubsub subscriptionsproperty domain : String? # Domain to be used for links to resources on the site where an absolute URL is requireddiff --git a/src/invidious/helpers/logger.cr b/src/invidious/helpers/logger.crindex 4e4d7306..7c5b0247 100644--- a/src/invidious/helpers/logger.cr+++ b/src/invidious/helpers/logger.cr@@ -1,14 +1,14 @@require "logger"enum LogLevel- All- Trace- Debug- Info- Warn- Error- Fatal- Off+ All = 0+ Trace = 1+ Debug = 2+ Info = 3+ Warn = 4+ Error = 5+ Fatal = 6+ Off = 7endclass Invidious::LogHandler < Kemal::BaseLogHandler