Skip to content

Commit

Permalink
Playlists: Fix pagination of Invidious playlists (#3861)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamantazFox committed Jul 16, 2023
2 parents c8ade51 + d164776 commit ff6166e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/invidious/routes/playlists.cr
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,13 @@ module Invidious::Routes::Playlists
return error_template(500, ex)
end

page_count = (playlist.video_count / 200).to_i
page_count += 1 if (playlist.video_count % 200) > 0
if playlist.is_a? InvidiousPlaylist
page_count = (playlist.video_count / 100).to_i
page_count += 1 if (playlist.video_count % 100) > 0
else
page_count = (playlist.video_count / 200).to_i
page_count += 1 if (playlist.video_count % 200) > 0
end

if page > page_count
return env.redirect "/playlist?list=#{plid}&page=#{page_count}"
Expand All @@ -433,7 +438,11 @@ module Invidious::Routes::Playlists
end

begin
items = get_playlist_videos(playlist, offset: (page - 1) * 200)
if playlist.is_a? InvidiousPlaylist
items = get_playlist_videos(playlist, offset: (page - 1) * 100)
else
items = get_playlist_videos(playlist, offset: (page - 1) * 200)
end
rescue ex
return error_template(500, "Error encountered while retrieving playlist videos.<br>#{ex.message}")
end
Expand Down

0 comments on commit ff6166e

Please sign in to comment.