mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-30 01:36:21 -05:00
use v1/next instead of searching for the continuation index
This commit is contained in:
parent
6176da3cbb
commit
84124b837d
@ -437,6 +437,12 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
|
|||||||
db.query_all("SELECT * FROM playlist_videos WHERE plid = $1 ORDER BY array_position($2, index) LIMIT 100 OFFSET $3",
|
db.query_all("SELECT * FROM playlist_videos WHERE plid = $1 ORDER BY array_position($2, index) LIMIT 100 OFFSET $3",
|
||||||
playlist.id, playlist.index, offset, as: PlaylistVideo)
|
playlist.id, playlist.index, offset, as: PlaylistVideo)
|
||||||
else
|
else
|
||||||
|
|
||||||
|
if continuation
|
||||||
|
initial_data = request_youtube_api_next(continuation, playlist.id)
|
||||||
|
offset = initial_data["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"]["currentIndex"].as_i
|
||||||
|
end
|
||||||
|
|
||||||
videos = [] of PlaylistVideo
|
videos = [] of PlaylistVideo
|
||||||
|
|
||||||
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
|
||||||
@ -445,19 +451,6 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
|
|||||||
initial_data = request_youtube_api_browse(ctoken)
|
initial_data = request_youtube_api_browse(ctoken)
|
||||||
videos += extract_playlist_videos(initial_data)
|
videos += extract_playlist_videos(initial_data)
|
||||||
|
|
||||||
if continuation
|
|
||||||
until videos[0].id == continuation
|
|
||||||
videos.shift
|
|
||||||
if videos.size == 0
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if videos.size > 0 && offset == 0
|
|
||||||
offset = videos[0].index
|
|
||||||
end
|
|
||||||
|
|
||||||
offset += 100
|
offset += 100
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user