From ff3305d52175c517b035d79b3c0c6a84809cbd0f Mon Sep 17 00:00:00 2001 From: Emilien <4016501+unixfox@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:05:17 +0100 Subject: [PATCH] move config checks for invidious companion --- config/config.example.yml | 12 +++++++++++- src/invidious.cr | 6 ------ src/invidious/config.cr | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 76a9a077..06e53541 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -67,9 +67,19 @@ db: ## Accepted values: "http(s)://:" ## Default: ## -# invidious_companion: +#invidious_companion: # - http://127.0.0.1:8282 +## +## API key for Invidious companion +## +## Needed when invidious_companion is configured +## +## Accepted values: "http(s)://:" +## Default: +## + +#invidious_companion_key: "CHANGE_ME!!" ######################################### # diff --git a/src/invidious.cr b/src/invidious.cr index 2fd9cdd8..b422dcbb 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -161,12 +161,6 @@ Invidious::Database.check_integrity(CONFIG) {% puts "\nDone checking player dependencies, now compiling Invidious...\n" %} {% end %} -# invidious_companion and signature_server can't work together -if CONFIG.signature_server && CONFIG.invidious_companion - puts "You can not run inv_sig_helper and invidious_companion at the same time." - exit(1) -end - # Misc DECRYPT_FUNCTION = diff --git a/src/invidious/config.cr b/src/invidious/config.cr index ba4224ce..7cd4bbdc 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -154,6 +154,9 @@ class Config # Invidious companion property invidious_companion : Array(String)? = nil + # Invidious companion API key + property invidious_companion_key : String? = nil + # Saved cookies in "name1=value1; name2=value2..." format @[YAML::Field(converter: Preferences::StringToCookies)] property cookies : HTTP::Cookies = HTTP::Cookies.new @@ -225,6 +228,21 @@ class Config end {% end %} + if CONFIG.invidious_companion + # invidious_companion and signature_server can't work together + if CONFIG.signature_server + puts "Config: You can not run inv_sig_helper and invidious_companion at the same time." + exit(1) + end + if !CONFIG.invidious_companion_key + puts "Config: Please configure a key if you are using invidious companion." + exit(1) + elsif CONFIG.invidious_companion_key == "CHANGE_ME!!" + puts "Config: The value of 'invidious_companion_key' needs to be changed!!" + exit(1) + end + end + # HMAC_key is mandatory # See: https://github.com/iv-org/invidious/issues/3854 if config.hmac_key.empty?