diff --git a/config/config.example.yml b/config/config.example.yml index 10734c3a..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 diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 786b65df..f0873df4 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -131,6 +131,9 @@ class Config # API URL for Anti-Captcha property captcha_api_url : String = "https://api.anti-captcha.com" + # Playlist length limit + property playlist_length_limit : Int32 = 500 + def disabled?(option) case disabled = CONFIG.disable_proxy when Bool diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr index 1f5ad8ef..421355bb 100644 --- a/src/invidious/routes/api/v1/authenticated.cr +++ b/src/invidious/routes/api/v1/authenticated.cr @@ -226,8 +226,8 @@ module Invidious::Routes::API::V1::Authenticated return error_json(403, "Invalid user") end - if playlist.index.size >= 500 - return error_json(400, "Playlist cannot have more than 500 videos") + if playlist.index.size >= CONFIG.playlist_length_limit + return error_json(400, "Playlist cannot have more than #{CONFIG.playlist_length_limit} videos") end video_id = env.params.json["videoId"].try &.as(String) diff --git a/src/invidious/routes/playlists.cr b/src/invidious/routes/playlists.cr index fe7e4e1c..0d242ee6 100644 --- a/src/invidious/routes/playlists.cr +++ b/src/invidious/routes/playlists.cr @@ -330,11 +330,11 @@ module Invidious::Routes::Playlists when "action_edit_playlist" # TODO: Playlist stub when "action_add_video" - if playlist.index.size >= 500 + if playlist.index.size >= CONFIG.playlist_length_limit if redirect - return error_template(400, "Playlist cannot have more than 500 videos") + return error_template(400, "Playlist cannot have more than #{CONFIG.playlist_length_limit} videos") else - return error_json(400, "Playlist cannot have more than 500 videos") + return error_json(400, "Playlist cannot have more than #{CONFIG.playlist_length_limit} videos") end end diff --git a/src/invidious/user/imports.cr b/src/invidious/user/imports.cr index f8b9e4e4..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 500 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