summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2022-09-28 19:53:59 +0200
committerSamantaz Fox <coding@samantaz.fr>2022-09-28 19:53:59 +0200
commitdcfa0687f41e303c9e465ff52abe6d16331512d5 (patch)
treedb57822b1bdd2bc0e8f2e0352cc384befed572f5 /src
parenta01433960dcfb3c1429f664f77928be4cac2a6ff (diff)
parent7c45026383132c5aaf47b761ef132f5b0e635bb8 (diff)
downloadinvidious-dcfa0687f41e303c9e465ff52abe6d16331512d5.tar.gz
invidious-dcfa0687f41e303c9e465ff52abe6d16331512d5.tar.bz2
invidious-dcfa0687f41e303c9e465ff52abe6d16331512d5.zip
Allow to set max playlist length via a config variable (#3283)
Diffstat (limited to 'src')
-rw-r--r--src/invidious/config.cr3
-rw-r--r--src/invidious/routes/api/v1/authenticated.cr4
-rw-r--r--src/invidious/routes/playlists.cr6
-rw-r--r--src/invidious/user/imports.cr4
4 files changed, 11 insertions, 6 deletions
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