use dig for getting the video index

This commit is contained in:
diogo 2021-07-19 17:21:04 +03:00 committed by Samantaz Fox
parent 62dc629337
commit e3df9f9ead
No known key found for this signature in database
GPG Key ID: F42821059186176E

View File

@ -439,7 +439,7 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
else
if continuation
initial_data = request_youtube_api_next(continuation, playlist.id)
offset = initial_data["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"]["currentIndex"].as_i
offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "playlist", "playlist", "currentIndex").try &.as_i || offset
end
videos = [] of PlaylistVideo