Playlists: Fix paging for Invidious playlists

This commit is contained in:
Chunky programmer 2023-06-06 16:27:26 -04:00
parent 545a5937d8
commit d164776024

View File

@ -410,8 +410,13 @@ module Invidious::Routes::Playlists
return error_template(500, ex)
end
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}"
@ -422,7 +427,11 @@ module Invidious::Routes::Playlists
end
begin
if playlist.is_a? InvidiousPlaylist
videos = get_playlist_videos(playlist, offset: (page - 1) * 100)
else
videos = 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