|
|
@ -58,17 +58,13 @@ struct SearchVideo
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def to_xml(auto_generated, query_params, xml : XML::Builder | Nil = nil)
|
|
|
|
def to_xml(auto_generated, query_params, _xml : Nil)
|
|
|
|
if xml
|
|
|
|
XML.build do |xml|
|
|
|
|
to_xml(HOST_URL, auto_generated, query_params, xml)
|
|
|
|
to_xml(auto_generated, query_params, xml)
|
|
|
|
else
|
|
|
|
|
|
|
|
XML.build do |xml|
|
|
|
|
|
|
|
|
to_xml(HOST_URL, auto_generated, query_params, xml)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
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"
|
|
|
|
json.field "title", self.title
|
|
|
|
json.field "title", self.title
|
|
|
@ -99,16 +95,17 @@ struct SearchVideo
|
|
|
|
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)
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
to_json(locale, json)
|
|
|
|
to_json(locale, json)
|
|
|
|
else
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
|
|
|
|
to_json(locale, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_json(json : JSON::Builder)
|
|
|
|
|
|
|
|
to_json(nil, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def is_upcoming
|
|
|
|
def is_upcoming
|
|
|
|
premiere_timestamp ? true : false
|
|
|
|
premiere_timestamp ? true : false
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -133,7 +130,7 @@ struct SearchPlaylist
|
|
|
|
property videos : Array(SearchPlaylistVideo)
|
|
|
|
property videos : Array(SearchPlaylistVideo)
|
|
|
|
property thumbnail : String?
|
|
|
|
property thumbnail : String?
|
|
|
|
|
|
|
|
|
|
|
|
def to_json(locale, json : JSON::Builder)
|
|
|
|
def to_json(locale : Hash(String, JSON::Any) | Nil, json : JSON::Builder)
|
|
|
|
json.object do
|
|
|
|
json.object do
|
|
|
|
json.field "type", "playlist"
|
|
|
|
json.field "type", "playlist"
|
|
|
|
json.field "title", self.title
|
|
|
|
json.field "title", self.title
|
|
|
@ -163,15 +160,16 @@ struct SearchPlaylist
|
|
|
|
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)
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
to_json(locale, json)
|
|
|
|
to_json(locale, json)
|
|
|
|
else
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
|
|
|
|
to_json(locale, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_json(json : JSON::Builder)
|
|
|
|
|
|
|
|
to_json(nil, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
struct SearchChannel
|
|
|
|
struct SearchChannel
|
|
|
@ -185,7 +183,7 @@ struct SearchChannel
|
|
|
|
property description_html : String
|
|
|
|
property description_html : String
|
|
|
|
property auto_generated : Bool
|
|
|
|
property auto_generated : Bool
|
|
|
|
|
|
|
|
|
|
|
|
def to_json(locale, json : JSON::Builder)
|
|
|
|
def to_json(locale : Hash(String, JSON::Any) | Nil, json : JSON::Builder)
|
|
|
|
json.object do
|
|
|
|
json.object do
|
|
|
|
json.field "type", "channel"
|
|
|
|
json.field "type", "channel"
|
|
|
|
json.field "author", self.author
|
|
|
|
json.field "author", self.author
|
|
|
@ -215,15 +213,16 @@ struct SearchChannel
|
|
|
|
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)
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
to_json(locale, json)
|
|
|
|
to_json(locale, json)
|
|
|
|
else
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
|
|
|
|
to_json(locale, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_json(json : JSON::Builder)
|
|
|
|
|
|
|
|
to_json(nil, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class Category
|
|
|
|
class Category
|
|
|
@ -235,7 +234,7 @@ class Category
|
|
|
|
property description_html : String
|
|
|
|
property description_html : String
|
|
|
|
property badges : Array(Tuple(String, String))?
|
|
|
|
property badges : Array(Tuple(String, String))?
|
|
|
|
|
|
|
|
|
|
|
|
def to_json(locale, json : JSON::Builder)
|
|
|
|
def to_json(locale : Hash(String, JSON::Any) | Nil, json : JSON::Builder)
|
|
|
|
json.object do
|
|
|
|
json.object do
|
|
|
|
json.field "type", "category"
|
|
|
|
json.field "type", "category"
|
|
|
|
json.field "title", self.title
|
|
|
|
json.field "title", self.title
|
|
|
@ -249,15 +248,16 @@ class Category
|
|
|
|
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)
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
to_json(locale, json)
|
|
|
|
to_json(locale, json)
|
|
|
|
else
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
|
|
|
|
to_json(locale, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_json(json : JSON::Builder)
|
|
|
|
|
|
|
|
to_json(nil, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
alias SearchItem = SearchVideo | SearchChannel | SearchPlaylist | Category
|
|
|
|
alias SearchItem = SearchVideo | SearchChannel | SearchPlaylist | Category
|
|
|
|