summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/invidious/helpers/helpers.cr4
-rw-r--r--src/invidious/routes/api/v1/videos.cr2
-rw-r--r--src/invidious/videos.cr17
3 files changed, 11 insertions, 12 deletions
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 9c053d74..c3b356a9 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -206,7 +206,7 @@ def create_notification_stream(env, topics, connection_channel)
video = get_video(video_id, PG_DB)
video.published = published
- response = JSON.parse(video.to_json(locale))
+ response = JSON.parse(video.to_json(locale, nil))
if fields_text = env.params.query["fields"]?
begin
@@ -282,7 +282,7 @@ def create_notification_stream(env, topics, connection_channel)
video = get_video(video_id, PG_DB)
video.published = Time.unix(published)
- response = JSON.parse(video.to_json(locale))
+ response = JSON.parse(video.to_json(locale, nil))
if fields_text = env.params.query["fields"]?
begin
diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr
index d483bca6..1edee29c 100644
--- a/src/invidious/routes/api/v1/videos.cr
+++ b/src/invidious/routes/api/v1/videos.cr
@@ -16,7 +16,7 @@ module Invidious::Routes::API::V1::Videos
return error_json(500, ex)
end
- video.to_json(locale)
+ video.to_json(locale, nil)
end
def self.captions(env)
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index d38a66d8..d3e5800c 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -275,7 +275,7 @@ struct Video
end
end
- def to_json(locale : Hash(String, JSON::Any), json : JSON::Builder)
+ def to_json(locale : Hash(String, JSON::Any) | Nil, json : JSON::Builder)
json.object do
json.field "type", "video"
@@ -474,14 +474,13 @@ struct Video
end
end
- def to_json(locale, json : JSON::Builder | Nil = nil)
- if json
- to_json(locale, json)
- else
- JSON.build do |json|
- to_json(locale, json)
- end
- end
+ # TODO: remove the locale and follow the crystal convention
+ def to_json(locale : Hash(String, JSON::Any) | Nil, _json : Nil)
+ JSON.build { |json| to_json(locale, json) }
+ end
+
+ def to_json(json : JSON::Builder | Nil = nil)
+ to_json(nil, json)
end
def title