From 55bd7feb6c6027b9035c9ad2abd6f9b9bb7628e3 Mon Sep 17 00:00:00 2001 From: Ray Cheung Date: Sun, 1 Nov 2020 16:13:07 +0800 Subject: [PATCH] Work out the playlist continuation by video id (#1451) Not the best but it tries to work out the continuation. However it always picks the first match even if the same video appears multiple times in the playlist. --- src/invidious/videos.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 8e314fe0..73f5d251 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -1020,7 +1020,9 @@ def process_continuation(db, query, plid, id) if index = query["index"]?.try &.to_i? continuation = index else - continuation = id + index = PG_DB.query_one?("SELECT index FROM playlist_videos WHERE plid = $1 AND id = $2 LIMIT 1", plid, id, as: Int64) + i = PG_DB.query_one?("SELECT array_position(index, $2) - 1 FROM playlists WHERE id = $1 LIMIT 1", plid, index, as: Int32) + continuation = i || id end continuation ||= 0 end