Allow to set maximum custom playlist length via a config variable.

このコミットが含まれているのは:
Jakub Filo 2022-08-27 22:36:07 +02:00
コミット 4818b89ab1
7個のファイルの変更19行の追加8行の削除

ファイルの表示

@ -869,3 +869,11 @@ default_user_preferences:
## Default: false
##
#extend_desc: false
##
## 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
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

ファイルの表示

@ -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 = 500) : Array(String)
def select_ids(plid : String, index : VideoIndex, limit = CONFIG.playlist_length_limit) : Array(String)
request = <<-SQL
SELECT id FROM playlist_videos
WHERE plid = $1

ファイルの表示

@ -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)

ファイルの表示

@ -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

ファイルの表示

@ -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: 500).each do |video_id|
Invidious::Database::PlaylistVideos.select_ids(playlist.id, playlist.index, limit: CONFIG.playlist_length_limit).each do |video_id|
json.string video_id
end
end

ファイルの表示

@ -71,7 +71,7 @@ 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
raise InfoException.new("Playlist cannot have more than #{CONFIG.playlist_length_limit} videos") if idx > 500
video_id = video_id.try &.as_s?
next if !video_id