mirror of
https://github.com/iv-org/invidious.git
synced 2026-01-28 15:58:30 -06:00
Fix Lint/WhitespaceAroundMacroExpression type of Ameba issues
This commit is contained in:
parent
068151a664
commit
3d6f266827
@ -59,7 +59,7 @@ end
|
|||||||
|
|
||||||
# Get relative file path to a file within the static_assets_handler folder
|
# Get relative file path to a file within the static_assets_handler folder
|
||||||
macro get_file_path(basename)
|
macro get_file_path(basename)
|
||||||
"spec/http_server/handlers/static_assets_handler/#{ {{basename}} }"
|
"spec/http_server/handlers/static_assets_handler/#{ {{ basename }} }"
|
||||||
end
|
end
|
||||||
|
|
||||||
Spectator.describe StaticAssetsHandler do
|
Spectator.describe StaticAssetsHandler do
|
||||||
|
|||||||
@ -93,7 +93,7 @@ struct ChannelVideo
|
|||||||
def to_tuple
|
def to_tuple
|
||||||
{% begin %}
|
{% begin %}
|
||||||
{
|
{
|
||||||
{{@type.instance_vars.map(&.name).splat}}
|
{{ @type.instance_vars.map(&.name).splat }}
|
||||||
}
|
}
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|||||||
@ -58,7 +58,7 @@ struct ConfigPreferences
|
|||||||
def to_tuple
|
def to_tuple
|
||||||
{% begin %}
|
{% begin %}
|
||||||
{
|
{
|
||||||
{{(@type.instance_vars.map { |var| "#{var.name}: #{var.name}".id }).splat}}
|
{{ (@type.instance_vars.map { |var| "#{var.name}: #{var.name}".id }).splat }}
|
||||||
}
|
}
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
@ -212,14 +212,14 @@ class Config
|
|||||||
{% for ivar in Config.instance_vars %}
|
{% for ivar in Config.instance_vars %}
|
||||||
{% env_id = "INVIDIOUS_#{ivar.id.upcase}" %}
|
{% env_id = "INVIDIOUS_#{ivar.id.upcase}" %}
|
||||||
|
|
||||||
if ENV.has_key?({{env_id}})
|
if ENV.has_key?({{ env_id }})
|
||||||
env_value = ENV.fetch({{env_id}})
|
env_value = ENV.fetch({{ env_id }})
|
||||||
success = false
|
success = false
|
||||||
|
|
||||||
# Use YAML converter if specified
|
# Use YAML converter if specified
|
||||||
{% ann = ivar.annotation(::YAML::Field) %}
|
{% ann = ivar.annotation(::YAML::Field) %}
|
||||||
{% if ann && ann[:converter] %}
|
{% if ann && ann[:converter] %}
|
||||||
config.{{ivar.id}} = {{ann[:converter]}}.from_yaml(YAML::ParseContext.new, YAML::Nodes.parse(ENV.fetch({{env_id}})).nodes[0])
|
config.{{ ivar.id }} = {{ ann[:converter] }}.from_yaml(YAML::ParseContext.new, YAML::Nodes.parse(ENV.fetch({{ env_id }})).nodes[0])
|
||||||
success = true
|
success = true
|
||||||
|
|
||||||
# Use regular YAML parser otherwise
|
# Use regular YAML parser otherwise
|
||||||
@ -227,10 +227,10 @@ class Config
|
|||||||
{% ivar_types = ivar.type.union? ? ivar.type.union_types : [ivar.type] %}
|
{% ivar_types = ivar.type.union? ? ivar.type.union_types : [ivar.type] %}
|
||||||
# Sort types to avoid parsing nulls and numbers as strings
|
# Sort types to avoid parsing nulls and numbers as strings
|
||||||
{% ivar_types = ivar_types.sort_by { |ivar_type| ivar_type == Nil ? 0 : ivar_type == Int32 ? 1 : 2 } %}
|
{% ivar_types = ivar_types.sort_by { |ivar_type| ivar_type == Nil ? 0 : ivar_type == Int32 ? 1 : 2 } %}
|
||||||
{{ivar_types}}.each do |ivar_type|
|
{{ ivar_types }}.each do |ivar_type|
|
||||||
if !success
|
if !success
|
||||||
begin
|
begin
|
||||||
config.{{ivar.id}} = ivar_type.from_yaml(env_value)
|
config.{{ ivar.id }} = ivar_type.from_yaml(env_value)
|
||||||
success = true
|
success = true
|
||||||
rescue
|
rescue
|
||||||
# nop
|
# nop
|
||||||
@ -241,14 +241,14 @@ class Config
|
|||||||
|
|
||||||
# Exit on fail
|
# Exit on fail
|
||||||
if !success
|
if !success
|
||||||
puts %(Config.{{ivar.id}} failed to parse #{env_value} as {{ivar.type}})
|
puts %(Config.{{ ivar.id }} failed to parse #{env_value} as {{ ivar.type }})
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Warn when any config attribute is set to "CHANGE_ME!!"
|
# Warn when any config attribute is set to "CHANGE_ME!!"
|
||||||
if config.{{ivar.id}} == "CHANGE_ME!!"
|
if config.{{ ivar.id }} == "CHANGE_ME!!"
|
||||||
puts "Config: The value of '#{ {{ivar.stringify}} }' needs to be changed!!"
|
puts "Config: The value of '#{ {{ ivar.stringify }} }' needs to be changed!!"
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|||||||
@ -41,11 +41,11 @@ module Invidious::Frontend::SearchFilters
|
|||||||
str << "\t\t\t\t<div class=\"filter-column\"><fieldset>\n"
|
str << "\t\t\t\t<div class=\"filter-column\"><fieldset>\n"
|
||||||
|
|
||||||
str << "\t\t\t\t\t<legend><div class=\"filter-name underlined\">"
|
str << "\t\t\t\t\t<legend><div class=\"filter-name underlined\">"
|
||||||
str << translate(locale, "search_filters_{{name}}_label")
|
str << translate(locale, "search_filters_{{ name }}_label")
|
||||||
str << "</div></legend>\n"
|
str << "</div></legend>\n"
|
||||||
|
|
||||||
str << "\t\t\t\t\t<div class=\"filter-options\">\n"
|
str << "\t\t\t\t\t<div class=\"filter-options\">\n"
|
||||||
make_{{name}}_filter_options(str, filters.{{name}}, locale)
|
make_{{ name }}_filter_options(str, filters.{{ name }}, locale)
|
||||||
str << "\t\t\t\t\t</div>"
|
str << "\t\t\t\t\t</div>"
|
||||||
|
|
||||||
str << "\t\t\t\t</fieldset></div>\n"
|
str << "\t\t\t\t</fieldset></div>\n"
|
||||||
@ -57,12 +57,12 @@ module Invidious::Frontend::SearchFilters
|
|||||||
{% date = value.underscore %}
|
{% date = value.underscore %}
|
||||||
|
|
||||||
str << "\t\t\t\t\t\t<div>"
|
str << "\t\t\t\t\t\t<div>"
|
||||||
str << "<input type='radio' name='date' id='filter-date-{{date}}' value='{{date}}'"
|
str << "<input type='radio' name='date' id='filter-date-{{ date }}' value='{{ date }}'"
|
||||||
str << " checked" if value.{{date}}?
|
str << " checked" if value.{{ date }}?
|
||||||
str << '>'
|
str << '>'
|
||||||
|
|
||||||
str << "<label for='filter-date-{{date}}'>"
|
str << "<label for='filter-date-{{ date }}'>"
|
||||||
str << translate(locale, "search_filters_date_option_{{date}}")
|
str << translate(locale, "search_filters_date_option_{{ date }}")
|
||||||
str << "</label></div>\n"
|
str << "</label></div>\n"
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
@ -73,12 +73,12 @@ module Invidious::Frontend::SearchFilters
|
|||||||
{% type = value.underscore %}
|
{% type = value.underscore %}
|
||||||
|
|
||||||
str << "\t\t\t\t\t\t<div>"
|
str << "\t\t\t\t\t\t<div>"
|
||||||
str << "<input type='radio' name='type' id='filter-type-{{type}}' value='{{type}}'"
|
str << "<input type='radio' name='type' id='filter-type-{{ type }}' value='{{ type }}'"
|
||||||
str << " checked" if value.{{type}}?
|
str << " checked" if value.{{ type }}?
|
||||||
str << '>'
|
str << '>'
|
||||||
|
|
||||||
str << "<label for='filter-type-{{type}}'>"
|
str << "<label for='filter-type-{{ type }}'>"
|
||||||
str << translate(locale, "search_filters_type_option_{{type}}")
|
str << translate(locale, "search_filters_type_option_{{ type }}")
|
||||||
str << "</label></div>\n"
|
str << "</label></div>\n"
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
@ -89,12 +89,12 @@ module Invidious::Frontend::SearchFilters
|
|||||||
{% duration = value.underscore %}
|
{% duration = value.underscore %}
|
||||||
|
|
||||||
str << "\t\t\t\t\t\t<div>"
|
str << "\t\t\t\t\t\t<div>"
|
||||||
str << "<input type='radio' name='duration' id='filter-duration-{{duration}}' value='{{duration}}'"
|
str << "<input type='radio' name='duration' id='filter-duration-{{ duration }}' value='{{ duration }}'"
|
||||||
str << " checked" if value.{{duration}}?
|
str << " checked" if value.{{ duration }}?
|
||||||
str << '>'
|
str << '>'
|
||||||
|
|
||||||
str << "<label for='filter-duration-{{duration}}'>"
|
str << "<label for='filter-duration-{{ duration }}'>"
|
||||||
str << translate(locale, "search_filters_duration_option_{{duration}}")
|
str << translate(locale, "search_filters_duration_option_{{ duration }}")
|
||||||
str << "</label></div>\n"
|
str << "</label></div>\n"
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
@ -106,12 +106,12 @@ module Invidious::Frontend::SearchFilters
|
|||||||
{% feature = value.underscore %}
|
{% feature = value.underscore %}
|
||||||
|
|
||||||
str << "\t\t\t\t\t\t<div>"
|
str << "\t\t\t\t\t\t<div>"
|
||||||
str << "<input type='checkbox' name='features' id='filter-feature-{{feature}}' value='{{feature}}'"
|
str << "<input type='checkbox' name='features' id='filter-feature-{{ feature }}' value='{{ feature }}'"
|
||||||
str << " checked" if value.{{feature}}?
|
str << " checked" if value.{{ feature }}?
|
||||||
str << '>'
|
str << '>'
|
||||||
|
|
||||||
str << "<label for='filter-feature-{{feature}}'>"
|
str << "<label for='filter-feature-{{ feature }}'>"
|
||||||
str << translate(locale, "search_filters_features_option_{{feature}}")
|
str << translate(locale, "search_filters_features_option_{{ feature }}")
|
||||||
str << "</label></div>\n"
|
str << "</label></div>\n"
|
||||||
{% end %}
|
{% end %}
|
||||||
{% end %}
|
{% end %}
|
||||||
@ -123,12 +123,12 @@ module Invidious::Frontend::SearchFilters
|
|||||||
{% sort = value.underscore %}
|
{% sort = value.underscore %}
|
||||||
|
|
||||||
str << "\t\t\t\t\t\t<div>"
|
str << "\t\t\t\t\t\t<div>"
|
||||||
str << "<input type='radio' name='sort' id='filter-sort-{{sort}}' value='{{sort}}'"
|
str << "<input type='radio' name='sort' id='filter-sort-{{ sort }}' value='{{ sort }}'"
|
||||||
str << " checked" if value.{{sort}}?
|
str << " checked" if value.{{ sort }}?
|
||||||
str << '>'
|
str << '>'
|
||||||
|
|
||||||
str << "<label for='filter-sort-{{sort}}'>"
|
str << "<label for='filter-sort-{{ sort }}'>"
|
||||||
str << translate(locale, "search_filters_sort_option_{{sort}}")
|
str << translate(locale, "search_filters_sort_option_{{ sort }}")
|
||||||
str << "</label></div>\n"
|
str << "</label></div>\n"
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
macro error_template(*args)
|
macro error_template(*args)
|
||||||
error_template_helper(env, {{args.splat}})
|
error_template_helper(env, {{ args.splat }})
|
||||||
end
|
end
|
||||||
|
|
||||||
def github_details(summary : String, content : String)
|
def github_details(summary : String, content : String)
|
||||||
@ -106,7 +106,7 @@ end
|
|||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
macro error_atom(*args)
|
macro error_atom(*args)
|
||||||
error_atom_helper(env, {{args.splat}})
|
error_atom_helper(env, {{ args.splat }})
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_atom_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception)
|
def error_atom_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception)
|
||||||
@ -132,7 +132,7 @@ end
|
|||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
macro error_json(*args)
|
macro error_json(*args)
|
||||||
error_json_helper(env, {{args.splat}})
|
error_json_helper(env, {{ args.splat }})
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_json_helper(
|
def error_json_helper(
|
||||||
|
|||||||
@ -2,10 +2,10 @@ module HTTP::Handler
|
|||||||
@@exclude_routes_tree = Radix::Tree(String).new
|
@@exclude_routes_tree = Radix::Tree(String).new
|
||||||
|
|
||||||
macro exclude(paths, method = "GET")
|
macro exclude(paths, method = "GET")
|
||||||
class_name = {{@type.name}}
|
class_name = {{ @type.name }}
|
||||||
method_downcase = {{method.downcase}}
|
method_downcase = {{ method.downcase }}
|
||||||
class_name_method = "#{class_name}/#{method_downcase}"
|
class_name_method = "#{class_name}/#{method_downcase}"
|
||||||
({{paths}}).each do |path|
|
({{ paths }}).each do |path|
|
||||||
@@exclude_routes_tree.add class_name_method + path, '/' + method_downcase + path
|
@@exclude_routes_tree.add class_name_method + path, '/' + method_downcase + path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -21,7 +21,7 @@ end
|
|||||||
|
|
||||||
class Kemal::RouteHandler
|
class Kemal::RouteHandler
|
||||||
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
||||||
exclude ["/api/v1/*"], {{method}}
|
exclude ["/api/v1/*"], {{ method }}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
# Processes the route if it's a match. Otherwise renders 404.
|
# Processes the route if it's a match. Otherwise renders 404.
|
||||||
@ -45,7 +45,7 @@ end
|
|||||||
|
|
||||||
class Kemal::ExceptionHandler
|
class Kemal::ExceptionHandler
|
||||||
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
||||||
exclude ["/api/v1/*"], {{method}}
|
exclude ["/api/v1/*"], {{ method }}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
private def call_exception_with_status_code(context : HTTP::Server::Context, exception : Exception, status_code : Int32)
|
private def call_exception_with_status_code(context : HTTP::Server::Context, exception : Exception, status_code : Int32)
|
||||||
@ -73,7 +73,7 @@ end
|
|||||||
|
|
||||||
class AuthHandler < Kemal::Handler
|
class AuthHandler < Kemal::Handler
|
||||||
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
||||||
only ["/api/v1/auth/*"], {{method}}
|
only ["/api/v1/auth/*"], {{ method }}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
@ -122,7 +122,7 @@ end
|
|||||||
|
|
||||||
class APIHandler < Kemal::Handler
|
class APIHandler < Kemal::Handler
|
||||||
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
|
||||||
only ["/api/v1/*"], {{method}}
|
only ["/api/v1/*"], {{ method }}
|
||||||
{% end %}
|
{% end %}
|
||||||
exclude ["/api/v1/auth/notifications"], "GET"
|
exclude ["/api/v1/auth/notifications"], "GET"
|
||||||
exclude ["/api/v1/auth/notifications"], "POST"
|
exclude ["/api/v1/auth/notifications"], "POST"
|
||||||
|
|||||||
@ -56,9 +56,9 @@ class Invidious::LogHandler < Kemal::BaseLogHandler
|
|||||||
end
|
end
|
||||||
|
|
||||||
{% for level in %w(trace debug info warn error fatal) %}
|
{% for level in %w(trace debug info warn error fatal) %}
|
||||||
def {{level.id}}(message : String)
|
def {{ level.id }}(message : String)
|
||||||
if LogLevel::{{level.id.capitalize}} >= @level
|
if LogLevel::{{ level.id.capitalize }} >= @level
|
||||||
puts("#{Time.utc} [{{level.id}}] #{message}".colorize(color(LogLevel::{{level.id.capitalize}})))
|
puts("#{Time.utc} [{{ level.id }}] #{message}".colorize(color(LogLevel::{{ level.id.capitalize }})))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|||||||
@ -49,24 +49,24 @@ module JSON::Serializable
|
|||||||
end
|
end
|
||||||
|
|
||||||
macro templated(_filename, template = "template", navbar_search = true)
|
macro templated(_filename, template = "template", navbar_search = true)
|
||||||
navbar_search = {{navbar_search}}
|
navbar_search = {{ navbar_search }}
|
||||||
|
|
||||||
{{ filename = "src/invidious/views/" + _filename + ".ecr" }}
|
{{ filename = "src/invidious/views/" + _filename + ".ecr" }}
|
||||||
{{ layout = "src/invidious/views/" + template + ".ecr" }}
|
{{ layout = "src/invidious/views/" + template + ".ecr" }}
|
||||||
|
|
||||||
__content_filename__ = {{filename}}
|
__content_filename__ = {{ filename }}
|
||||||
render {{filename}}, {{layout}}
|
render {{ filename }}, {{ layout }}
|
||||||
end
|
end
|
||||||
|
|
||||||
macro rendered(filename)
|
macro rendered(filename)
|
||||||
render("src/invidious/views/#{{{filename}}}.ecr")
|
render("src/invidious/views/#{{{ filename }}}.ecr")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Similar to Kemals halt method but works in a
|
# Similar to Kemals halt method but works in a
|
||||||
# method.
|
# method.
|
||||||
macro haltf(env, status_code = 200, response = "")
|
macro haltf(env, status_code = 200, response = "")
|
||||||
{{env}}.response.status_code = {{status_code}}
|
{{ env }}.response.status_code = {{ status_code }}
|
||||||
{{env}}.response.print {{response}}
|
{{ env }}.response.print {{ response }}
|
||||||
{{env}}.response.close
|
{{ env }}.response.close
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@ -106,7 +106,7 @@ module Invidious::HttpServer
|
|||||||
# Can be removed once https://github.com/crystal-lang/crystal/issues/15817 is fixed.
|
# Can be removed once https://github.com/crystal-lang/crystal/issues/15817 is fixed.
|
||||||
private def serve_file_range(context : HTTP::Server::Context, file : IO, range_header : String, file_info)
|
private def serve_file_range(context : HTTP::Server::Context, file : IO, range_header : String, file_info)
|
||||||
# Paste in the body of inherited serve_file_range
|
# Paste in the body of inherited serve_file_range
|
||||||
{{@type.superclass.methods.select(&.name.==("serve_file_range"))[0].body}}
|
{{ @type.superclass.methods.select(&.name.==("serve_file_range"))[0].body }}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Clear cached files.
|
# Clear cached files.
|
||||||
|
|||||||
@ -3,12 +3,12 @@ module Invidious::Routing
|
|||||||
|
|
||||||
{% for http_method in {"get", "post", "delete", "options", "patch", "put"} %}
|
{% for http_method in {"get", "post", "delete", "options", "patch", "put"} %}
|
||||||
|
|
||||||
macro {{http_method.id}}(path, controller, method = :handle)
|
macro {{ http_method.id }}(path, controller, method = :handle)
|
||||||
unless Kemal::Utils.path_starts_with_slash?(\{{path}})
|
unless Kemal::Utils.path_starts_with_slash?(\{{path}})
|
||||||
raise Kemal::Exceptions::InvalidPathStartException.new({{http_method}}, \{{path}})
|
raise Kemal::Exceptions::InvalidPathStartException.new({{ http_method }}, \{{path}})
|
||||||
end
|
end
|
||||||
|
|
||||||
Kemal::RouteHandler::INSTANCE.add_route({{http_method.upcase}}, \{{path}}) do |env|
|
Kemal::RouteHandler::INSTANCE.add_route({{ http_method.upcase }}, \{{path}}) do |env|
|
||||||
\{{ controller }}.\{{ method.id }}(env)
|
\{{ controller }}.\{{ method.id }}(env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -238,91 +238,91 @@ module Invidious::Routing
|
|||||||
|
|
||||||
def register_api_v1_routes
|
def register_api_v1_routes
|
||||||
{% begin %}
|
{% begin %}
|
||||||
{{namespace = Routes::API::V1}}
|
{{ namespace = Routes::API::V1 }}
|
||||||
|
|
||||||
# Videos
|
# Videos
|
||||||
get "/api/v1/videos/:id", {{namespace}}::Videos, :videos
|
get "/api/v1/videos/:id", {{ namespace }}::Videos, :videos
|
||||||
get "/api/v1/storyboards/:id", {{namespace}}::Videos, :storyboards
|
get "/api/v1/storyboards/:id", {{ namespace }}::Videos, :storyboards
|
||||||
get "/api/v1/captions/:id", {{namespace}}::Videos, :captions
|
get "/api/v1/captions/:id", {{ namespace }}::Videos, :captions
|
||||||
get "/api/v1/annotations/:id", {{namespace}}::Videos, :annotations
|
get "/api/v1/annotations/:id", {{ namespace }}::Videos, :annotations
|
||||||
get "/api/v1/comments/:id", {{namespace}}::Videos, :comments
|
get "/api/v1/comments/:id", {{ namespace }}::Videos, :comments
|
||||||
get "/api/v1/clips/:id", {{namespace}}::Videos, :clips
|
get "/api/v1/clips/:id", {{ namespace }}::Videos, :clips
|
||||||
get "/api/v1/transcripts/:id", {{namespace}}::Videos, :transcripts
|
get "/api/v1/transcripts/:id", {{ namespace }}::Videos, :transcripts
|
||||||
|
|
||||||
# Feeds
|
# Feeds
|
||||||
get "/api/v1/trending", {{namespace}}::Feeds, :trending
|
get "/api/v1/trending", {{ namespace }}::Feeds, :trending
|
||||||
get "/api/v1/popular", {{namespace}}::Feeds, :popular
|
get "/api/v1/popular", {{ namespace }}::Feeds, :popular
|
||||||
|
|
||||||
# Channels
|
# Channels
|
||||||
get "/api/v1/channels/:ucid", {{namespace}}::Channels, :home
|
get "/api/v1/channels/:ucid", {{ namespace }}::Channels, :home
|
||||||
get "/api/v1/channels/:ucid/latest", {{namespace}}::Channels, :latest
|
get "/api/v1/channels/:ucid/latest", {{ namespace }}::Channels, :latest
|
||||||
get "/api/v1/channels/:ucid/videos", {{namespace}}::Channels, :videos
|
get "/api/v1/channels/:ucid/videos", {{ namespace }}::Channels, :videos
|
||||||
get "/api/v1/channels/:ucid/shorts", {{namespace}}::Channels, :shorts
|
get "/api/v1/channels/:ucid/shorts", {{ namespace }}::Channels, :shorts
|
||||||
get "/api/v1/channels/:ucid/streams", {{namespace}}::Channels, :streams
|
get "/api/v1/channels/:ucid/streams", {{ namespace }}::Channels, :streams
|
||||||
get "/api/v1/channels/:ucid/podcasts", {{namespace}}::Channels, :podcasts
|
get "/api/v1/channels/:ucid/podcasts", {{ namespace }}::Channels, :podcasts
|
||||||
get "/api/v1/channels/:ucid/releases", {{namespace}}::Channels, :releases
|
get "/api/v1/channels/:ucid/releases", {{ namespace }}::Channels, :releases
|
||||||
get "/api/v1/channels/:ucid/courses", {{namespace}}::Channels, :courses
|
get "/api/v1/channels/:ucid/courses", {{ namespace }}::Channels, :courses
|
||||||
get "/api/v1/channels/:ucid/playlists", {{namespace}}::Channels, :playlists
|
get "/api/v1/channels/:ucid/playlists", {{ namespace }}::Channels, :playlists
|
||||||
get "/api/v1/channels/:ucid/community", {{namespace}}::Channels, :community
|
get "/api/v1/channels/:ucid/community", {{ namespace }}::Channels, :community
|
||||||
get "/api/v1/channels/:ucid/posts", {{namespace}}::Channels, :community
|
get "/api/v1/channels/:ucid/posts", {{ namespace }}::Channels, :community
|
||||||
get "/api/v1/channels/:ucid/channels", {{namespace}}::Channels, :channels
|
get "/api/v1/channels/:ucid/channels", {{ namespace }}::Channels, :channels
|
||||||
get "/api/v1/channels/:ucid/search", {{namespace}}::Channels, :search
|
get "/api/v1/channels/:ucid/search", {{ namespace }}::Channels, :search
|
||||||
|
|
||||||
# Posts
|
# Posts
|
||||||
get "/api/v1/post/:id", {{namespace}}::Channels, :post
|
get "/api/v1/post/:id", {{ namespace }}::Channels, :post
|
||||||
get "/api/v1/post/:id/comments", {{namespace}}::Channels, :post_comments
|
get "/api/v1/post/:id/comments", {{ namespace }}::Channels, :post_comments
|
||||||
|
|
||||||
# 301 redirects to new /api/v1/channels/community/:ucid and /:ucid/community
|
# 301 redirects to new /api/v1/channels/community/:ucid and /:ucid/community
|
||||||
get "/api/v1/channels/comments/:ucid", {{namespace}}::Channels, :channel_comments_redirect
|
get "/api/v1/channels/comments/:ucid", {{ namespace }}::Channels, :channel_comments_redirect
|
||||||
get "/api/v1/channels/:ucid/comments", {{namespace}}::Channels, :channel_comments_redirect
|
get "/api/v1/channels/:ucid/comments", {{ namespace }}::Channels, :channel_comments_redirect
|
||||||
|
|
||||||
# Search
|
# Search
|
||||||
get "/api/v1/search", {{namespace}}::Search, :search
|
get "/api/v1/search", {{ namespace }}::Search, :search
|
||||||
get "/api/v1/search/suggestions", {{namespace}}::Search, :search_suggestions
|
get "/api/v1/search/suggestions", {{ namespace }}::Search, :search_suggestions
|
||||||
get "/api/v1/hashtag/:hashtag", {{namespace}}::Search, :hashtag
|
get "/api/v1/hashtag/:hashtag", {{ namespace }}::Search, :hashtag
|
||||||
|
|
||||||
|
|
||||||
# Authenticated
|
# Authenticated
|
||||||
|
|
||||||
get "/api/v1/auth/preferences", {{namespace}}::Authenticated, :get_preferences
|
get "/api/v1/auth/preferences", {{ namespace }}::Authenticated, :get_preferences
|
||||||
post "/api/v1/auth/preferences", {{namespace}}::Authenticated, :set_preferences
|
post "/api/v1/auth/preferences", {{ namespace }}::Authenticated, :set_preferences
|
||||||
|
|
||||||
get "/api/v1/auth/export/invidious", {{namespace}}::Authenticated, :export_invidious
|
get "/api/v1/auth/export/invidious", {{ namespace }}::Authenticated, :export_invidious
|
||||||
post "/api/v1/auth/import/invidious", {{namespace}}::Authenticated, :import_invidious
|
post "/api/v1/auth/import/invidious", {{ namespace }}::Authenticated, :import_invidious
|
||||||
|
|
||||||
get "/api/v1/auth/history", {{namespace}}::Authenticated, :get_history
|
get "/api/v1/auth/history", {{ namespace }}::Authenticated, :get_history
|
||||||
post "/api/v1/auth/history/:id", {{namespace}}::Authenticated, :mark_watched
|
post "/api/v1/auth/history/:id", {{ namespace }}::Authenticated, :mark_watched
|
||||||
delete "/api/v1/auth/history/:id", {{namespace}}::Authenticated, :mark_unwatched
|
delete "/api/v1/auth/history/:id", {{ namespace }}::Authenticated, :mark_unwatched
|
||||||
delete "/api/v1/auth/history", {{namespace}}::Authenticated, :clear_history
|
delete "/api/v1/auth/history", {{ namespace }}::Authenticated, :clear_history
|
||||||
|
|
||||||
get "/api/v1/auth/feed", {{namespace}}::Authenticated, :feed
|
get "/api/v1/auth/feed", {{ namespace }}::Authenticated, :feed
|
||||||
|
|
||||||
get "/api/v1/auth/subscriptions", {{namespace}}::Authenticated, :get_subscriptions
|
get "/api/v1/auth/subscriptions", {{ namespace }}::Authenticated, :get_subscriptions
|
||||||
post "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :subscribe_channel
|
post "/api/v1/auth/subscriptions/:ucid", {{ namespace }}::Authenticated, :subscribe_channel
|
||||||
delete "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :unsubscribe_channel
|
delete "/api/v1/auth/subscriptions/:ucid", {{ namespace }}::Authenticated, :unsubscribe_channel
|
||||||
|
|
||||||
get "/api/v1/auth/playlists", {{namespace}}::Authenticated, :list_playlists
|
get "/api/v1/auth/playlists", {{ namespace }}::Authenticated, :list_playlists
|
||||||
post "/api/v1/auth/playlists", {{namespace}}::Authenticated, :create_playlist
|
post "/api/v1/auth/playlists", {{ namespace }}::Authenticated, :create_playlist
|
||||||
patch "/api/v1/auth/playlists/:plid",{{namespace}}:: Authenticated, :update_playlist_attribute
|
patch "/api/v1/auth/playlists/:plid",{{ namespace }}:: Authenticated, :update_playlist_attribute
|
||||||
delete "/api/v1/auth/playlists/:plid", {{namespace}}::Authenticated, :delete_playlist
|
delete "/api/v1/auth/playlists/:plid", {{ namespace }}::Authenticated, :delete_playlist
|
||||||
post "/api/v1/auth/playlists/:plid/videos", {{namespace}}::Authenticated, :insert_video_into_playlist
|
post "/api/v1/auth/playlists/:plid/videos", {{ namespace }}::Authenticated, :insert_video_into_playlist
|
||||||
delete "/api/v1/auth/playlists/:plid/videos/:index", {{namespace}}::Authenticated, :delete_video_in_playlist
|
delete "/api/v1/auth/playlists/:plid/videos/:index", {{ namespace }}::Authenticated, :delete_video_in_playlist
|
||||||
|
|
||||||
get "/api/v1/auth/tokens", {{namespace}}::Authenticated, :get_tokens
|
get "/api/v1/auth/tokens", {{ namespace }}::Authenticated, :get_tokens
|
||||||
post "/api/v1/auth/tokens/register", {{namespace}}::Authenticated, :register_token
|
post "/api/v1/auth/tokens/register", {{ namespace }}::Authenticated, :register_token
|
||||||
post "/api/v1/auth/tokens/unregister", {{namespace}}::Authenticated, :unregister_token
|
post "/api/v1/auth/tokens/unregister", {{ namespace }}::Authenticated, :unregister_token
|
||||||
|
|
||||||
if CONFIG.enable_user_notifications
|
if CONFIG.enable_user_notifications
|
||||||
get "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications
|
get "/api/v1/auth/notifications", {{ namespace }}::Authenticated, :notifications
|
||||||
post "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications
|
post "/api/v1/auth/notifications", {{ namespace }}::Authenticated, :notifications
|
||||||
end
|
end
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
get "/api/v1/stats", {{namespace}}::Misc, :stats
|
get "/api/v1/stats", {{ namespace }}::Misc, :stats
|
||||||
get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist
|
get "/api/v1/playlists/:plid", {{ namespace }}::Misc, :get_playlist
|
||||||
get "/api/v1/auth/playlists/:plid", {{namespace}}::Misc, :get_playlist
|
get "/api/v1/auth/playlists/:plid", {{ namespace }}::Misc, :get_playlist
|
||||||
get "/api/v1/mixes/:rdid", {{namespace}}::Misc, :mixes
|
get "/api/v1/mixes/:rdid", {{ namespace }}::Misc, :mixes
|
||||||
get "/api/v1/resolveurl", {{namespace}}::Misc, :resolve_url
|
get "/api/v1/resolveurl", {{ namespace }}::Misc, :resolve_url
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -195,37 +195,37 @@ struct Video
|
|||||||
# Macros defining getters/setters for various types of data
|
# Macros defining getters/setters for various types of data
|
||||||
|
|
||||||
private macro getset_string(name)
|
private macro getset_string(name)
|
||||||
# Return {{name.stringify}} from `info`
|
# Return {{ name.stringify }} from `info`
|
||||||
def {{name.id.underscore}} : String
|
def {{ name.id.underscore }} : String
|
||||||
return info[{{name.stringify}}]?.try &.as_s || ""
|
return info[{{ name.stringify }}]?.try &.as_s || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update {{name.stringify}} into `info`
|
# Update {{ name.stringify }} into `info`
|
||||||
def {{name.id.underscore}}=(value : String)
|
def {{ name.id.underscore }}=(value : String)
|
||||||
info[{{name.stringify}}] = JSON::Any.new(value)
|
info[{{ name.stringify }}] = JSON::Any.new(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
{% if flag?(:debug_macros) %} {{debug}} {% end %}
|
{% if flag?(:debug_macros) %} {{ debug }} {% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
private macro getset_string_array(name)
|
private macro getset_string_array(name)
|
||||||
# Return {{name.stringify}} from `info`
|
# Return {{ name.stringify }} from `info`
|
||||||
def {{name.id.underscore}} : Array(String)
|
def {{ name.id.underscore }} : Array(String)
|
||||||
return info[{{name.stringify}}]?.try &.as_a.map &.as_s || [] of String
|
return info[{{ name.stringify }}]?.try &.as_a.map &.as_s || [] of String
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update {{name.stringify}} into `info`
|
# Update {{ name.stringify }} into `info`
|
||||||
def {{name.id.underscore}}=(value : Array(String))
|
def {{ name.id.underscore }}=(value : Array(String))
|
||||||
info[{{name.stringify}}] = JSON::Any.new(value)
|
info[{{ name.stringify }}] = JSON::Any.new(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
{% if flag?(:debug_macros) %} {{debug}} {% end %}
|
{% if flag?(:debug_macros) %} {{ debug }} {% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
{% for op, type in {i32: Int32, i64: Int64} %}
|
{% for op, type in {i32: Int32, i64: Int64} %}
|
||||||
private macro getset_{{op}}(name)
|
private macro getset_{{ op }}(name)
|
||||||
def \{{name.id.underscore}} : {{type}}
|
def \{{name.id.underscore}} : {{ type }}
|
||||||
return info[\{{name.stringify}}]?.try &.as_i64.to_{{op}} || 0_{{op}}
|
return info[\{{name.stringify}}]?.try &.as_i64.to_{{ op }} || 0_{{ op }}
|
||||||
end
|
end
|
||||||
|
|
||||||
def \{{name.id.underscore}}=(value : Int)
|
def \{{name.id.underscore}}=(value : Int)
|
||||||
@ -237,32 +237,32 @@ struct Video
|
|||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
private macro getset_bool(name)
|
private macro getset_bool(name)
|
||||||
# Return {{name.stringify}} from `info`
|
# Return {{ name.stringify }} from `info`
|
||||||
def {{name.id.underscore}} : Bool
|
def {{ name.id.underscore }} : Bool
|
||||||
return info[{{name.stringify}}]?.try &.as_bool || false
|
return info[{{ name.stringify }}]?.try &.as_bool || false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update {{name.stringify}} into `info`
|
# Update {{ name.stringify }} into `info`
|
||||||
def {{name.id.underscore}}=(value : Bool)
|
def {{ name.id.underscore }}=(value : Bool)
|
||||||
info[{{name.stringify}}] = JSON::Any.new(value)
|
info[{{ name.stringify }}] = JSON::Any.new(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
{% if flag?(:debug_macros) %} {{debug}} {% end %}
|
{% if flag?(:debug_macros) %} {{ debug }} {% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Macro to generate ? and = accessor methods for attributes in `info`
|
# Macro to generate ? and = accessor methods for attributes in `info`
|
||||||
private macro predicate_bool(method_name, name)
|
private macro predicate_bool(method_name, name)
|
||||||
# Return {{name.stringify}} from `info`
|
# Return {{ name.stringify }} from `info`
|
||||||
def {{method_name.id.underscore}}? : Bool
|
def {{ method_name.id.underscore }}? : Bool
|
||||||
return info[{{name.stringify}}]?.try &.as_bool || false
|
return info[{{ name.stringify }}]?.try &.as_bool || false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update {{name.stringify}} into `info`
|
# Update {{ name.stringify }} into `info`
|
||||||
def {{method_name.id.underscore}}=(value : Bool)
|
def {{ method_name.id.underscore }}=(value : Bool)
|
||||||
info[{{name.stringify}}] = JSON::Any.new(value)
|
info[{{ name.stringify }}] = JSON::Any.new(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
{% if flag?(:debug_macros) %} {{debug}} {% end %}
|
{% if flag?(:debug_macros) %} {{ debug }} {% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Method definitions, using the macros above
|
# Method definitions, using the macros above
|
||||||
|
|||||||
@ -40,8 +40,8 @@ private module Parsers
|
|||||||
begin
|
begin
|
||||||
return parse_internal(*args)
|
return parse_internal(*args)
|
||||||
rescue ex
|
rescue ex
|
||||||
LOGGER.debug("#{{{@type.name}}}: Failed to render item.")
|
LOGGER.debug("#{{{ @type.name }}}: Failed to render item.")
|
||||||
LOGGER.debug("#{{{@type.name}}}: Got exception: #{ex.message}")
|
LOGGER.debug("#{{{ @type.name }}}: Got exception: #{ex.message}")
|
||||||
ProblematicTimelineItem.new(
|
ProblematicTimelineItem.new(
|
||||||
parse_exception: ex
|
parse_exception: ex
|
||||||
)
|
)
|
||||||
@ -173,7 +173,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -626,7 +626,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -704,7 +704,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -762,7 +762,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -791,7 +791,7 @@ private module Parsers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.parser_name
|
def self.parser_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -878,7 +878,7 @@ private module Extractors
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.extractor_name
|
def self.extractor_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -919,7 +919,7 @@ private module Extractors
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.extractor_name
|
def self.extractor_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -953,7 +953,7 @@ private module Extractors
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.extractor_name
|
def self.extractor_name
|
||||||
return {{@type.name}}
|
return {{ @type.name }}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user