forked from midou/invidious
Fix 'to_json' in struct PlaylistVideo
This commit is contained in:
parent
0ec94405ce
commit
86f75758a7
@ -57,7 +57,7 @@ struct PlaylistVideo
|
||||
end
|
||||
end
|
||||
|
||||
def to_json(locale, json : JSON::Builder, index : Int32?)
|
||||
def to_json(json : JSON::Builder, index : Int32? = nil)
|
||||
json.object do
|
||||
json.field "title", self.title
|
||||
json.field "videoId", self.id
|
||||
@ -81,14 +81,8 @@ struct PlaylistVideo
|
||||
end
|
||||
end
|
||||
|
||||
def to_json(locale, json : JSON::Builder? = nil, index : Int32? = nil)
|
||||
if json
|
||||
to_json(locale, json, index: index)
|
||||
else
|
||||
JSON.build do |json|
|
||||
to_json(locale, json, index: index)
|
||||
end
|
||||
end
|
||||
def to_json(_json : Nil, index : Int32? = nil)
|
||||
JSON.build { |json| to_json(json, index: index) }
|
||||
end
|
||||
end
|
||||
|
||||
@ -144,7 +138,7 @@ struct Playlist
|
||||
json.array do
|
||||
videos = get_playlist_videos(PG_DB, self, offset: offset, locale: locale, video_id: video_id)
|
||||
videos.each do |video|
|
||||
video.to_json(locale, json)
|
||||
video.to_json(json)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -224,7 +218,7 @@ struct InvidiousPlaylist
|
||||
|
||||
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)
|
||||
video.to_json(json, offset + index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -274,7 +274,10 @@ module Invidious::Routes::API::V1::Authenticated
|
||||
|
||||
env.response.headers["Location"] = "#{HOST_URL}/api/v1/auth/playlists/#{plid}/videos/#{playlist_video.index.to_u64.to_s(16).upcase}"
|
||||
env.response.status_code = 201
|
||||
playlist_video.to_json(locale, index: playlist.index.size)
|
||||
|
||||
JSON.build do |json|
|
||||
playlist_video.to_json(json, index: playlist.index.size)
|
||||
end
|
||||
end
|
||||
|
||||
def self.delete_video_in_playlist(env)
|
||||
|
Loading…
Reference in New Issue
Block a user