From 24bc3e27045c2e93223255b9b383f14879dc8699 Mon Sep 17 00:00:00 2001 From: diogo Date: Sun, 18 Jul 2021 17:43:37 +0300 Subject: [PATCH] no need to normalize the offset --- src/invidious/playlists.cr | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index a4ef212f..1718bc2f 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -439,17 +439,11 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) else videos = [] of PlaylistVideo - original_offset = offset until videos.size >= 100 || videos.size == playlist.video_count || offset >= playlist.video_count - if offset >= 100 - # Normalize offset to match youtube's behavior (100 videos chunck per request) - normalized_offset = (offset / 100).to_i64 * 100_i64 - ctoken = produce_playlist_continuation(playlist.id, normalized_offset) - initial_data = request_youtube_api_browse(ctoken) - else - initial_data = request_youtube_api_browse("VL" + playlist.id, params: "") - end + # 100 videos per request + ctoken = produce_playlist_continuation(playlist.id, offset) + initial_data = request_youtube_api_browse(ctoken) videos += extract_playlist_videos(initial_data) if continuation @@ -459,13 +453,6 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) break end end - else - until videos[0].index == original_offset - videos.shift - if videos.size == 0 - break - end - end end if videos.size > 0 && offset == 0