Skip to content

Commit

Permalink
Limit playlist to 100 items for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubery committed Oct 7, 2024
1 parent 1e750ea commit 0a55c6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/services/youtube/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Youtube
class CLI
class << self
DL_BINARY = "./bin/yt-dlp".freeze
PLAYLIST_LENGTH=100

def sanitize_id!(id)
unless id =~ /\A[a-z0-9\-_]+\z/i
raise(ArgumentError, "The id #{id.inspect} can be dangerous!")
Expand Down Expand Up @@ -34,9 +36,9 @@ def get_video_information(url)
end
end

def get_playlist_information(id)
def get_playlist_information(id, length: PLAYLIST_LENGTH)
sanitize_id!(id)
stdout, stderr, status = cmd("-j --flat-playlist \"#{id}\"")
stdout, stderr, status = cmd("-j -I1:#{length} --flat-playlist \"#{id}\"")
if status.exitstatus.zero?
stdout
else
Expand Down

Large diffs are not rendered by default.

0 comments on commit 0a55c6a

Please sign in to comment.