Merge branch 'iv-org:master' into master

This commit is contained in:
Ramon 2025-09-12 14:00:32 +02:00 committed by GitHub
commit 7156d38664
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 38 additions and 22 deletions

View File

@ -61,39 +61,32 @@ db:
## When this setting is commented out, Invidious companion is not used. ## When this setting is commented out, Invidious companion is not used.
## Otherwise, Invidious will proxy the requests to Invidious companion. ## Otherwise, Invidious will proxy the requests to Invidious companion.
## ##
## Note: multiple URL can be configured. In this case, invidious will ## Note: multiple URL can be configured. In this case, Invidious will
## randomly pick one every time video data needs to be retrieved. This ## randomly pick one every time video data needs to be retrieved. This
## URL is then kept in the video metadata cache to allow video playback ## URL is then kept in the video metadata cache to allow video playback
## to work. Once said cache has expired, requesting that video's data ## to work. Once said cache has expired, requesting that video's data
## again will cause a new companion URL to be picked. ## again will cause a new companion URL to be picked.
## ##
## The parameter private_url needs to be configured for the internal ## The parameter private_url is required for the internal communication
## communication between the companion and Invidious. ## between Invidious companion and Invidious.
## And public_url is the public URL from which companion is listening
## to the requests from the user(s).
## ##
## If you are using a reverse proxy then you will probably need to ## The optional parameter public_url is the public URL from which
## configure the public_url to be the same as the domain used for Invidious. ## Invidious companion is listening to the requests from the user(s).
## Also apply when used from an external IP address (without a domain). ## When this setting is commented out, Invidious proxy all requests to
## Examples: https://MYINVIDIOUSDOMAIN/companion or http://192.168.1.100:8282/companion ## Invidious companion. Useful for simple setups.
## ## Otherwise, requests from the user(s) will reach Invidious companion directly.
## Both parameter can have identical URL when Invidious is hosted in ## And you will need to configure a reverse proxy with separate routes
## an internal network or at home or locally (localhost). ## for Invidious and Invidious companion.
## ## Read the post-install documentation for advanced reverse proxy
## NOTE: If public_url is omitted, Invidious will use its built-in proxy ## documentation: https://docs.invidious.io/installation/#post-install-configuration
## to route companion requests through /companion, which is useful for
## simple setups where companion runs on the same network. When using
## the built-in proxy, CSP headers are not modified since requests
## stay within the same domain.
## ##
## Accepted values: "http(s)://<IP-HOSTNAME>:<Port>" ## Accepted values: "http(s)://<IP-HOSTNAME>:<Port>"
## Default: <none> ## Default: <none>
## ##
#invidious_companion: #invidious_companion:
# - private_url: "http://localhost:8282/companion" # - private_url: "http://localhost:8282/companion"
# public_url: "http://localhost:8282/companion" # # Uncomment for advanced reverse proxy configuration (see above).
# # Example with built-in proxy (omit public_url): # # public_url: "http://localhost:8282/companion"
# # - private_url: "http://localhost:8282/companion"
## ##
## API key for Invidious companion, used for securing the communication ## API key for Invidious companion, used for securing the communication

View File

@ -122,6 +122,8 @@
"Redirect homepage to feed: ": "Redirect homepage to feed: ", "Redirect homepage to feed: ": "Redirect homepage to feed: ",
"preferences_max_results_label": "Number of videos shown in feed: ", "preferences_max_results_label": "Number of videos shown in feed: ",
"preferences_sort_label": "Sort videos by: ", "preferences_sort_label": "Sort videos by: ",
"preferences_default_playlist": "Default playlist: ",
"preferences_default_playlist_none": "No default playlist set",
"published": "published", "published": "published",
"published - reverse": "published - reverse", "published - reverse": "published - reverse",
"alphabetically": "alphabetically", "alphabetically": "alphabetically",

View File

@ -78,6 +78,8 @@
"Redirect homepage to feed: ": "Redirigir la página de inicio a la fuente: ", "Redirect homepage to feed: ": "Redirigir la página de inicio a la fuente: ",
"preferences_max_results_label": "Número de videos mostrados en la fuente: ", "preferences_max_results_label": "Número de videos mostrados en la fuente: ",
"preferences_sort_label": "Ordenar los videos por: ", "preferences_sort_label": "Ordenar los videos por: ",
"preferences_default_playlist": "Lista de reproducción por defecto: ",
"preferences_default_playlist_none": "Ninguna lista de reproducción por defecto establecida",
"published": "fecha de publicación", "published": "fecha de publicación",
"published - reverse": "fecha de publicación: orden inverso", "published - reverse": "fecha de publicación: orden inverso",
"alphabetically": "alfabéticamente", "alphabetically": "alfabéticamente",

View File

@ -52,6 +52,8 @@ struct ConfigPreferences
property vr_mode : Bool = true property vr_mode : Bool = true
property show_nick : Bool = true property show_nick : Bool = true
property save_player_pos : Bool = false property save_player_pos : Bool = false
@[YAML::Field(ignore: true)]
property default_playlist : String? = nil
def to_tuple def to_tuple
{% begin %} {% begin %}

View File

@ -144,6 +144,8 @@ module Invidious::Routes::PreferencesRoute
notifications_only ||= "off" notifications_only ||= "off"
notifications_only = notifications_only == "on" notifications_only = notifications_only == "on"
default_playlist = env.params.body["default_playlist"]?.try &.as(String)
# Convert to JSON and back again to take advantage of converters used for compatibility # Convert to JSON and back again to take advantage of converters used for compatibility
preferences = Preferences.from_json({ preferences = Preferences.from_json({
annotations: annotations, annotations: annotations,
@ -180,6 +182,7 @@ module Invidious::Routes::PreferencesRoute
vr_mode: vr_mode, vr_mode: vr_mode,
show_nick: show_nick, show_nick: show_nick,
save_player_pos: save_player_pos, save_player_pos: save_player_pos,
default_playlist: default_playlist,
}.to_json) }.to_json)
if user = env.get? "user" if user = env.get? "user"

View File

@ -56,6 +56,7 @@ struct Preferences
property extend_desc : Bool = CONFIG.default_user_preferences.extend_desc property extend_desc : Bool = CONFIG.default_user_preferences.extend_desc
property volume : Int32 = CONFIG.default_user_preferences.volume property volume : Int32 = CONFIG.default_user_preferences.volume
property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos
property default_playlist : String? = nil
module BoolToString module BoolToString
def self.to_json(value : String, json : JSON::Builder) def self.to_json(value : String, json : JSON::Builder)

View File

@ -126,6 +126,19 @@
<input name="save_player_pos" id="save_player_pos" type="checkbox" <% if preferences.save_player_pos %>checked<% end %>> <input name="save_player_pos" id="save_player_pos" type="checkbox" <% if preferences.save_player_pos %>checked<% end %>>
</div> </div>
<% if user = env.get?("user").try &.as(User) %>
<% playlists = Invidious::Database::Playlists.select_user_created_playlists(user.email) %>
<div class="pure-control-group">
<label for="default_playlist"><%= translate(locale, "preferences_default_playlist") %></label>
<select name="default_playlist" id="default_playlist">
<option value=""><%= translate(locale, "preferences_default_playlist_none") %></option>
<% playlists.each do |plid, playlist_title| %>
<option value="<%= plid %>" <%= "selected" if user.preferences.default_playlist == plid %>><%= HTML.escape(playlist_title) %></option>
<% end %>
</select>
</div>
<% end %>
<legend><%= translate(locale, "preferences_category_visual") %></legend> <legend><%= translate(locale, "preferences_category_visual") %></legend>
<div class="pure-control-group"> <div class="pure-control-group">

View File

@ -163,7 +163,7 @@ we're going to need to do it here in order to allow for translations.
<label for="playlist_id"><%= translate(locale, "Add to playlist: ") %></label> <label for="playlist_id"><%= translate(locale, "Add to playlist: ") %></label>
<select style="width:100%" name="playlist_id" id="playlist_id"> <select style="width:100%" name="playlist_id" id="playlist_id">
<% playlists.each do |plid, playlist_title| %> <% playlists.each do |plid, playlist_title| %>
<option data-plid="<%= plid %>" value="<%= plid %>"><%= HTML.escape(playlist_title) %></option> <option data-plid="<%= plid %>" value="<%= plid %>" <%= "selected" if user.preferences.default_playlist == plid %>><%= HTML.escape(playlist_title) %></option>
<% end %> <% end %>
</select> </select>
</div> </div>