Invidious is an alternative front-end to YouTube
propagate video_id field on getting playlists
diogoa1d6411f1f72
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.crindex 31b48fe8..5034844e 100644--- a/src/invidious/playlists.cr+++ b/src/invidious/playlists.cr@@ -107,7 +107,7 @@ struct Playlistproperty updated : Timeproperty 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 dojson.field "type", "playlist"json.field "title", self.title@@ -142,7 +142,7 @@ struct Playlistjson.field "videos" dojson.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 Playlistendend- 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)elseJSON.build do |json|- to_json(offset, locale, json, continuation: continuation)+ to_json(offset, locale, json, video_id: video_id)endendend@@ -196,7 +196,7 @@ struct InvidiousPlaylistendend- 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 dojson.field "type", "invidiousPlaylist"json.field "title", self.title@@ -218,11 +218,11 @@ struct InvidiousPlaylistjson.field "videos" dojson.array doif !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) || 0end- 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 InvidiousPlaylistendend- 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)elseJSON.build do |json|- to_json(offset, locale, json, continuation: continuation)+ to_json(offset, locale, json, video_id: video_id)endendenddiff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.crindex 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