move config checks for invidious companion

This commit is contained in:
Emilien 2024-11-08 21:05:17 +01:00
parent 409df4cff3
commit ff3305d521
3 changed files with 29 additions and 7 deletions

View File

@ -67,9 +67,19 @@ db:
## Accepted values: "http(s)://<IP-HOSTNAME>:<Port>"
## Default: <none>
##
# 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)://<IP-HOSTNAME>:<Port>"
## Default: <none>
##
#invidious_companion_key: "CHANGE_ME!!"
#########################################
#

View File

@ -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 =

View File

@ -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?