no need to normalize the offset

This commit is contained in:
diogo 2021-07-18 17:43:37 +03:00 committed by Samantaz Fox
parent f13fb80b42
commit 24bc3e2704
No known key found for this signature in database
GPG Key ID: F42821059186176E

View File

@ -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