mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Also fix 'to_json' in struct Video
This commit is contained in:
parent
1cb715ac9f
commit
33780f1995
3 changed files with 11 additions and 12 deletions
|
@ -206,7 +206,7 @@ def create_notification_stream(env, topics, connection_channel)
|
||||||
|
|
||||||
video = get_video(video_id, PG_DB)
|
video = get_video(video_id, PG_DB)
|
||||||
video.published = published
|
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"]?
|
if fields_text = env.params.query["fields"]?
|
||||||
begin
|
begin
|
||||||
|
@ -282,7 +282,7 @@ def create_notification_stream(env, topics, connection_channel)
|
||||||
|
|
||||||
video = get_video(video_id, PG_DB)
|
video = get_video(video_id, PG_DB)
|
||||||
video.published = Time.unix(published)
|
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"]?
|
if fields_text = env.params.query["fields"]?
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Invidious::Routes::API::V1::Videos
|
||||||
return error_json(500, ex)
|
return error_json(500, ex)
|
||||||
end
|
end
|
||||||
|
|
||||||
video.to_json(locale)
|
video.to_json(locale, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.captions(env)
|
def self.captions(env)
|
||||||
|
|
|
@ -275,7 +275,7 @@ struct Video
|
||||||
end
|
end
|
||||||
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.object do
|
||||||
json.field "type", "video"
|
json.field "type", "video"
|
||||||
|
|
||||||
|
@ -474,14 +474,13 @@ struct Video
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(locale, json : JSON::Builder | Nil = nil)
|
# TODO: remove the locale and follow the crystal convention
|
||||||
if json
|
def to_json(locale : Hash(String, JSON::Any) | Nil, _json : Nil)
|
||||||
to_json(locale, json)
|
JSON.build { |json| to_json(locale, json) }
|
||||||
else
|
|
||||||
JSON.build do |json|
|
|
||||||
to_json(locale, json)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_json(json : JSON::Builder | Nil = nil)
|
||||||
|
to_json(nil, json)
|
||||||
end
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
|
|
Loading…
Reference in a new issue