|
|
@ -107,7 +107,7 @@ struct Playlist
|
|
|
|
property updated : Time
|
|
|
|
property updated : Time
|
|
|
|
property thumbnail : String?
|
|
|
|
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.object do
|
|
|
|
json.field "type", "playlist"
|
|
|
|
json.field "type", "playlist"
|
|
|
|
json.field "title", self.title
|
|
|
|
json.field "title", self.title
|
|
|
@ -142,7 +142,7 @@ struct Playlist
|
|
|
|
|
|
|
|
|
|
|
|
json.field "videos" do
|
|
|
|
json.field "videos" do
|
|
|
|
json.array 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|
|
|
|
|
videos.each_with_index do |video, index|
|
|
|
|
video.to_json(locale, json)
|
|
|
|
video.to_json(locale, json)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -151,12 +151,12 @@ struct Playlist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
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
|
|
|
|
if json
|
|
|
|
to_json(offset, locale, json, continuation: continuation)
|
|
|
|
to_json(offset, locale, json, video_id: video_id)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
JSON.build do |json|
|
|
|
|
JSON.build do |json|
|
|
|
|
to_json(offset, locale, json, continuation: continuation)
|
|
|
|
to_json(offset, locale, json, video_id: video_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -196,7 +196,7 @@ struct InvidiousPlaylist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
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.object do
|
|
|
|
json.field "type", "invidiousPlaylist"
|
|
|
|
json.field "type", "invidiousPlaylist"
|
|
|
|
json.field "title", self.title
|
|
|
|
json.field "title", self.title
|
|
|
@ -218,11 +218,11 @@ struct InvidiousPlaylist
|
|
|
|
json.field "videos" do
|
|
|
|
json.field "videos" do
|
|
|
|
json.array do
|
|
|
|
json.array do
|
|
|
|
if !offset || offset == 0
|
|
|
|
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
|
|
|
|
offset = self.index.index(index) || 0
|
|
|
|
end
|
|
|
|
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|
|
|
|
|
videos.each_with_index do |video, index|
|
|
|
|
video.to_json(locale, json, offset + index)
|
|
|
|
video.to_json(locale, json, offset + index)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -231,12 +231,12 @@ struct InvidiousPlaylist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
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
|
|
|
|
if json
|
|
|
|
to_json(offset, locale, json, continuation: continuation)
|
|
|
|
to_json(offset, locale, json, video_id: video_id)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
JSON.build do |json|
|
|
|
|
JSON.build do |json|
|
|
|
|
to_json(offset, locale, json, continuation: continuation)
|
|
|
|
to_json(offset, locale, json, video_id: video_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|