forked from midou/invidious
no need to normalize the offset
This commit is contained in:
parent
f13fb80b42
commit
24bc3e2704
@ -439,17 +439,11 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
|
|||||||
else
|
else
|
||||||
videos = [] of PlaylistVideo
|
videos = [] of PlaylistVideo
|
||||||
|
|
||||||
original_offset = offset
|
|
||||||
until videos.size >= 100 || videos.size == playlist.video_count || offset >= playlist.video_count
|
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)
|
videos += extract_playlist_videos(initial_data)
|
||||||
|
|
||||||
if continuation
|
if continuation
|
||||||
@ -459,13 +453,6 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
until videos[0].index == original_offset
|
|
||||||
videos.shift
|
|
||||||
if videos.size == 0
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if videos.size > 0 && offset == 0
|
if videos.size > 0 && offset == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user