mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:35:38 -04:00
Allow to set max playlist length via a config variable (#3283)
This commit is contained in:
commit
dcfa0687f4
@ -453,7 +453,13 @@ feed_threads: 1
|
|||||||
##
|
##
|
||||||
#modified_source_code_url: ""
|
#modified_source_code_url: ""
|
||||||
|
|
||||||
|
##
|
||||||
|
## Maximum custom playlist length limit.
|
||||||
|
##
|
||||||
|
## Accepted values: Integer
|
||||||
|
## Default: 500
|
||||||
|
##
|
||||||
|
#playlist_length_limit: 500
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
#
|
#
|
||||||
|
@ -131,6 +131,9 @@ class Config
|
|||||||
# API URL for Anti-Captcha
|
# API URL for Anti-Captcha
|
||||||
property captcha_api_url : String = "https://api.anti-captcha.com"
|
property captcha_api_url : String = "https://api.anti-captcha.com"
|
||||||
|
|
||||||
|
# Playlist length limit
|
||||||
|
property playlist_length_limit : Int32 = 500
|
||||||
|
|
||||||
def disabled?(option)
|
def disabled?(option)
|
||||||
case disabled = CONFIG.disable_proxy
|
case disabled = CONFIG.disable_proxy
|
||||||
when Bool
|
when Bool
|
||||||
|
@ -226,8 +226,8 @@ module Invidious::Routes::API::V1::Authenticated
|
|||||||
return error_json(403, "Invalid user")
|
return error_json(403, "Invalid user")
|
||||||
end
|
end
|
||||||
|
|
||||||
if playlist.index.size >= 500
|
if playlist.index.size >= CONFIG.playlist_length_limit
|
||||||
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
|
||||||
|
|
||||||
video_id = env.params.json["videoId"].try &.as(String)
|
video_id = env.params.json["videoId"].try &.as(String)
|
||||||
|
@ -330,11 +330,11 @@ module Invidious::Routes::Playlists
|
|||||||
when "action_edit_playlist"
|
when "action_edit_playlist"
|
||||||
# TODO: Playlist stub
|
# TODO: Playlist stub
|
||||||
when "action_add_video"
|
when "action_add_video"
|
||||||
if playlist.index.size >= 500
|
if playlist.index.size >= CONFIG.playlist_length_limit
|
||||||
if redirect
|
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
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,7 +71,9 @@ struct Invidious::User
|
|||||||
Invidious::Database::Playlists.update_description(playlist.id, description)
|
Invidious::Database::Playlists.update_description(playlist.id, description)
|
||||||
|
|
||||||
videos = item["videos"]?.try &.as_a?.try &.each_with_index do |video_id, idx|
|
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?
|
video_id = video_id.try &.as_s?
|
||||||
next if !video_id
|
next if !video_id
|
||||||
|
Loading…
Reference in New Issue
Block a user