diff --git a/spec/http_server/handlers/static_assets_handler_spec.cr b/spec/http_server/handlers/static_assets_handler_spec.cr
index 76dc7be77..268c4b2f4 100644
--- a/spec/http_server/handlers/static_assets_handler_spec.cr
+++ b/spec/http_server/handlers/static_assets_handler_spec.cr
@@ -59,7 +59,7 @@ end
# Get relative file path to a file within the static_assets_handler folder
macro get_file_path(basename)
- "spec/http_server/handlers/static_assets_handler/#{ {{basename}} }"
+ "spec/http_server/handlers/static_assets_handler/#{ {{ basename }} }"
end
Spectator.describe StaticAssetsHandler do
diff --git a/src/invidious/channels/channels.cr b/src/invidious/channels/channels.cr
index 659823255..65a1aab72 100644
--- a/src/invidious/channels/channels.cr
+++ b/src/invidious/channels/channels.cr
@@ -93,7 +93,7 @@ struct ChannelVideo
def to_tuple
{% begin %}
{
- {{@type.instance_vars.map(&.name).splat}}
+ {{ @type.instance_vars.map(&.name).splat }}
}
{% end %}
end
diff --git a/src/invidious/config.cr b/src/invidious/config.cr
index 7853d9a3b..d24939923 100644
--- a/src/invidious/config.cr
+++ b/src/invidious/config.cr
@@ -58,7 +58,7 @@ struct ConfigPreferences
def to_tuple
{% 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
@@ -212,14 +212,14 @@ class Config
{% for ivar in Config.instance_vars %}
{% env_id = "INVIDIOUS_#{ivar.id.upcase}" %}
- if ENV.has_key?({{env_id}})
- env_value = ENV.fetch({{env_id}})
+ if ENV.has_key?({{ env_id }})
+ env_value = ENV.fetch({{ env_id }})
success = false
# Use YAML converter if specified
{% ann = ivar.annotation(::YAML::Field) %}
{% 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
# Use regular YAML parser otherwise
@@ -227,10 +227,10 @@ class Config
{% ivar_types = ivar.type.union? ? ivar.type.union_types : [ivar.type] %}
# 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}}.each do |ivar_type|
+ {{ ivar_types }}.each do |ivar_type|
if !success
begin
- config.{{ivar.id}} = ivar_type.from_yaml(env_value)
+ config.{{ ivar.id }} = ivar_type.from_yaml(env_value)
success = true
rescue
# nop
@@ -241,14 +241,14 @@ class Config
# Exit on fail
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)
end
end
# Warn when any config attribute is set to "CHANGE_ME!!"
- if config.{{ivar.id}} == "CHANGE_ME!!"
- puts "Config: The value of '#{ {{ivar.stringify}} }' needs to be changed!!"
+ if config.{{ ivar.id }} == "CHANGE_ME!!"
+ puts "Config: The value of '#{ {{ ivar.stringify }} }' needs to be changed!!"
exit(1)
end
{% end %}
diff --git a/src/invidious/frontend/search_filters.cr b/src/invidious/frontend/search_filters.cr
index 8ac0af2e9..2ad6c6395 100644
--- a/src/invidious/frontend/search_filters.cr
+++ b/src/invidious/frontend/search_filters.cr
@@ -41,11 +41,11 @@ module Invidious::Frontend::SearchFilters
str << "\t\t\t\t
\n"
@@ -57,12 +57,12 @@ module Invidious::Frontend::SearchFilters
{% date = value.underscore %}
str << "\t\t\t\t\t\t"
- str << "'
- str << "
\n"
{% end %}
end
@@ -73,12 +73,12 @@ module Invidious::Frontend::SearchFilters
{% type = value.underscore %}
str << "\t\t\t\t\t\t"
- str << "'
- str << ""
- str << translate(locale, "search_filters_type_option_{{type}}")
+ str << ""
+ str << translate(locale, "search_filters_type_option_{{ type }}")
str << "
\n"
{% end %}
end
@@ -89,12 +89,12 @@ module Invidious::Frontend::SearchFilters
{% duration = value.underscore %}
str << "\t\t\t\t\t\t"
- str << "'
- str << ""
- str << translate(locale, "search_filters_duration_option_{{duration}}")
+ str << ""
+ str << translate(locale, "search_filters_duration_option_{{ duration }}")
str << "
\n"
{% end %}
end
@@ -106,12 +106,12 @@ module Invidious::Frontend::SearchFilters
{% feature = value.underscore %}
str << "\t\t\t\t\t\t"
- str << "'
- str << ""
- str << translate(locale, "search_filters_features_option_{{feature}}")
+ str << ""
+ str << translate(locale, "search_filters_features_option_{{ feature }}")
str << "
\n"
{% end %}
{% end %}
@@ -123,12 +123,12 @@ module Invidious::Frontend::SearchFilters
{% sort = value.underscore %}
str << "\t\t\t\t\t\t"
- str << "'
- str << ""
- str << translate(locale, "search_filters_sort_option_{{sort}}")
+ str << ""
+ str << translate(locale, "search_filters_sort_option_{{ sort }}")
str << "
\n"
{% end %}
end
diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr
index e2c4b650a..fa198031e 100644
--- a/src/invidious/helpers/errors.cr
+++ b/src/invidious/helpers/errors.cr
@@ -3,7 +3,7 @@
# -------------------
macro error_template(*args)
- error_template_helper(env, {{args.splat}})
+ error_template_helper(env, {{ args.splat }})
end
def github_details(summary : String, content : String)
@@ -106,7 +106,7 @@ end
# -------------------
macro error_atom(*args)
- error_atom_helper(env, {{args.splat}})
+ error_atom_helper(env, {{ args.splat }})
end
def error_atom_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception)
@@ -132,7 +132,7 @@ end
# -------------------
macro error_json(*args)
- error_json_helper(env, {{args.splat}})
+ error_json_helper(env, {{ args.splat }})
end
def error_json_helper(
diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.cr
index 7c5ef1185..ca0556568 100644
--- a/src/invidious/helpers/handlers.cr
+++ b/src/invidious/helpers/handlers.cr
@@ -2,10 +2,10 @@ module HTTP::Handler
@@exclude_routes_tree = Radix::Tree(String).new
macro exclude(paths, method = "GET")
- class_name = {{@type.name}}
- method_downcase = {{method.downcase}}
+ class_name = {{ @type.name }}
+ method_downcase = {{ 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
end
end
@@ -21,7 +21,7 @@ end
class Kemal::RouteHandler
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
- exclude ["/api/v1/*"], {{method}}
+ exclude ["/api/v1/*"], {{ method }}
{% end %}
# Processes the route if it's a match. Otherwise renders 404.
@@ -45,7 +45,7 @@ end
class Kemal::ExceptionHandler
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
- exclude ["/api/v1/*"], {{method}}
+ exclude ["/api/v1/*"], {{ method }}
{% end %}
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
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
- only ["/api/v1/auth/*"], {{method}}
+ only ["/api/v1/auth/*"], {{ method }}
{% end %}
def call(env)
@@ -122,7 +122,7 @@ end
class APIHandler < Kemal::Handler
{% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}
- only ["/api/v1/*"], {{method}}
+ only ["/api/v1/*"], {{ method }}
{% end %}
exclude ["/api/v1/auth/notifications"], "GET"
exclude ["/api/v1/auth/notifications"], "POST"
diff --git a/src/invidious/helpers/logger.cr b/src/invidious/helpers/logger.cr
index 033495955..bce10bb3e 100644
--- a/src/invidious/helpers/logger.cr
+++ b/src/invidious/helpers/logger.cr
@@ -56,9 +56,9 @@ class Invidious::LogHandler < Kemal::BaseLogHandler
end
{% for level in %w(trace debug info warn error fatal) %}
- def {{level.id}}(message : String)
- if LogLevel::{{level.id.capitalize}} >= @level
- puts("#{Time.utc} [{{level.id}}] #{message}".colorize(color(LogLevel::{{level.id.capitalize}})))
+ def {{ level.id }}(message : String)
+ if LogLevel::{{ level.id.capitalize }} >= @level
+ puts("#{Time.utc} [{{ level.id }}] #{message}".colorize(color(LogLevel::{{ level.id.capitalize }})))
end
end
{% end %}
diff --git a/src/invidious/helpers/macros.cr b/src/invidious/helpers/macros.cr
index 848473218..4e2f4bb24 100644
--- a/src/invidious/helpers/macros.cr
+++ b/src/invidious/helpers/macros.cr
@@ -49,24 +49,24 @@ module JSON::Serializable
end
macro templated(_filename, template = "template", navbar_search = true)
- navbar_search = {{navbar_search}}
+ navbar_search = {{ navbar_search }}
{{ filename = "src/invidious/views/" + _filename + ".ecr" }}
{{ layout = "src/invidious/views/" + template + ".ecr" }}
- __content_filename__ = {{filename}}
- render {{filename}}, {{layout}}
+ __content_filename__ = {{ filename }}
+ render {{ filename }}, {{ layout }}
end
macro rendered(filename)
- render("src/invidious/views/#{{{filename}}}.ecr")
+ render("src/invidious/views/#{{{ filename }}}.ecr")
end
# Similar to Kemals halt method but works in a
# method.
macro haltf(env, status_code = 200, response = "")
- {{env}}.response.status_code = {{status_code}}
- {{env}}.response.print {{response}}
- {{env}}.response.close
+ {{ env }}.response.status_code = {{ status_code }}
+ {{ env }}.response.print {{ response }}
+ {{ env }}.response.close
return
end
diff --git a/src/invidious/http_server/static_assets_handler.cr b/src/invidious/http_server/static_assets_handler.cr
index 7902c95bf..024b693dd 100644
--- a/src/invidious/http_server/static_assets_handler.cr
+++ b/src/invidious/http_server/static_assets_handler.cr
@@ -106,7 +106,7 @@ module Invidious::HttpServer
# 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)
# 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
# Clear cached files.
diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr
index 32e8554c3..684b578f8 100644
--- a/src/invidious/routing.cr
+++ b/src/invidious/routing.cr
@@ -3,12 +3,12 @@ module Invidious::Routing
{% 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}})
- raise Kemal::Exceptions::InvalidPathStartException.new({{http_method}}, \{{path}})
+ raise Kemal::Exceptions::InvalidPathStartException.new({{ http_method }}, \{{path}})
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)
end
end
@@ -238,91 +238,91 @@ module Invidious::Routing
def register_api_v1_routes
{% begin %}
- {{namespace = Routes::API::V1}}
+ {{ namespace = Routes::API::V1 }}
# Videos
- get "/api/v1/videos/:id", {{namespace}}::Videos, :videos
- get "/api/v1/storyboards/:id", {{namespace}}::Videos, :storyboards
- get "/api/v1/captions/:id", {{namespace}}::Videos, :captions
- get "/api/v1/annotations/:id", {{namespace}}::Videos, :annotations
- get "/api/v1/comments/:id", {{namespace}}::Videos, :comments
- get "/api/v1/clips/:id", {{namespace}}::Videos, :clips
- get "/api/v1/transcripts/:id", {{namespace}}::Videos, :transcripts
+ get "/api/v1/videos/:id", {{ namespace }}::Videos, :videos
+ get "/api/v1/storyboards/:id", {{ namespace }}::Videos, :storyboards
+ get "/api/v1/captions/:id", {{ namespace }}::Videos, :captions
+ get "/api/v1/annotations/:id", {{ namespace }}::Videos, :annotations
+ get "/api/v1/comments/:id", {{ namespace }}::Videos, :comments
+ get "/api/v1/clips/:id", {{ namespace }}::Videos, :clips
+ get "/api/v1/transcripts/:id", {{ namespace }}::Videos, :transcripts
# Feeds
- get "/api/v1/trending", {{namespace}}::Feeds, :trending
- get "/api/v1/popular", {{namespace}}::Feeds, :popular
+ get "/api/v1/trending", {{ namespace }}::Feeds, :trending
+ get "/api/v1/popular", {{ namespace }}::Feeds, :popular
# Channels
- get "/api/v1/channels/:ucid", {{namespace}}::Channels, :home
- get "/api/v1/channels/:ucid/latest", {{namespace}}::Channels, :latest
- get "/api/v1/channels/:ucid/videos", {{namespace}}::Channels, :videos
- get "/api/v1/channels/:ucid/shorts", {{namespace}}::Channels, :shorts
- get "/api/v1/channels/:ucid/streams", {{namespace}}::Channels, :streams
- get "/api/v1/channels/:ucid/podcasts", {{namespace}}::Channels, :podcasts
- get "/api/v1/channels/:ucid/releases", {{namespace}}::Channels, :releases
- get "/api/v1/channels/:ucid/courses", {{namespace}}::Channels, :courses
- get "/api/v1/channels/:ucid/playlists", {{namespace}}::Channels, :playlists
- get "/api/v1/channels/:ucid/community", {{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/search", {{namespace}}::Channels, :search
+ get "/api/v1/channels/:ucid", {{ namespace }}::Channels, :home
+ get "/api/v1/channels/:ucid/latest", {{ namespace }}::Channels, :latest
+ get "/api/v1/channels/:ucid/videos", {{ namespace }}::Channels, :videos
+ get "/api/v1/channels/:ucid/shorts", {{ namespace }}::Channels, :shorts
+ get "/api/v1/channels/:ucid/streams", {{ namespace }}::Channels, :streams
+ get "/api/v1/channels/:ucid/podcasts", {{ namespace }}::Channels, :podcasts
+ get "/api/v1/channels/:ucid/releases", {{ namespace }}::Channels, :releases
+ get "/api/v1/channels/:ucid/courses", {{ namespace }}::Channels, :courses
+ get "/api/v1/channels/:ucid/playlists", {{ namespace }}::Channels, :playlists
+ get "/api/v1/channels/:ucid/community", {{ 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/search", {{ namespace }}::Channels, :search
# Posts
- get "/api/v1/post/:id", {{namespace}}::Channels, :post
- get "/api/v1/post/:id/comments", {{namespace}}::Channels, :post_comments
+ get "/api/v1/post/:id", {{ namespace }}::Channels, :post
+ get "/api/v1/post/:id/comments", {{ namespace }}::Channels, :post_comments
# 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/:ucid/comments", {{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
# Search
- get "/api/v1/search", {{namespace}}::Search, :search
- get "/api/v1/search/suggestions", {{namespace}}::Search, :search_suggestions
- get "/api/v1/hashtag/:hashtag", {{namespace}}::Search, :hashtag
+ get "/api/v1/search", {{ namespace }}::Search, :search
+ get "/api/v1/search/suggestions", {{ namespace }}::Search, :search_suggestions
+ get "/api/v1/hashtag/:hashtag", {{ namespace }}::Search, :hashtag
# Authenticated
- get "/api/v1/auth/preferences", {{namespace}}::Authenticated, :get_preferences
- post "/api/v1/auth/preferences", {{namespace}}::Authenticated, :set_preferences
+ get "/api/v1/auth/preferences", {{ namespace }}::Authenticated, :get_preferences
+ post "/api/v1/auth/preferences", {{ namespace }}::Authenticated, :set_preferences
- get "/api/v1/auth/export/invidious", {{namespace}}::Authenticated, :export_invidious
- post "/api/v1/auth/import/invidious", {{namespace}}::Authenticated, :import_invidious
+ get "/api/v1/auth/export/invidious", {{ namespace }}::Authenticated, :export_invidious
+ post "/api/v1/auth/import/invidious", {{ namespace }}::Authenticated, :import_invidious
- get "/api/v1/auth/history", {{namespace}}::Authenticated, :get_history
- 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", {{namespace}}::Authenticated, :clear_history
+ get "/api/v1/auth/history", {{ namespace }}::Authenticated, :get_history
+ 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", {{ 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
- post "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :subscribe_channel
- delete "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :unsubscribe_channel
+ get "/api/v1/auth/subscriptions", {{ namespace }}::Authenticated, :get_subscriptions
+ post "/api/v1/auth/subscriptions/:ucid", {{ namespace }}::Authenticated, :subscribe_channel
+ delete "/api/v1/auth/subscriptions/:ucid", {{ namespace }}::Authenticated, :unsubscribe_channel
- get "/api/v1/auth/playlists", {{namespace}}::Authenticated, :list_playlists
- post "/api/v1/auth/playlists", {{namespace}}::Authenticated, :create_playlist
- patch "/api/v1/auth/playlists/:plid",{{namespace}}:: Authenticated, :update_playlist_attribute
- delete "/api/v1/auth/playlists/:plid", {{namespace}}::Authenticated, :delete_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
+ get "/api/v1/auth/playlists", {{ namespace }}::Authenticated, :list_playlists
+ post "/api/v1/auth/playlists", {{ namespace }}::Authenticated, :create_playlist
+ patch "/api/v1/auth/playlists/:plid",{{ namespace }}:: Authenticated, :update_playlist_attribute
+ delete "/api/v1/auth/playlists/:plid", {{ namespace }}::Authenticated, :delete_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
- get "/api/v1/auth/tokens", {{namespace}}::Authenticated, :get_tokens
- post "/api/v1/auth/tokens/register", {{namespace}}::Authenticated, :register_token
- post "/api/v1/auth/tokens/unregister", {{namespace}}::Authenticated, :unregister_token
+ get "/api/v1/auth/tokens", {{ namespace }}::Authenticated, :get_tokens
+ post "/api/v1/auth/tokens/register", {{ namespace }}::Authenticated, :register_token
+ post "/api/v1/auth/tokens/unregister", {{ namespace }}::Authenticated, :unregister_token
if CONFIG.enable_user_notifications
- get "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications
- post "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications
+ get "/api/v1/auth/notifications", {{ namespace }}::Authenticated, :notifications
+ post "/api/v1/auth/notifications", {{ namespace }}::Authenticated, :notifications
end
# Misc
- get "/api/v1/stats", {{namespace}}::Misc, :stats
- get "/api/v1/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/resolveurl", {{namespace}}::Misc, :resolve_url
+ get "/api/v1/stats", {{ namespace }}::Misc, :stats
+ get "/api/v1/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/resolveurl", {{ namespace }}::Misc, :resolve_url
{% end %}
end
end
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 0446922fe..b9ddecb6b 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -195,37 +195,37 @@ struct Video
# Macros defining getters/setters for various types of data
private macro getset_string(name)
- # Return {{name.stringify}} from `info`
- def {{name.id.underscore}} : String
- return info[{{name.stringify}}]?.try &.as_s || ""
+ # Return {{ name.stringify }} from `info`
+ def {{ name.id.underscore }} : String
+ return info[{{ name.stringify }}]?.try &.as_s || ""
end
- # Update {{name.stringify}} into `info`
- def {{name.id.underscore}}=(value : String)
- info[{{name.stringify}}] = JSON::Any.new(value)
+ # Update {{ name.stringify }} into `info`
+ def {{ name.id.underscore }}=(value : String)
+ info[{{ name.stringify }}] = JSON::Any.new(value)
end
- {% if flag?(:debug_macros) %} {{debug}} {% end %}
+ {% if flag?(:debug_macros) %} {{ debug }} {% end %}
end
private macro getset_string_array(name)
- # Return {{name.stringify}} from `info`
- def {{name.id.underscore}} : Array(String)
- return info[{{name.stringify}}]?.try &.as_a.map &.as_s || [] of String
+ # Return {{ name.stringify }} from `info`
+ def {{ name.id.underscore }} : Array(String)
+ return info[{{ name.stringify }}]?.try &.as_a.map &.as_s || [] of String
end
- # Update {{name.stringify}} into `info`
- def {{name.id.underscore}}=(value : Array(String))
- info[{{name.stringify}}] = JSON::Any.new(value)
+ # Update {{ name.stringify }} into `info`
+ def {{ name.id.underscore }}=(value : Array(String))
+ info[{{ name.stringify }}] = JSON::Any.new(value)
end
- {% if flag?(:debug_macros) %} {{debug}} {% end %}
+ {% if flag?(:debug_macros) %} {{ debug }} {% end %}
end
{% for op, type in {i32: Int32, i64: Int64} %}
- private macro getset_{{op}}(name)
- def \{{name.id.underscore}} : {{type}}
- return info[\{{name.stringify}}]?.try &.as_i64.to_{{op}} || 0_{{op}}
+ private macro getset_{{ op }}(name)
+ def \{{name.id.underscore}} : {{ type }}
+ return info[\{{name.stringify}}]?.try &.as_i64.to_{{ op }} || 0_{{ op }}
end
def \{{name.id.underscore}}=(value : Int)
@@ -237,32 +237,32 @@ struct Video
{% end %}
private macro getset_bool(name)
- # Return {{name.stringify}} from `info`
- def {{name.id.underscore}} : Bool
- return info[{{name.stringify}}]?.try &.as_bool || false
+ # Return {{ name.stringify }} from `info`
+ def {{ name.id.underscore }} : Bool
+ return info[{{ name.stringify }}]?.try &.as_bool || false
end
- # Update {{name.stringify}} into `info`
- def {{name.id.underscore}}=(value : Bool)
- info[{{name.stringify}}] = JSON::Any.new(value)
+ # Update {{ name.stringify }} into `info`
+ def {{ name.id.underscore }}=(value : Bool)
+ info[{{ name.stringify }}] = JSON::Any.new(value)
end
- {% if flag?(:debug_macros) %} {{debug}} {% end %}
+ {% if flag?(:debug_macros) %} {{ debug }} {% 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
+ # 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)
+ # 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 %}
+ {% if flag?(:debug_macros) %} {{ debug }} {% end %}
end
# Method definitions, using the macros above
diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr
index 04e00f202..759f1ed32 100644
--- a/src/invidious/yt_backend/extractors.cr
+++ b/src/invidious/yt_backend/extractors.cr
@@ -40,8 +40,8 @@ private module Parsers
begin
return parse_internal(*args)
rescue ex
- LOGGER.debug("#{{{@type.name}}}: Failed to render item.")
- LOGGER.debug("#{{{@type.name}}}: Got exception: #{ex.message}")
+ LOGGER.debug("#{{{ @type.name }}}: Failed to render item.")
+ LOGGER.debug("#{{{ @type.name }}}: Got exception: #{ex.message}")
ProblematicTimelineItem.new(
parse_exception: ex
)
@@ -173,7 +173,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -240,7 +240,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -289,7 +289,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -334,7 +334,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -395,7 +395,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -467,7 +467,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -496,7 +496,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -527,7 +527,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -626,7 +626,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -704,7 +704,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -762,7 +762,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -791,7 +791,7 @@ private module Parsers
end
def self.parser_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
end
@@ -878,7 +878,7 @@ private module Extractors
end
def self.extractor_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -919,7 +919,7 @@ private module Extractors
end
def self.extractor_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
@@ -953,7 +953,7 @@ private module Extractors
end
def self.extractor_name
- return {{@type.name}}
+ return {{ @type.name }}
end
end
end