Skip to content

Commit

Permalink
move config checks for invidious companion
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Nov 8, 2024
1 parent 37df2b4 commit 97ae26c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
12 changes: 11 additions & 1 deletion config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!!"

#########################################
#
Expand Down
6 changes: 0 additions & 6 deletions src/invidious.cr
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,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 =
Expand Down
18 changes: 18 additions & 0 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,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
Expand Down Expand Up @@ -223,6 +226,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?
Expand Down

0 comments on commit 97ae26c

Please sign in to comment.