summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordiogo <diogo@riddleandcode.com>2021-07-17 01:48:33 +0200
committerSamantaz Fox <coding@samantaz.fr>2021-10-11 23:30:49 +0200
commit440105976f20fcd63ad3d821b9aa8e0c900f0187 (patch)
treeb27e15331784091455319cd8de092bc8b6f03198 /src
parent7eba7fbcc79eba2c15f2fde9f6d011a7d1c1541c (diff)
downloadinvidious-440105976f20fcd63ad3d821b9aa8e0c900f0187.tar.gz
invidious-440105976f20fcd63ad3d821b9aa8e0c900f0187.tar.bz2
invidious-440105976f20fcd63ad3d821b9aa8e0c900f0187.zip
fix cases when high offset video from playlist has no offset in url
Diffstat (limited to 'src')
-rw-r--r--src/invidious/playlists.cr14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index 771f5ba1..33623ec2 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -439,7 +439,7 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
else
videos = [] of PlaylistVideo
- until videos.size >= 50 || videos.size == playlist.video_count
+ until videos.size >= 50 || 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
@@ -454,18 +454,24 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil)
if continuation
until videos[0].id == continuation
videos.shift
+ if videos.size == 0
+ break
+ end
end
- elsif
+ else
until videos[0].index == offset
videos.shift
+ if videos.size == 0
+ break
+ end
end
end
- if offset == 0
+ if videos.size > 0 && offset == 0
offset = videos[0].index
end
- offset += 50
+ offset += 100
end
return videos