diff options
| -rw-r--r-- | .github/workflows/ci.yml | 30 | ||||
| -rw-r--r-- | src/invidious/playlists.cr | 10 |
2 files changed, 6 insertions, 34 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index affa7337..fde6506e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,37 +16,9 @@ jobs: steps: - uses: actions/checkout@v2 - # - name: Find out latest Crystal version - # run: | - # crystal_latest=$(curl -ILs -o /dev/null -w %{url_effective} https://github.com/crystal-lang/crystal/releases/latest | grep -o '[^/]*$') - # echo "crystal_latest=$crystal_latest" >> $GITHUB_ENV - # echo $crystal_latest - # - # - name: Cache Crystal - # uses: actions/cache@v2 - # with: - # path: ./crystal-bin - # key: crystal-${{ env.crystal_latest }} - # - # - name: Add custom Crystal dir to path - # run: echo "./crystal-bin" >> $GITHUB_PATH - # - # - name: Find out installed Crystal version - # run: | - # if ! [ -x "$(command -v crystal)" ]; then - # crystal_installed="none" - # else - # crystal_installed=$(crystal version | grep Crystal | awk '{print $2}') - # fi - # echo "crystal_installed=$crystal_installed" >> $GITHUB_ENV - # echo $crystal_installed - - name: Install Crystal uses: oprypin/install-crystal@v1.2.4 - # if: env.crystal_installed != env.crystal_latest - # with: - # destination: ./crystal-bin - + - name: Cache Shards uses: actions/cache@v2 with: 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) |
