diff options
| author | TheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com> | 2020-12-08 11:55:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-08 11:55:40 +0000 |
| commit | eea6f5cbfaed81e181ac29e56804a36a33b522af (patch) | |
| tree | 322336bcdf3255584f7e6da4ba8879320770eecc /src | |
| parent | b55dcc16aeb9e26bf51c9702b75c4e03de5e148d (diff) | |
| parent | e55a09241e991ce2366608feb2e7c06bb67de8df (diff) | |
| download | invidious-eea6f5cbfaed81e181ac29e56804a36a33b522af.tar.gz invidious-eea6f5cbfaed81e181ac29e56804a36a33b522af.tar.bz2 invidious-eea6f5cbfaed81e181ac29e56804a36a33b522af.zip | |
Merge pull request #1549 from saltycrys/invidious-playlist-continuation
Fix Invidious playlist continuation
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/playlists.cr | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 2389de49..d5b41caa 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -220,6 +220,11 @@ struct InvidiousPlaylist json.field "videos" do json.array do + if !offset || offset == 0 + index = PG_DB.query_one?("SELECT index FROM playlist_videos WHERE plid = $1 AND id = $2 LIMIT 1", self.id, continuation, as: Int64) + offset = self.index.index(index) || 0 + end + videos = get_playlist_videos(PG_DB, self, offset: offset, locale: locale, continuation: continuation) videos.each_with_index do |video, index| video.to_json(locale, json, offset + index) @@ -412,11 +417,6 @@ end def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) if playlist.is_a? InvidiousPlaylist - if !offset - index = PG_DB.query_one?("SELECT index FROM playlist_videos WHERE plid = $1 AND id = $2 LIMIT 1", playlist.id, continuation, as: Int64) - offset = playlist.index.index(index) || 0 - end - 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) else fetch_playlist_videos(playlist.id, playlist.video_count, offset, locale, continuation) |
