From d9bfb3d3056d1c9f628c0c7d1b363ebf63977e87 Mon Sep 17 00:00:00 2001 From: diogo Date: Fri, 16 Jul 2021 23:32:48 +0200 Subject: [PATCH 01/16] playlist starts at the offset --- src/invidious/playlists.cr | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index f56cc2ea..6c745945 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -437,17 +437,38 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) 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 - if offset >= 100 - # Normalize offset to match youtube's behavior (100 videos chunck per request) - offset = (offset / 100).to_i64 * 100_i64 + videos = [] of PlaylistVideo - ctoken = produce_playlist_continuation(playlist.id, offset) - initial_data = YoutubeAPI.browse(ctoken) - else - initial_data = YoutubeAPI.browse("VL" + playlist.id, params: "") + until videos.size >= 50 || videos.size == 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 + ctoken = produce_playlist_continuation(playlist.id, normalized_offset) + initial_data = request_youtube_api_browse(ctoken) + else + initial_data = request_youtube_api_browse("VL" + playlist.id, params: "") + end + + videos += extract_playlist_videos(initial_data) + + if continuation + until videos[0].id == continuation + videos.shift + end + elsif + until videos[0].index == offset + videos.shift + end + end + + if offset == 0 + offset = videos[0].index + end + + offset += 50 end - return extract_playlist_videos(initial_data) + return videos end end From 7eba7fbcc79eba2c15f2fde9f6d011a7d1c1541c Mon Sep 17 00:00:00 2001 From: diogo Date: Sat, 17 Jul 2021 01:38:24 +0200 Subject: [PATCH 02/16] add index to playlist item --- src/invidious/playlists.cr | 2 +- src/invidious/views/components/item.ecr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 6c745945..771f5ba1 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -545,7 +545,7 @@ def template_playlist(playlist) playlist["videos"].as_a.each do |video| html += <<-END_HTML
  • - +

    #{recode_length_seconds(video["lengthSeconds"].as_i)}

    diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index b15ae255..d084bfd4 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -48,7 +48,7 @@

    <%= HTML.escape(item.author) %>

    <% when PlaylistVideo %> - + <% if !env.get("preferences").as(Preferences).thin_mode %>
    From 440105976f20fcd63ad3d821b9aa8e0c900f0187 Mon Sep 17 00:00:00 2001 From: diogo Date: Sat, 17 Jul 2021 01:48:33 +0200 Subject: [PATCH 03/16] fix cases when high offset video from playlist has no offset in url --- src/invidious/playlists.cr | 14 ++++++++++---- 1 file 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 From 65e45c407997878d110a159363d7131a7ed24349 Mon Sep 17 00:00:00 2001 From: diogo Date: Sat, 17 Jul 2021 01:50:53 +0200 Subject: [PATCH 04/16] linting --- src/invidious/playlists.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 33623ec2..568f3e2e 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 || offset >= 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 From 0a9e19646afad11bccfba5430ed526178952d479 Mon Sep 17 00:00:00 2001 From: diogo Date: Sat, 17 Jul 2021 19:43:03 +0200 Subject: [PATCH 05/16] pass the api/v1/playlists with videos before the offset --- src/invidious/playlists.cr | 7 ++++--- src/invidious/routes/api/v1/misc.cr | 30 ++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 568f3e2e..a4ef212f 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -439,7 +439,8 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) else videos = [] of PlaylistVideo - until videos.size >= 50 || videos.size == playlist.video_count || offset >= playlist.video_count + original_offset = offset + until videos.size >= 100 || 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 @@ -459,7 +460,7 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) end end else - until videos[0].index == offset + until videos[0].index == original_offset videos.shift if videos.size == 0 break @@ -550,7 +551,7 @@ def template_playlist(playlist) playlist["videos"].as_a.each do |video| html += <<-END_HTML -
  • +
  • diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr index cf95bd9b..9aa75e09 100644 --- a/src/invidious/routes/api/v1/misc.cr +++ b/src/invidious/routes/api/v1/misc.cr @@ -24,7 +24,7 @@ module Invidious::Routes::API::V1::Misc offset ||= env.params.query["page"]?.try &.to_i?.try { |page| (page - 1) * 100 } offset ||= 0 - continuation = env.params.query["continuation"]? + video_id = env.params.query["continuation"]? format = env.params.query["format"]? format ||= "json" @@ -46,12 +46,32 @@ module Invidious::Routes::API::V1::Misc return error_json(404, "Playlist does not exist.") end - response = playlist.to_json(offset, locale, continuation: continuation) + # includes into the playlist a maximum of 20 videos, before the offset + lookback = 20 + if offset > 0 + lookback = offset < lookback ? offset : lookback + response = playlist.to_json(offset - lookback, locale) + json_response = JSON.parse(response) + else + # Unless the continuation is really the offset 0, it becomes expensive. + # It happens when the offset is not set. + # First we find the actual offset, and then we lookback + # it shouldn't happen often though + + response = playlist.to_json(offset, locale, continuation: continuation) + json_response = JSON.parse(response) + + if json_response["videos"].as_a[0]["index"] != offset + offset = json_response["videos"].as_a[0]["index"].as_i + lookback = offset < 50 ? offset : 50 + response = playlist.to_json(offset - lookback, locale) + json_response = JSON.parse(response) + end + end if format == "html" - response = JSON.parse(response) - playlist_html = template_playlist(response) - index, next_video = response["videos"].as_a.skip(1).select { |video| !video["author"].as_s.empty? }[0]?.try { |v| {v["index"], v["videoId"]} } || {nil, nil} + playlist_html = template_playlist(json_response) + index, next_video = json_response["videos"].as_a.skip(1 + lookback).select { |video| !video["author"].as_s.empty? }[0]?.try { |v| {v["index"], v["videoId"]} } || {nil, nil} response = { "playlistHtml" => playlist_html, From f13fb80b427f0d1151053c7c20ba37a466538677 Mon Sep 17 00:00:00 2001 From: diogo Date: Sat, 17 Jul 2021 19:43:51 +0200 Subject: [PATCH 06/16] scroll the nextVideo into the top --- assets/js/watch.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/js/watch.js b/assets/js/watch.js index 3909edd4..1579abf4 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -149,6 +149,8 @@ function get_playlist(plid, retries) { if (xhr.readyState == 4) { if (xhr.status == 200) { playlist.innerHTML = xhr.response.playlistHtml; + var nextVideo = document.getElementById(xhr.response.nextVideo); + nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop; if (xhr.response.nextVideo) { player.on('ended', function () { From 24bc3e27045c2e93223255b9b383f14879dc8699 Mon Sep 17 00:00:00 2001 From: diogo Date: Sun, 18 Jul 2021 17:43:37 +0300 Subject: [PATCH 07/16] no need to normalize the offset --- src/invidious/playlists.cr | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index a4ef212f..1718bc2f 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -439,17 +439,11 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) else videos = [] of PlaylistVideo - original_offset = offset until videos.size >= 100 || 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 - ctoken = produce_playlist_continuation(playlist.id, normalized_offset) - initial_data = request_youtube_api_browse(ctoken) - else - initial_data = request_youtube_api_browse("VL" + playlist.id, params: "") - end + # 100 videos per request + ctoken = produce_playlist_continuation(playlist.id, offset) + initial_data = request_youtube_api_browse(ctoken) videos += extract_playlist_videos(initial_data) if continuation @@ -459,13 +453,6 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) break end end - else - until videos[0].index == original_offset - videos.shift - if videos.size == 0 - break - end - end end if videos.size > 0 && offset == 0 From 6176da3cbb3decdab0da1a36003a965f3f752000 Mon Sep 17 00:00:00 2001 From: diogo Date: Sun, 18 Jul 2021 18:05:44 +0300 Subject: [PATCH 08/16] linting --- src/invidious/playlists.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 1718bc2f..20128462 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -440,7 +440,6 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) videos = [] of PlaylistVideo until videos.size >= 100 || videos.size == playlist.video_count || offset >= playlist.video_count - # 100 videos per request ctoken = produce_playlist_continuation(playlist.id, offset) initial_data = request_youtube_api_browse(ctoken) From 84124b837db306c9bd5575fd6f87c413baed1e5b Mon Sep 17 00:00:00 2001 From: diogo Date: Mon, 19 Jul 2021 12:09:17 +0300 Subject: [PATCH 09/16] use v1/next instead of searching for the continuation index --- src/invidious/playlists.cr | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 20128462..b17ff9ef 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -437,6 +437,12 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) 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 + + if continuation + initial_data = request_youtube_api_next(continuation, playlist.id) + offset = initial_data["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"]["currentIndex"].as_i + end + videos = [] of PlaylistVideo until videos.size >= 100 || videos.size == playlist.video_count || offset >= playlist.video_count @@ -445,19 +451,6 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) initial_data = request_youtube_api_browse(ctoken) videos += extract_playlist_videos(initial_data) - if continuation - until videos[0].id == continuation - videos.shift - if videos.size == 0 - break - end - end - end - - if videos.size > 0 && offset == 0 - offset = videos[0].index - end - offset += 100 end From dccdf38ce725e81778ce3b641a5a537619c774ef Mon Sep 17 00:00:00 2001 From: diogo Date: Mon, 19 Jul 2021 12:09:48 +0300 Subject: [PATCH 10/16] increase the max videos in a playlist --- src/invidious/playlists.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index b17ff9ef..ad142dd6 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -445,7 +445,7 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) videos = [] of PlaylistVideo - until videos.size >= 100 || videos.size == playlist.video_count || offset >= playlist.video_count + until videos.size >= 200 || videos.size == playlist.video_count || offset >= playlist.video_count # 100 videos per request ctoken = produce_playlist_continuation(playlist.id, offset) initial_data = request_youtube_api_browse(ctoken) From 62dc6293375a53c9a4151da3213ecee6a2faa097 Mon Sep 17 00:00:00 2001 From: diogo Date: Mon, 19 Jul 2021 12:15:03 +0300 Subject: [PATCH 11/16] linting --- src/invidious/playlists.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index ad142dd6..a290ca61 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -437,7 +437,6 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) 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 - if continuation initial_data = request_youtube_api_next(continuation, playlist.id) offset = initial_data["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"]["currentIndex"].as_i From e3df9f9eaddfa8eb4781512de7d4fd97d1729b10 Mon Sep 17 00:00:00 2001 From: diogo Date: Mon, 19 Jul 2021 17:21:04 +0300 Subject: [PATCH 12/16] use dig for getting the video index --- src/invidious/playlists.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index a290ca61..788a4dbc 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 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 From ee94ccdeb0097bc14dbde9ca945784c3a630347a Mon Sep 17 00:00:00 2001 From: diogo Date: Sun, 8 Aug 2021 19:05:47 +0200 Subject: [PATCH 13/16] update to new YoutubeAPI --- src/invidious/playlists.cr | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 788a4dbc..7f80dc11 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -438,7 +438,10 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) playlist.id, playlist.index, offset, as: PlaylistVideo) else if continuation - initial_data = request_youtube_api_next(continuation, playlist.id) + initial_data = YoutubeAPI.next({ + "videoId" => continuation, + "playlistId" => playlist.id, + }) offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "playlist", "playlist", "currentIndex").try &.as_i || offset end @@ -447,7 +450,7 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) until videos.size >= 200 || videos.size == playlist.video_count || offset >= playlist.video_count # 100 videos per request ctoken = produce_playlist_continuation(playlist.id, offset) - initial_data = request_youtube_api_browse(ctoken) + initial_data = YoutubeAPI.browse(ctoken) videos += extract_playlist_videos(initial_data) offset += 100 From c4c8a1050769a4ab25ab57ba62b96cf2b30fa6f9 Mon Sep 17 00:00:00 2001 From: diogo Date: Mon, 9 Aug 2021 09:36:44 +0200 Subject: [PATCH 14/16] rename from continuation to video_id on get_playlist_videos --- src/invidious/playlists.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 7f80dc11..31b48fe8 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -426,7 +426,7 @@ def fetch_playlist(plid, locale) }) end -def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) +def get_playlist_videos(db, playlist, offset, locale = nil, video_id = nil) # Show empy playlist if requested page is out of range # (e.g, when a new playlist has been created, offset will be negative) if offset >= playlist.video_count || offset < 0 @@ -437,9 +437,9 @@ def get_playlist_videos(db, playlist, offset, locale = nil, continuation = nil) 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 - if continuation + if video_id initial_data = YoutubeAPI.next({ - "videoId" => continuation, + "videoId" => video_id, "playlistId" => playlist.id, }) offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "playlist", "playlist", "currentIndex").try &.as_i || offset From a1d6411f1f7232c98a17e9d3f17d61a771068780 Mon Sep 17 00:00:00 2001 From: diogo Date: Mon, 9 Aug 2021 09:47:37 +0200 Subject: [PATCH 15/16] propagate video_id field on getting playlists --- src/invidious/playlists.cr | 22 +++++++++++----------- src/invidious/routes/api/v1/misc.cr | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 31b48fe8..5034844e 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -107,7 +107,7 @@ struct Playlist property updated : Time property thumbnail : String? - def to_json(offset, locale, json : JSON::Builder, continuation : String? = nil) + def to_json(offset, locale, json : JSON::Builder, video_id : String? = nil) json.object do json.field "type", "playlist" json.field "title", self.title @@ -142,7 +142,7 @@ struct Playlist json.field "videos" do json.array do - videos = get_playlist_videos(PG_DB, self, offset: offset, locale: locale, continuation: continuation) + videos = get_playlist_videos(PG_DB, self, offset: offset, locale: locale, video_id: video_id) videos.each_with_index do |video, index| video.to_json(locale, json) end @@ -151,12 +151,12 @@ struct Playlist end end - def to_json(offset, locale, json : JSON::Builder? = nil, continuation : String? = nil) + def to_json(offset, locale, json : JSON::Builder? = nil, video_id : String? = nil) if json - to_json(offset, locale, json, continuation: continuation) + to_json(offset, locale, json, video_id: video_id) else JSON.build do |json| - to_json(offset, locale, json, continuation: continuation) + to_json(offset, locale, json, video_id: video_id) end end end @@ -196,7 +196,7 @@ struct InvidiousPlaylist end end - def to_json(offset, locale, json : JSON::Builder, continuation : String? = nil) + def to_json(offset, locale, json : JSON::Builder, video_id : String? = nil) json.object do json.field "type", "invidiousPlaylist" json.field "title", self.title @@ -218,11 +218,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) + index = PG_DB.query_one?("SELECT index FROM playlist_videos WHERE plid = $1 AND id = $2 LIMIT 1", self.id, video_id, as: Int64) offset = self.index.index(index) || 0 end - videos = get_playlist_videos(PG_DB, self, offset: offset, locale: locale, continuation: continuation) + videos = get_playlist_videos(PG_DB, self, offset: offset, locale: locale, video_id: video_id) videos.each_with_index do |video, index| video.to_json(locale, json, offset + index) end @@ -231,12 +231,12 @@ struct InvidiousPlaylist end end - def to_json(offset, locale, json : JSON::Builder? = nil, continuation : String? = nil) + def to_json(offset, locale, json : JSON::Builder? = nil, video_id : String? = nil) if json - to_json(offset, locale, json, continuation: continuation) + to_json(offset, locale, json, video_id: video_id) else JSON.build do |json| - to_json(offset, locale, json, continuation: continuation) + to_json(offset, locale, json, video_id: video_id) end end end diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr index 9aa75e09..da5a940c 100644 --- a/src/invidious/routes/api/v1/misc.cr +++ b/src/invidious/routes/api/v1/misc.cr @@ -58,7 +58,7 @@ module Invidious::Routes::API::V1::Misc # First we find the actual offset, and then we lookback # it shouldn't happen often though - response = playlist.to_json(offset, locale, continuation: continuation) + response = playlist.to_json(offset, locale, video_id: video_id) json_response = JSON.parse(response) if json_response["videos"].as_a[0]["index"] != offset From 678b10dbcfc71fd9001915892586de8c62357976 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 11 Oct 2021 23:52:57 +0200 Subject: [PATCH 16/16] Lookback 50 videos --- src/invidious/routes/api/v1/misc.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr index da5a940c..80b59fd5 100644 --- a/src/invidious/routes/api/v1/misc.cr +++ b/src/invidious/routes/api/v1/misc.cr @@ -47,9 +47,8 @@ module Invidious::Routes::API::V1::Misc end # includes into the playlist a maximum of 20 videos, before the offset - lookback = 20 if offset > 0 - lookback = offset < lookback ? offset : lookback + lookback = offset < 50 ? offset : 50 response = playlist.to_json(offset - lookback, locale) json_response = JSON.parse(response) else @@ -58,6 +57,7 @@ module Invidious::Routes::API::V1::Misc # First we find the actual offset, and then we lookback # it shouldn't happen often though + lookback = 0 response = playlist.to_json(offset, locale, video_id: video_id) json_response = JSON.parse(response)