summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2021-10-29 14:59:53 +0200
committerSamantaz Fox <coding@samantaz.fr>2021-10-29 16:26:42 +0200
commit86f75758a76427dd7564ef17bc6a33b6d7ce2e62 (patch)
tree4d478533e0ca85c224fa5deba1dbff6be6d98bb0 /src
parent0ec94405ce2b9f421dc85e2d5941e415e9d97f3d (diff)
downloadinvidious-86f75758a76427dd7564ef17bc6a33b6d7ce2e62.tar.gz
invidious-86f75758a76427dd7564ef17bc6a33b6d7ce2e62.tar.bz2
invidious-86f75758a76427dd7564ef17bc6a33b6d7ce2e62.zip
Fix 'to_json' in struct PlaylistVideo
Diffstat (limited to 'src')
-rw-r--r--src/invidious/playlists.cr16
-rw-r--r--src/invidious/routes/api/v1/authenticated.cr5
2 files changed, 9 insertions, 12 deletions
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index 443d19d7..e25180c1 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -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
diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr
index 7950b302..cdd9e2f6 100644
--- a/src/invidious/routes/api/v1/authenticated.cr
+++ b/src/invidious/routes/api/v1/authenticated.cr
@@ -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)