update to new YoutubeAPI

This commit is contained in:
diogo 2021-08-08 19:05:47 +02:00 committed by Samantaz Fox
parent e3df9f9ead
commit ee94ccdeb0
No known key found for this signature in database
GPG key ID: F42821059186176E

View file

@ -438,7 +438,10 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
playlist.id, playlist.index, offset, as: PlaylistVideo) playlist.id, playlist.index, offset, as: PlaylistVideo)
else else
if continuation if continuation
initial_data = request_youtube_api_next(continuation, playlist.id) initial_data = YoutubeAPI.next({
"videoId" => continuation,
"playlistId" => playlist.id,
})
offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "playlist", "playlist", "currentIndex").try &.as_i || offset offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "playlist", "playlist", "currentIndex").try &.as_i || offset
end end
@ -447,7 +450,7 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
until videos.size >= 200 || videos.size == playlist.video_count || offset >= playlist.video_count until videos.size >= 200 || videos.size == playlist.video_count || offset >= playlist.video_count
# 100 videos per request # 100 videos per request
ctoken = produce_playlist_continuation(playlist.id, offset) ctoken = produce_playlist_continuation(playlist.id, offset)
initial_data = request_youtube_api_browse(ctoken) initial_data = YoutubeAPI.browse(ctoken)
videos += extract_playlist_videos(initial_data) videos += extract_playlist_videos(initial_data)
offset += 100 offset += 100