From 7c45026383132c5aaf47b761ef132f5b0e635bb8 Mon Sep 17 00:00:00 2001 From: Jakub Filo Date: Wed, 28 Sep 2022 12:21:23 +0200 Subject: [PATCH] Fix playlist limit --- config/config.example.yml | 18 ++++++++---------- src/invidious/database/playlists.cr | 2 +- src/invidious/routes/subscriptions.cr | 2 +- src/invidious/user/imports.cr | 4 +++- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 424e2a38..160a2750 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -453,7 +453,13 @@ feed_threads: 1 ## #modified_source_code_url: "" - +## +## Maximum custom playlist length limit. +## +## Accepted values: Integer +## Default: 500 +## +#playlist_length_limit: 500 ######################################### # @@ -859,7 +865,7 @@ default_user_preferences: ## Default: false ## #automatic_instance_redirect: false - + ## ## Show the entire video description by default (when set to 'false', ## only the first few lines of the description are shown and a @@ -869,11 +875,3 @@ default_user_preferences: ## Default: false ## #extend_desc: false - - ## - ## Maximum custom playlist length limit. - ## - ## Accepted values: Integer - ## Default: 500 - ## - #playlist_length_limit: 500 diff --git a/src/invidious/database/playlists.cr b/src/invidious/database/playlists.cr index 5f47ff95..c6754a1e 100644 --- a/src/invidious/database/playlists.cr +++ b/src/invidious/database/playlists.cr @@ -248,7 +248,7 @@ module Invidious::Database::PlaylistVideos return PG_DB.query_one?(request, plid, index, as: String) end - def select_ids(plid : String, index : VideoIndex, limit = CONFIG.playlist_length_limit) : Array(String) + def select_ids(plid : String, index : VideoIndex, limit = 500) : Array(String) request = <<-SQL SELECT id FROM playlist_videos WHERE plid = $1 diff --git a/src/invidious/routes/subscriptions.cr b/src/invidious/routes/subscriptions.cr index ed595d9a..7b1fa876 100644 --- a/src/invidious/routes/subscriptions.cr +++ b/src/invidious/routes/subscriptions.cr @@ -120,7 +120,7 @@ module Invidious::Routes::Subscriptions json.field "privacy", playlist.privacy.to_s json.field "videos" do json.array do - Invidious::Database::PlaylistVideos.select_ids(playlist.id, playlist.index, limit: CONFIG.playlist_length_limit).each do |video_id| + Invidious::Database::PlaylistVideos.select_ids(playlist.id, playlist.index, limit: 500).each do |video_id| json.string video_id end end diff --git a/src/invidious/user/imports.cr b/src/invidious/user/imports.cr index bd929e4d..20ae0d47 100644 --- a/src/invidious/user/imports.cr +++ b/src/invidious/user/imports.cr @@ -71,7 +71,9 @@ struct Invidious::User Invidious::Database::Playlists.update_description(playlist.id, description) videos = item["videos"]?.try &.as_a?.try &.each_with_index do |video_id, idx| - raise InfoException.new("Playlist cannot have more than #{CONFIG.playlist_length_limit} videos") if idx > 500 + if idx > CONFIG.playlist_length_limit + raise InfoException.new("Playlist cannot have more than #{CONFIG.playlist_length_limit} videos") + end video_id = video_id.try &.as_s? next if !video_id