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

@ -70,6 +70,16 @@ db:
#invidious_companion: #invidious_companion:
# - http://127.0.0.1:8282 # - 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" %} {% puts "\nDone checking player dependencies, now compiling Invidious...\n" %}
{% end %} {% 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 # Misc
DECRYPT_FUNCTION = DECRYPT_FUNCTION =

View File

@ -154,6 +154,9 @@ class Config
# Invidious companion # Invidious companion
property invidious_companion : Array(String)? = nil property invidious_companion : Array(String)? = nil
# Invidious companion API key
property invidious_companion_key : String? = nil
# Saved cookies in "name1=value1; name2=value2..." format # Saved cookies in "name1=value1; name2=value2..." format
@[YAML::Field(converter: Preferences::StringToCookies)] @[YAML::Field(converter: Preferences::StringToCookies)]
property cookies : HTTP::Cookies = HTTP::Cookies.new property cookies : HTTP::Cookies = HTTP::Cookies.new
@ -225,6 +228,21 @@ class Config
end end
{% 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 # HMAC_key is mandatory
# See: https://github.com/iv-org/invidious/issues/3854 # See: https://github.com/iv-org/invidious/issues/3854
if config.hmac_key.empty? if config.hmac_key.empty?