Skip to content

Commit 0a55c6a

Browse files
committed
Limit playlist to 100 items for performance
1 parent 1e750ea commit 0a55c6a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

app/services/youtube/cli.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module Youtube
22
class CLI
33
class << self
44
DL_BINARY = "./bin/yt-dlp".freeze
5+
PLAYLIST_LENGTH=100
6+
57
def sanitize_id!(id)
68
unless id =~ /\A[a-z0-9\-_]+\z/i
79
raise(ArgumentError, "The id #{id.inspect} can be dangerous!")
@@ -34,9 +36,9 @@ def get_video_information(url)
3436
end
3537
end
3638

37-
def get_playlist_information(id)
39+
def get_playlist_information(id, length: PLAYLIST_LENGTH)
3840
sanitize_id!(id)
39-
stdout, stderr, status = cmd("-j --flat-playlist \"#{id}\"")
41+
stdout, stderr, status = cmd("-j -I1:#{length} --flat-playlist \"#{id}\"")
4042
if status.exitstatus.zero?
4143
stdout
4244
else

test/fixtures/youtube_cli/get_playlist_information-291387ba69c6f12c2d43aed1aa63d5d6.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)