mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-10 01:01:57 +01:00
Ameba: Fix Naming/PredicateName
This commit is contained in:
parent
22b35c453e
commit
f66068976e
5 changed files with 24 additions and 8 deletions
|
@ -90,7 +90,7 @@ struct SearchVideo
|
||||||
json.field "lengthSeconds", self.length_seconds
|
json.field "lengthSeconds", self.length_seconds
|
||||||
json.field "liveNow", self.live_now
|
json.field "liveNow", self.live_now
|
||||||
json.field "premium", self.premium
|
json.field "premium", self.premium
|
||||||
json.field "isUpcoming", self.is_upcoming
|
json.field "isUpcoming", self.upcoming?
|
||||||
|
|
||||||
if self.premiere_timestamp
|
if self.premiere_timestamp
|
||||||
json.field "premiereTimestamp", self.premiere_timestamp.try &.to_unix
|
json.field "premiereTimestamp", self.premiere_timestamp.try &.to_unix
|
||||||
|
@ -109,7 +109,7 @@ struct SearchVideo
|
||||||
to_json(nil, json)
|
to_json(nil, json)
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_upcoming
|
def upcoming?
|
||||||
premiere_timestamp ? true : false
|
premiere_timestamp ? true : false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,7 +63,7 @@ module Invidious::JSONify::APIv1
|
||||||
json.field "isListed", video.is_listed
|
json.field "isListed", video.is_listed
|
||||||
json.field "liveNow", video.live_now
|
json.field "liveNow", video.live_now
|
||||||
json.field "isPostLiveDvr", video.post_live_dvr
|
json.field "isPostLiveDvr", video.post_live_dvr
|
||||||
json.field "isUpcoming", video.is_upcoming
|
json.field "isUpcoming", video.upcoming?
|
||||||
|
|
||||||
if video.premiere_timestamp
|
if video.premiere_timestamp
|
||||||
json.field "premiereTimestamp", video.premiere_timestamp.try &.to_unix
|
json.field "premiereTimestamp", video.premiere_timestamp.try &.to_unix
|
||||||
|
|
|
@ -161,7 +161,7 @@ struct Invidious::User
|
||||||
# Youtube
|
# Youtube
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
private def is_opml?(mimetype : String, extension : String)
|
private def opml?(mimetype : String, extension : String)
|
||||||
opml_mimetypes = [
|
opml_mimetypes = [
|
||||||
"application/xml",
|
"application/xml",
|
||||||
"text/xml",
|
"text/xml",
|
||||||
|
@ -179,7 +179,7 @@ struct Invidious::User
|
||||||
def from_youtube(user : User, body : String, filename : String, type : String) : Bool
|
def from_youtube(user : User, body : String, filename : String, type : String) : Bool
|
||||||
extension = filename.split(".").last
|
extension = filename.split(".").last
|
||||||
|
|
||||||
if is_opml?(type, extension)
|
if opml?(type, extension)
|
||||||
subscriptions = XML.parse(body)
|
subscriptions = XML.parse(body)
|
||||||
user.subscriptions += subscriptions.xpath_nodes(%q(//outline[@type="rss"])).map do |channel|
|
user.subscriptions += subscriptions.xpath_nodes(%q(//outline[@type="rss"])).map do |channel|
|
||||||
channel["xmlUrl"].match!(/UC[a-zA-Z0-9_-]{22}/)[0]
|
channel["xmlUrl"].match!(/UC[a-zA-Z0-9_-]{22}/)[0]
|
||||||
|
|
|
@ -280,7 +280,7 @@ struct Video
|
||||||
info["genreUcid"].try &.as_s? ? "/channel/#{info["genreUcid"]}" : nil
|
info["genreUcid"].try &.as_s? ? "/channel/#{info["genreUcid"]}" : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_vr : Bool?
|
def vr? : Bool?
|
||||||
return {"EQUIRECTANGULAR", "MESH"}.includes? self.projection_type
|
return {"EQUIRECTANGULAR", "MESH"}.includes? self.projection_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -361,6 +361,21 @@ struct Video
|
||||||
{% if flag?(:debug_macros) %} {{debug}} {% end %}
|
{% if flag?(:debug_macros) %} {{debug}} {% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Macro to generate ? and = accessor methods for attributes in `info`
|
||||||
|
private macro predicate_bool(method_name, name)
|
||||||
|
# Return {{name.stringify}} from `info`
|
||||||
|
def {{method_name.id.underscore}}? : Bool
|
||||||
|
return info[{{name.stringify}}]?.try &.as_bool || false
|
||||||
|
end
|
||||||
|
|
||||||
|
# Update {{name.stringify}} into `info`
|
||||||
|
def {{method_name.id.underscore}}=(value : Bool)
|
||||||
|
info[{{name.stringify}}] = JSON::Any.new(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
{% if flag?(:debug_macros) %} {{debug}} {% end %}
|
||||||
|
end
|
||||||
|
|
||||||
# Method definitions, using the macros above
|
# Method definitions, using the macros above
|
||||||
|
|
||||||
getset_string author
|
getset_string author
|
||||||
|
@ -382,11 +397,12 @@ struct Video
|
||||||
getset_i64 likes
|
getset_i64 likes
|
||||||
getset_i64 views
|
getset_i64 views
|
||||||
|
|
||||||
|
# TODO: Make predicate_bool the default as to adhere to Crystal conventions
|
||||||
getset_bool allowRatings
|
getset_bool allowRatings
|
||||||
getset_bool authorVerified
|
getset_bool authorVerified
|
||||||
getset_bool isFamilyFriendly
|
getset_bool isFamilyFriendly
|
||||||
getset_bool isListed
|
getset_bool isListed
|
||||||
getset_bool isUpcoming
|
predicate_bool upcoming, isUpcoming
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_video(id, refresh = true, region = nil, force_refresh = false)
|
def get_video(id, refresh = true, region = nil, force_refresh = false)
|
||||||
|
|
|
@ -62,7 +62,7 @@ we're going to need to do it here in order to allow for translations.
|
||||||
"params" => params,
|
"params" => params,
|
||||||
"preferences" => preferences,
|
"preferences" => preferences,
|
||||||
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
|
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
|
||||||
"vr" => video.is_vr,
|
"vr" => video.vr?,
|
||||||
"projection_type" => video.projection_type,
|
"projection_type" => video.projection_type,
|
||||||
"local_disabled" => CONFIG.disabled?("local"),
|
"local_disabled" => CONFIG.disabled?("local"),
|
||||||
"support_reddit" => true
|
"support_reddit" => true
|
||||||
|
|
Loading…
Reference in a new issue