Invidious is an alternative front-end to YouTube
chore: update to ameba 1.7.0 and adapt most of the code to it (#6082)
Fijxu907fe54aab02
diff --git a/.ameba.yml b/.ameba.ymlindex 7f6e4cae..5af91f9f 100644--- a/.ameba.yml+++ b/.ameba.yml@@ -5,20 +5,26 @@# Exclude assigns for ECR filesLint/UselessAssign:Excluded:- - src/invidious.cr- - src/invidious/helpers/errors.cr- - src/invidious/routes/*.cr+ - src/invidious.cr+ - src/invidious/helpers/errors.cr+ - src/invidious/routes/*.cr+ - src/invidious/views/**/**++# Exclude unused arguments for ECR files+Lint/UnusedArgument:+ Excluded:+ - src/invidious/views/**/**# Ignore false negative (if !db.query_one?...)Lint/UnreachableCode:Excluded:- - src/invidious/database/base.cr+ - src/invidious/database/base.cr# Ignore shadowed variable `key` (it works for now, and that's# a sensitive part of the code)Lint/ShadowingOuterLocalVar:Excluded:- - src/invidious/helpers/tokens.cr+ - src/invidious/helpers/tokens.crLint/NotNil:Enabled: false@@ -27,7 +33,6 @@ Lint/SpecFilename:Excluded:- spec/parsers_helper.cr-## Style#@@ -44,6 +49,15 @@ Style/RedundantNext:Style/ParenthesesAroundCondition:Enabled: false+# Disable this as it's really useful for functions and variables+# that belong to a same module, struct or class, and it can be confused+# by a global function.+# This is subject to change with https://github.com/iv-org/invidious/pull/6046+# where there will not be more global variables or functions, well, that's+# the goal.+Style/RedundantSelf:+ Enabled: false+# This requires a rewrite of most data structs (and their usage) in Invidious.Naming/QueryBoolMethods:Enabled: false@@ -56,12 +70,11 @@ Naming/BlockParameterName:# Hides TODO comment warnings.#-# Call `bin/ameba --only Documentation/DocumentationAdmonition` to+# Call `bin/ameba --only Documentation/Admonition` to# list them-Documentation/DocumentationAdmonition:+Documentation/Admonition:Enabled: false-## Metrics#diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 514462d9..6d9f5a58 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -146,7 +146,6 @@ jobs:with:path: |./lib- ./binkey: shards-${{ hashFiles('shard.lock') }}-${{ steps.lint_step_install_crystal.outputs.crystal }}- name: Install Shards@@ -164,4 +163,4 @@ jobs:fi- name: Run Ameba linter- run: bin/ameba+ uses: crystal-ameba/github-action@v1diff --git a/shard.lock b/shard.lockindex 6b3ebc6e..7aaa7470 100644--- a/shard.lock+++ b/shard.lock@@ -2,7 +2,7 @@ version: 2.0shards:ameba:git: https://github.com/crystal-ameba/ameba.git- version: 1.6.4+ version: 1.7.0athena-negotiation:git: https://github.com/athena-framework/negotiation.gitdiff --git a/shard.yml b/shard.ymlindex e6536780..beb35f91 100644--- a/shard.yml+++ b/shard.yml@@ -8,6 +8,8 @@ authors:targets:invidious:main: src/invidious.cr+ ameba:+ main: lib/ameba/bin/ameba.crdescription: |Invidious is an alternative front-end to YouTube@@ -38,7 +40,7 @@ development_dependencies:version: ~> 0.12.4ameba:github: crystal-ameba/ameba- version: ~> 1.6.4+ version: ~> 1.7.0crystal: ">= 1.14.1, < 2.0.0"diff --git a/spec/http_server/handlers/static_assets_handler_spec.cr b/spec/http_server/handlers/static_assets_handler_spec.crindex 76dc7be7..268c4b2f 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 foldermacro get_file_path(basename)- "spec/http_server/handlers/static_assets_handler/#{ {{basename}} }"+ "spec/http_server/handlers/static_assets_handler/#{ {{ basename }} }"endSpectator.describe StaticAssetsHandler dodiff --git a/spec/invidious/user/imports_spec.cr b/spec/invidious/user/imports_spec.crindex 762ce0d8..58b5d4aa 100644--- a/spec/invidious/user/imports_spec.cr+++ b/spec/invidious/user/imports_spec.cr@@ -8,21 +8,21 @@ enddef csv_samplereturn <<-CSV- Kanal-ID,Kanal-URL,Kanaltitel- UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla- UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie- UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft- UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic- UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott- UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun- UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations- UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos- UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake- UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy- UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp- UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips- UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord- CSV+ Kanal-ID,Kanal-URL,Kanaltitel+ UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla+ UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie+ UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft+ UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic+ UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott+ UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun+ UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations+ UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos+ UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake+ UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy+ UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp+ UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips+ UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord+ CSVendSpectator.describe Invidious::User::Import dodiff --git a/src/invidious.cr b/src/invidious.crindex cc65dde0..c436ad3c 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -123,7 +123,7 @@ Kemal.config.extra_options do |parser|parser.on("-c THREADS", "--channel-threads=THREADS", "Number of threads for refreshing channels (default: #{CONFIG.channel_threads})") do |number|beginCONFIG.channel_threads = number.to_i- rescue ex+ rescueputs "THREADS must be integer"exitend@@ -131,7 +131,7 @@ Kemal.config.extra_options do |parser|parser.on("-f THREADS", "--feed-threads=THREADS", "Number of threads for refreshing feeds (default: #{CONFIG.feed_threads})") do |number|beginCONFIG.feed_threads = number.to_i- rescue ex+ rescueputs "THREADS must be integer"exitenddiff --git a/src/invidious/channels/channels.cr b/src/invidious/channels/channels.crindex 64f0484d..de177911 100644--- a/src/invidious/channels/channels.cr+++ b/src/invidious/channels/channels.cr@@ -93,7 +93,7 @@ struct ChannelVideodef to_tuple{% begin %}{- {{@type.instance_vars.map(&.name).splat}}+ {{ @type.instance_vars.map(&.name).splat }}}{% end %}end@@ -107,7 +107,7 @@ class ChannelRedirect < Exceptionenddef get_batch_channels(channels)- finished_channel = Channel(String | Nil).new+ finished_channel = Channel(String?).newmax_threads = 10spawn do@@ -125,7 +125,7 @@ def get_batch_channels(channels)beginget_channel(ucid)finished_channel.send(ucid)- rescue ex+ rescuefinished_channel.send(nil)ensureactive_channel.send(nil)diff --git a/src/invidious/comments/links_util.cr b/src/invidious/comments/links_util.crindex f89b86d3..6832aeea 100644--- a/src/invidious/comments/links_util.cr+++ b/src/invidious/comments/links_util.cr@@ -15,7 +15,7 @@ module Invidious::Commentsif url.host.nil? || url.host.not_nil!.ends_with?("youtube.com") || url.host.not_nil!.ends_with?("youtu.be")if url.host.try &.ends_with? "youtu.be"- url = "/watch?v=#{url.path.lstrip('/')}#{url.query_params}"+ anchor["href"] = "/watch?v=#{url.path.lstrip('/')}#{url.query_params}"elseif url.path == "/redirect"params = HTTP::Params.parse(url.query.not_nil!)@@ -27,7 +27,7 @@ module Invidious::Commentselsif url.to_s == "#"beginlength_seconds = decode_length_seconds(anchor.content)- rescue ex+ rescuelength_seconds = decode_time(anchor.content)enddiff --git a/src/invidious/config.cr b/src/invidious/config.crindex 58b77cba..94a3946c 100644--- a/src/invidious/config.cr+++ b/src/invidious/config.cr@@ -59,7 +59,7 @@ struct ConfigPreferencesdef 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@@ -237,14 +237,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@@ -252,10 +252,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 !successbegin- config.{{ivar.id}} = ivar_type.from_yaml(env_value)+ config.{{ ivar.id }} = ivar_type.from_yaml(env_value)success = truerescue# nop@@ -266,14 +266,14 @@ class Config# Exit on failif !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)endend# 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/database/annotations.cr b/src/invidious/database/annotations.crindex 03749473..f1659509 100644--- a/src/invidious/database/annotations.cr+++ b/src/invidious/database/annotations.cr@@ -8,7 +8,7 @@ module Invidious::Database::AnnotationsINSERT INTO annotationsVALUES ($1, $2)ON CONFLICT DO NOTHING- SQL+ SQLPG_DB.exec(request, id, annotations)end@@ -17,7 +17,7 @@ module Invidious::Database::Annotationsrequest = <<-SQLSELECT * FROM annotationsWHERE id = $1- SQL+ SQLreturn PG_DB.query_one?(request, id, as: Annotation)enddiff --git a/src/invidious/database/base.cr b/src/invidious/database/base.crindex 0fb1b6af..a9757e9a 100644--- a/src/invidious/database/base.cr+++ b/src/invidious/database/base.cr@@ -45,7 +45,7 @@ module Invidious::Database# Create table if it doesn't existbeginPG_DB.exec("SELECT * FROM #{table_name} LIMIT 0")- rescue ex+ rescueLOGGER.info("check_table: check_table: CREATE TABLE #{table_name}")PG_DB.using_connection do |conn|diff --git a/src/invidious/database/channels.cr b/src/invidious/database/channels.crindex df44e485..3e7f480c 100644--- a/src/invidious/database/channels.cr+++ b/src/invidious/database/channels.cr@@ -16,13 +16,13 @@ module Invidious::Database::Channelsrequest = <<-SQLINSERT INTO channelsVALUES (#{arg_array(channel_array)})- SQL+ SQLif update_on_conflictrequest += <<-SQLON CONFLICT (id) DO UPDATESET author = $2, updated = $3- SQL+ SQLendPG_DB.exec(request, args: channel_array)@@ -37,7 +37,7 @@ module Invidious::Database::ChannelsUPDATE channelsSET updated = now(), author = $1, deleted = falseWHERE id = $2- SQL+ SQLPG_DB.exec(request, author, id)end@@ -47,7 +47,7 @@ module Invidious::Database::ChannelsUPDATE channelsSET subscribed = now()WHERE id = $1- SQL+ SQLPG_DB.exec(request, id)end@@ -57,7 +57,7 @@ module Invidious::Database::ChannelsUPDATE channelsSET updated = now(), deleted = trueWHERE id = $1- SQL+ SQLPG_DB.exec(request, id)end@@ -70,7 +70,7 @@ module Invidious::Database::Channelsrequest = <<-SQLSELECT * FROM channelsWHERE id = $1- SQL+ SQLreturn PG_DB.query_one?(request, id, as: InvidiousChannel)end@@ -81,7 +81,7 @@ module Invidious::Database::Channelsrequest = <<-SQLSELECT * FROM channelsWHERE id = ANY($1)- SQL+ SQLreturn PG_DB.query_all(request, ids, as: InvidiousChannel)end@@ -112,7 +112,7 @@ module Invidious::Database::ChannelVideosSET title = $2, published = $3, updated = $4, ucid = $5,author = $6, length_seconds = $7, live_now = $8, #{last_items}RETURNING (xmax=0) AS was_insert- SQL+ SQLreturn PG_DB.query_one(request, *video.to_tuple, as: Bool)end@@ -128,7 +128,7 @@ module Invidious::Database::ChannelVideosSELECT * FROM channel_videosWHERE id = ANY($1)ORDER BY published DESC- SQL+ SQLreturn PG_DB.query_all(request, ids, as: ChannelVideo)end@@ -139,7 +139,7 @@ module Invidious::Database::ChannelVideosWHERE ucid = $1 AND published > $2ORDER BY published DESCLIMIT 15- SQL+ SQLreturn PG_DB.query_all(request, ucid, since, as: ChannelVideo)end@@ -151,7 +151,7 @@ module Invidious::Database::ChannelVideosWHERE ucid IN (SELECT channel FROM (SELECT UNNEST(subscriptions) AS channel FROM users) AS dGROUP BY channel ORDER BY COUNT(channel) DESC LIMIT 40)ORDER BY ucid, published DESC- SQL+ SQLPG_DB.query_all(request, as: ChannelVideo)enddiff --git a/src/invidious/database/migrations/0001_create_channels_table.cr b/src/invidious/database/migrations/0001_create_channels_table.crindex a1362bcf..df7e31a1 100644--- a/src/invidious/database/migrations/0001_create_channels_table.cr+++ b/src/invidious/database/migrations/0001_create_channels_table.cr@@ -4,27 +4,27 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.channels- (- id text NOT NULL,- author text,- updated timestamp with time zone,- deleted boolean,- subscribed timestamp with time zone,- CONSTRAINT channels_id_key UNIQUE (id)- );- SQL+ CREATE TABLE IF NOT EXISTS public.channels+ (+ id text NOT NULL,+ author text,+ updated timestamp with time zone,+ deleted boolean,+ subscribed timestamp with time zone,+ CONSTRAINT channels_id_key UNIQUE (id)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.channels TO current_user;- SQL+ GRANT ALL ON TABLE public.channels TO current_user;+ SQLconn.exec <<-SQL- CREATE INDEX IF NOT EXISTS channels_id_idx- ON public.channels- USING btree- (id COLLATE pg_catalog."default");- SQL+ CREATE INDEX IF NOT EXISTS channels_id_idx+ ON public.channels+ USING btree+ (id COLLATE pg_catalog."default");+ SQLendendenddiff --git a/src/invidious/database/migrations/0002_create_videos_table.cr b/src/invidious/database/migrations/0002_create_videos_table.crindex c2ac84f8..1d0f5afb 100644--- a/src/invidious/database/migrations/0002_create_videos_table.cr+++ b/src/invidious/database/migrations/0002_create_videos_table.cr@@ -4,25 +4,25 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE UNLOGGED TABLE IF NOT EXISTS public.videos- (- id text NOT NULL,- info text,- updated timestamp with time zone,- CONSTRAINT videos_pkey PRIMARY KEY (id)- );- SQL+ CREATE UNLOGGED TABLE IF NOT EXISTS public.videos+ (+ id text NOT NULL,+ info text,+ updated timestamp with time zone,+ CONSTRAINT videos_pkey PRIMARY KEY (id)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.videos TO current_user;- SQL+ GRANT ALL ON TABLE public.videos TO current_user;+ SQLconn.exec <<-SQL- CREATE UNIQUE INDEX IF NOT EXISTS id_idx- ON public.videos- USING btree- (id COLLATE pg_catalog."default");- SQL+ CREATE UNIQUE INDEX IF NOT EXISTS id_idx+ ON public.videos+ USING btree+ (id COLLATE pg_catalog."default");+ SQLendendenddiff --git a/src/invidious/database/migrations/0003_create_channel_videos_table.cr b/src/invidious/database/migrations/0003_create_channel_videos_table.crindex c9b62e4c..e4023fef 100644--- a/src/invidious/database/migrations/0003_create_channel_videos_table.cr+++ b/src/invidious/database/migrations/0003_create_channel_videos_table.cr@@ -4,32 +4,32 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.channel_videos- (- id text NOT NULL,- title text,- published timestamp with time zone,- updated timestamp with time zone,- ucid text,- author text,- length_seconds integer,- live_now boolean,- premiere_timestamp timestamp with time zone,- views bigint,- CONSTRAINT channel_videos_id_key UNIQUE (id)- );- SQL+ CREATE TABLE IF NOT EXISTS public.channel_videos+ (+ id text NOT NULL,+ title text,+ published timestamp with time zone,+ updated timestamp with time zone,+ ucid text,+ author text,+ length_seconds integer,+ live_now boolean,+ premiere_timestamp timestamp with time zone,+ views bigint,+ CONSTRAINT channel_videos_id_key UNIQUE (id)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.channel_videos TO current_user;- SQL+ GRANT ALL ON TABLE public.channel_videos TO current_user;+ SQLconn.exec <<-SQL- CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx- ON public.channel_videos- USING btree- (ucid COLLATE pg_catalog."default");- SQL+ CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx+ ON public.channel_videos+ USING btree+ (ucid COLLATE pg_catalog."default");+ SQLendendenddiff --git a/src/invidious/database/migrations/0004_create_users_table.cr b/src/invidious/database/migrations/0004_create_users_table.crindex a13ba15f..3e561bc0 100644--- a/src/invidious/database/migrations/0004_create_users_table.cr+++ b/src/invidious/database/migrations/0004_create_users_table.cr@@ -4,31 +4,31 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.users- (- updated timestamp with time zone,- notifications text[],- subscriptions text[],- email text NOT NULL,- preferences text,- password text,- token text,- watched text[],- feed_needs_update boolean,- CONSTRAINT users_email_key UNIQUE (email)- );- SQL+ CREATE TABLE IF NOT EXISTS public.users+ (+ updated timestamp with time zone,+ notifications text[],+ subscriptions text[],+ email text NOT NULL,+ preferences text,+ password text,+ token text,+ watched text[],+ feed_needs_update boolean,+ CONSTRAINT users_email_key UNIQUE (email)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.users TO current_user;- SQL+ GRANT ALL ON TABLE public.users TO current_user;+ SQLconn.exec <<-SQL- CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx- ON public.users- USING btree- (lower(email) COLLATE pg_catalog."default");- SQL+ CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx+ ON public.users+ USING btree+ (lower(email) COLLATE pg_catalog."default");+ SQLendendenddiff --git a/src/invidious/database/migrations/0005_create_session_ids_table.cr b/src/invidious/database/migrations/0005_create_session_ids_table.crindex 13c2228d..e760ad16 100644--- a/src/invidious/database/migrations/0005_create_session_ids_table.cr+++ b/src/invidious/database/migrations/0005_create_session_ids_table.cr@@ -4,25 +4,25 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.session_ids- (- id text NOT NULL,- email text,- issued timestamp with time zone,- CONSTRAINT session_ids_pkey PRIMARY KEY (id)- );- SQL+ CREATE TABLE IF NOT EXISTS public.session_ids+ (+ id text NOT NULL,+ email text,+ issued timestamp with time zone,+ CONSTRAINT session_ids_pkey PRIMARY KEY (id)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.session_ids TO current_user;- SQL+ GRANT ALL ON TABLE public.session_ids TO current_user;+ SQLconn.exec <<-SQL- CREATE INDEX IF NOT EXISTS session_ids_id_idx- ON public.session_ids- USING btree- (id COLLATE pg_catalog."default");- SQL+ CREATE INDEX IF NOT EXISTS session_ids_id_idx+ ON public.session_ids+ USING btree+ (id COLLATE pg_catalog."default");+ SQLendendenddiff --git a/src/invidious/database/migrations/0006_create_nonces_table.cr b/src/invidious/database/migrations/0006_create_nonces_table.crindex cf1229e1..c2ae7a87 100644--- a/src/invidious/database/migrations/0006_create_nonces_table.cr+++ b/src/invidious/database/migrations/0006_create_nonces_table.cr@@ -4,24 +4,24 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.nonces- (- nonce text,- expire timestamp with time zone,- CONSTRAINT nonces_id_key UNIQUE (nonce)- );- SQL+ CREATE TABLE IF NOT EXISTS public.nonces+ (+ nonce text,+ expire timestamp with time zone,+ CONSTRAINT nonces_id_key UNIQUE (nonce)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.nonces TO current_user;- SQL+ GRANT ALL ON TABLE public.nonces TO current_user;+ SQLconn.exec <<-SQL- CREATE INDEX IF NOT EXISTS nonces_nonce_idx- ON public.nonces- USING btree- (nonce COLLATE pg_catalog."default");- SQL+ CREATE INDEX IF NOT EXISTS nonces_nonce_idx+ ON public.nonces+ USING btree+ (nonce COLLATE pg_catalog."default");+ SQLendendenddiff --git a/src/invidious/database/migrations/0007_create_annotations_table.cr b/src/invidious/database/migrations/0007_create_annotations_table.crindex dcecbc3b..518e2886 100644--- a/src/invidious/database/migrations/0007_create_annotations_table.cr+++ b/src/invidious/database/migrations/0007_create_annotations_table.cr@@ -4,17 +4,17 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.annotations- (- id text NOT NULL,- annotations xml,- CONSTRAINT annotations_id_key UNIQUE (id)- );- SQL+ CREATE TABLE IF NOT EXISTS public.annotations+ (+ id text NOT NULL,+ annotations xml,+ CONSTRAINT annotations_id_key UNIQUE (id)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.annotations TO current_user;- SQL+ GRANT ALL ON TABLE public.annotations TO current_user;+ SQLendendenddiff --git a/src/invidious/database/migrations/0008_create_playlists_table.cr b/src/invidious/database/migrations/0008_create_playlists_table.crindex 6aa16e1a..63901f61 100644--- a/src/invidious/database/migrations/0008_create_playlists_table.cr+++ b/src/invidious/database/migrations/0008_create_playlists_table.cr@@ -5,33 +5,33 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)if !privacy_type_exists?(conn)conn.exec <<-SQL- CREATE TYPE public.privacy AS ENUM- (- 'Public',- 'Unlisted',- 'Private'- );- SQL+ CREATE TYPE public.privacy AS ENUM+ (+ 'Public',+ 'Unlisted',+ 'Private'+ );+ SQLendconn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.playlists- (- title text,- id text primary key,- author text,- description text,- video_count integer,- created timestamptz,- updated timestamptz,- privacy privacy,- index int8[]- );- SQL+ CREATE TABLE IF NOT EXISTS public.playlists+ (+ title text,+ id text primary key,+ author text,+ description text,+ video_count integer,+ created timestamptz,+ updated timestamptz,+ privacy privacy,+ index int8[]+ );+ SQLconn.exec <<-SQL- GRANT ALL ON public.playlists TO current_user;- SQL+ GRANT ALL ON public.playlists TO current_user;+ SQLendprivate def privacy_type_exists?(conn : DB::Connection) : Bool@@ -42,7 +42,7 @@ module Invidious::Database::MigrationsWHERE pg_namespace.nspname = 'public'AND pg_type.typname = 'privacy'LIMIT 1;- SQL+ SQL!conn.query_one?(request, as: Int32).nil?enddiff --git a/src/invidious/database/migrations/0009_create_playlist_videos_table.cr b/src/invidious/database/migrations/0009_create_playlist_videos_table.crindex 84938b9b..82699b34 100644--- a/src/invidious/database/migrations/0009_create_playlist_videos_table.cr+++ b/src/invidious/database/migrations/0009_create_playlist_videos_table.cr@@ -4,24 +4,24 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- CREATE TABLE IF NOT EXISTS public.playlist_videos- (- title text,- id text,- author text,- ucid text,- length_seconds integer,- published timestamptz,- plid text references playlists(id),- index int8,- live_now boolean,- PRIMARY KEY (index,plid)- );- SQL+ CREATE TABLE IF NOT EXISTS public.playlist_videos+ (+ title text,+ id text,+ author text,+ ucid text,+ length_seconds integer,+ published timestamptz,+ plid text references playlists(id),+ index int8,+ live_now boolean,+ PRIMARY KEY (index,plid)+ );+ SQLconn.exec <<-SQL- GRANT ALL ON TABLE public.playlist_videos TO current_user;- SQL+ GRANT ALL ON TABLE public.playlist_videos TO current_user;+ SQLendendenddiff --git a/src/invidious/database/migrations/0010_make_videos_unlogged.cr b/src/invidious/database/migrations/0010_make_videos_unlogged.crindex f5d19683..37f1da23 100644--- a/src/invidious/database/migrations/0010_make_videos_unlogged.cr+++ b/src/invidious/database/migrations/0010_make_videos_unlogged.cr@@ -4,8 +4,8 @@ module Invidious::Database::Migrationsdef up(conn : DB::Connection)conn.exec <<-SQL- ALTER TABLE public.videos SET UNLOGGED;- SQL+ ALTER TABLE public.videos SET UNLOGGED;+ SQLendendenddiff --git a/src/invidious/database/migrator.cr b/src/invidious/database/migrator.crindex 660c3203..200cf421 100644--- a/src/invidious/database/migrator.cr+++ b/src/invidious/database/migrator.cr@@ -44,6 +44,6 @@ class Invidious::Database::Migratorid bigserial PRIMARY KEY,version bigint NOT NULL)- SQL+ SQLendenddiff --git a/src/invidious/database/nonces.cr b/src/invidious/database/nonces.crindex b87c81ec..55c8d856 100644--- a/src/invidious/database/nonces.cr+++ b/src/invidious/database/nonces.cr@@ -12,7 +12,7 @@ module Invidious::Database::NoncesINSERT INTO noncesVALUES ($1, $2)ON CONFLICT DO NOTHING- SQL+ SQLPG_DB.exec(request, nonce, expire)end@@ -21,7 +21,7 @@ module Invidious::Database::Noncesrequest = <<-SQLDELETE FROM nonces *WHERE expire < now()- SQL+ SQLPG_DB.exec(request)end@@ -35,7 +35,7 @@ module Invidious::Database::NoncesUPDATE noncesSET expire = $1WHERE nonce = $2- SQL+ SQLPG_DB.exec(request, Time.utc(1990, 1, 1), nonce)end@@ -48,7 +48,7 @@ module Invidious::Database::Noncesrequest = <<-SQLSELECT * FROM noncesWHERE nonce = $1- SQL+ SQLreturn PG_DB.query_one?(request, nonce, as: {String, Time})enddiff --git a/src/invidious/database/playlists.cr b/src/invidious/database/playlists.crindex 4db6b11d..ee8ab88c 100644--- a/src/invidious/database/playlists.cr+++ b/src/invidious/database/playlists.cr@@ -16,7 +16,7 @@ module Invidious::Database::Playlistsrequest = <<-SQLINSERT INTO playlistsVALUES (#{arg_array(playlist_array)})- SQL+ SQLPG_DB.exec(request, args: playlist_array)end@@ -27,7 +27,7 @@ module Invidious::Database::Playlistsrequest = <<-SQLDELETE FROM playlists *WHERE id = $1- SQL+ SQLPG_DB.exec(request, id)end@@ -41,7 +41,7 @@ module Invidious::Database::PlaylistsUPDATE playlistsSET title = $1, privacy = $2, description = $3, updated = $4WHERE id = $5- SQL+ SQLPG_DB.exec(request, title, privacy, description, updated, id)end@@ -51,7 +51,7 @@ module Invidious::Database::PlaylistsUPDATE playlistsSET description = $1WHERE id = $2- SQL+ SQLPG_DB.exec(request, description, id)end@@ -61,7 +61,7 @@ module Invidious::Database::PlaylistsUPDATE playlistsSET subscribed = now()WHERE id = $1- SQL+ SQLPG_DB.exec(request, id)end@@ -73,7 +73,7 @@ module Invidious::Database::Playlistsvideo_count = cardinality(index) + 1,updated = now()WHERE id = $2- SQL+ SQLPG_DB.exec(request, index, id)end@@ -85,7 +85,7 @@ module Invidious::Database::Playlistsvideo_count = cardinality(index) - 1,updated = now()WHERE id = $2- SQL+ SQLPG_DB.exec(request, index, id)end@@ -98,7 +98,7 @@ module Invidious::Database::Playlistsrequest = <<-SQLSELECT * FROM playlistsWHERE id = $1- SQL+ SQLreturn PG_DB.query_one?(request, id, as: InvidiousPlaylist)end@@ -107,7 +107,7 @@ module Invidious::Database::Playlistsrequest = <<-SQLSELECT * FROM playlistsWHERE author = $1- SQL+ SQLreturn PG_DB.query_all(request, author, as: InvidiousPlaylist)end@@ -121,7 +121,7 @@ module Invidious::Database::PlaylistsSELECT * FROM playlistsWHERE author = $1 AND id LIKE 'IV%'ORDER BY created- SQL+ SQLPG_DB.query_all(request, email, as: InvidiousPlaylist)end@@ -131,7 +131,7 @@ module Invidious::Database::PlaylistsSELECT * FROM playlistsWHERE author = $1 AND id NOT LIKE 'IV%'ORDER BY created- SQL+ SQLPG_DB.query_all(request, email, as: InvidiousPlaylist)end@@ -141,7 +141,7 @@ module Invidious::Database::PlaylistsSELECT id,title FROM playlistsWHERE author = $1 AND id LIKE 'IV%'ORDER BY title- SQL+ SQLPG_DB.query_all(request, email, as: {String, String})end@@ -155,7 +155,7 @@ module Invidious::Database::Playlistsrequest = <<-SQLSELECT id FROM playlistsWHERE id = $1- SQL+ SQLreturn PG_DB.query_one?(request, id, as: String).nil?end@@ -165,7 +165,7 @@ module Invidious::Database::Playlistsrequest = <<-SQLSELECT count(*) FROM playlistsWHERE author = $1- SQL+ SQLreturn PG_DB.query_one?(request, author, as: Int64) || 0_i64end@@ -189,7 +189,7 @@ module Invidious::Database::PlaylistVideosrequest = <<-SQLINSERT INTO playlist_videosVALUES (#{arg_array(video_array)})- SQL+ SQLPG_DB.exec(request, args: video_array)end@@ -198,7 +198,7 @@ module Invidious::Database::PlaylistVideosrequest = <<-SQLDELETE FROM playlist_videos *WHERE index = $1 AND plid = $2- SQL+ SQLPG_DB.exec(request, index, plid)end@@ -207,7 +207,7 @@ module Invidious::Database::PlaylistVideosrequest = <<-SQLDELETE FROM playlist_videos *WHERE plid = $1- SQL+ SQLPG_DB.exec(request, plid)end@@ -223,7 +223,7 @@ module Invidious::Database::PlaylistVideosORDER BY array_position($2, index)LIMIT $3OFFSET $4- SQL+ SQLreturn PG_DB.query_all(request, plid, index, limit, offset, as: PlaylistVideo)end@@ -233,7 +233,7 @@ module Invidious::Database::PlaylistVideosSELECT index FROM playlist_videosWHERE plid = $1 AND id = $2LIMIT 1- SQL+ SQLreturn PG_DB.query_one?(request, plid, vid, as: Int64)end@@ -244,7 +244,7 @@ module Invidious::Database::PlaylistVideosWHERE plid = $1ORDER BY array_position($2, index)LIMIT 1- SQL+ SQLreturn PG_DB.query_one?(request, plid, index, as: String)end@@ -255,7 +255,7 @@ module Invidious::Database::PlaylistVideosWHERE plid = $1ORDER BY array_position($2, index)LIMIT $3- SQL+ SQLreturn PG_DB.query_all(request, plid, index, limit, as: String)enddiff --git a/src/invidious/database/sessions.cr b/src/invidious/database/sessions.crindex 96587082..5537f087 100644--- a/src/invidious/database/sessions.cr+++ b/src/invidious/database/sessions.cr@@ -11,7 +11,7 @@ module Invidious::Database::SessionIDsrequest = <<-SQLINSERT INTO session_idsVALUES ($1, $2, now())- SQL+ SQLrequest += " ON CONFLICT (id) DO NOTHING" if handle_conflicts@@ -26,7 +26,7 @@ module Invidious::Database::SessionIDsrequest = <<-SQLDELETE FROM session_ids *WHERE id = $1- SQL+ SQLPG_DB.exec(request, sid)end@@ -35,7 +35,7 @@ module Invidious::Database::SessionIDsrequest = <<-SQLDELETE FROM session_ids *WHERE email = $1- SQL+ SQLPG_DB.exec(request, email)end@@ -44,7 +44,7 @@ module Invidious::Database::SessionIDsrequest = <<-SQLDELETE FROM session_ids *WHERE id = $1 AND email = $2- SQL+ SQLPG_DB.exec(request, sid, email)end@@ -57,7 +57,7 @@ module Invidious::Database::SessionIDsrequest = <<-SQLSELECT email FROM session_idsWHERE id = $1- SQL+ SQLPG_DB.query_one?(request, sid, as: String)end@@ -67,7 +67,7 @@ module Invidious::Database::SessionIDsSELECT id, issued FROM session_idsWHERE email = $1ORDER BY issued DESC- SQL+ SQLPG_DB.query_all(request, email, as: {session: String, issued: Time})enddiff --git a/src/invidious/database/statistics.cr b/src/invidious/database/statistics.crindex 9e4963fd..cf2a138e 100644--- a/src/invidious/database/statistics.cr+++ b/src/invidious/database/statistics.cr@@ -10,7 +10,7 @@ module Invidious::Database::Statisticsdef count_users_total : Int64request = <<-SQLSELECT count(*) FROM users- SQL+ SQLPG_DB.query_one(request, as: Int64)end@@ -19,7 +19,7 @@ module Invidious::Database::Statisticsrequest = <<-SQLSELECT count(*) FROM usersWHERE CURRENT_TIMESTAMP - updated < '6 months'- SQL+ SQLPG_DB.query_one(request, as: Int64)end@@ -28,7 +28,7 @@ module Invidious::Database::Statisticsrequest = <<-SQLSELECT count(*) FROM usersWHERE CURRENT_TIMESTAMP - updated < '1 month'- SQL+ SQLPG_DB.query_one(request, as: Int64)end@@ -42,7 +42,7 @@ module Invidious::Database::StatisticsSELECT updated FROM channelsORDER BY updated DESCLIMIT 1- SQL+ SQLPG_DB.query_one?(request, as: Time)enddiff --git a/src/invidious/database/users.cr b/src/invidious/database/users.crindex 4a3056ea..9b297930 100644--- a/src/invidious/database/users.cr+++ b/src/invidious/database/users.cr@@ -14,13 +14,13 @@ module Invidious::Database::Usersrequest = <<-SQLINSERT INTO usersVALUES (#{arg_array(user_array)})- SQL+ SQLif update_on_conflictrequest += <<-SQLON CONFLICT (email) DO UPDATESET updated = $1, subscriptions = $3- SQL+ SQLendPG_DB.exec(request, args: user_array)@@ -30,7 +30,7 @@ module Invidious::Database::Usersrequest = <<-SQLDELETE FROM users *WHERE email = $1- SQL+ SQLPG_DB.exec(request, user.email)end@@ -44,7 +44,7 @@ module Invidious::Database::UsersUPDATE usersSET watched = $1WHERE email = $2- SQL+ SQLPG_DB.exec(request, user.watched, user.email)end@@ -54,7 +54,7 @@ module Invidious::Database::UsersUPDATE usersSET watched = array_append(array_remove(watched, $1), $1)WHERE email = $2- SQL+ SQLPG_DB.exec(request, vid, user.email)end@@ -64,7 +64,7 @@ module Invidious::Database::UsersUPDATE usersSET watched = array_remove(watched, $1)WHERE email = $2- SQL+ SQLPG_DB.exec(request, vid, user.email)end@@ -74,7 +74,7 @@ module Invidious::Database::UsersUPDATE usersSET watched = '{}'WHERE email = $1- SQL+ SQLPG_DB.exec(request, user.email)end@@ -88,7 +88,7 @@ module Invidious::Database::UsersUPDATE usersSET feed_needs_update = true, subscriptions = $1WHERE email = $2- SQL+ SQLPG_DB.exec(request, user.subscriptions, user.email)end@@ -99,7 +99,7 @@ module Invidious::Database::UsersSET feed_needs_update = true,subscriptions = array_append(subscriptions,$1)WHERE email = $2- SQL+ SQLPG_DB.exec(request, ucid, user.email)end@@ -110,7 +110,7 @@ module Invidious::Database::UsersSET feed_needs_update = true,subscriptions = array_remove(subscriptions, $1)WHERE email = $2- SQL+ SQLPG_DB.exec(request, ucid, user.email)end@@ -125,7 +125,7 @@ module Invidious::Database::UsersSET notifications = array_cat(notifications, $1),feed_needs_update = trueWHERE $2 = ANY(subscriptions)- SQL+ SQLPG_DB.exec(request, video_ids, channel_id)end@@ -135,7 +135,7 @@ module Invidious::Database::UsersUPDATE usersSET notifications = array_remove(notifications, $1)WHERE email = $2- SQL+ SQLPG_DB.exec(request, vid, user.email)end@@ -145,7 +145,7 @@ module Invidious::Database::UsersUPDATE usersSET notifications = '{}', updated = now()WHERE email = $1- SQL+ SQLPG_DB.exec(request, user.email)end@@ -159,7 +159,7 @@ module Invidious::Database::UsersUPDATE usersSET feed_needs_update = trueWHERE $1 = ANY(subscriptions)- SQL+ SQLPG_DB.exec(request, channel_id)end@@ -169,7 +169,7 @@ module Invidious::Database::UsersUPDATE usersSET preferences = $1WHERE email = $2- SQL+ SQLPG_DB.exec(request, user.preferences.to_json, user.email)end@@ -179,7 +179,7 @@ module Invidious::Database::UsersUPDATE usersSET password = $1WHERE email = $2- SQL+ SQLPG_DB.exec(request, pass, user.email)end@@ -192,7 +192,7 @@ module Invidious::Database::Usersrequest = <<-SQLSELECT * FROM usersWHERE email = $1- SQL+ SQLreturn PG_DB.query_one?(request, email, as: User)end@@ -202,7 +202,7 @@ module Invidious::Database::Usersrequest = <<-SQLSELECT * FROM usersWHERE email = $1- SQL+ SQLreturn PG_DB.query_one(request, email, as: User)end@@ -211,7 +211,7 @@ module Invidious::Database::Usersrequest = <<-SQLSELECT * FROM usersWHERE token = $1- SQL+ SQLreturn PG_DB.query_one?(request, token, as: User)end@@ -221,7 +221,7 @@ module Invidious::Database::UsersSELECT notificationsFROM usersWHERE email = $1- SQL+ SQLreturn PG_DB.query_one(request, user.email, as: Array(String))enddiff --git a/src/invidious/database/videos.cr b/src/invidious/database/videos.crindex 695f5b33..40bafaf1 100644--- a/src/invidious/database/videos.cr+++ b/src/invidious/database/videos.cr@@ -8,7 +8,7 @@ module Invidious::Database::VideosINSERT INTO videosVALUES ($1, $2, $3)ON CONFLICT (id) DO NOTHING- SQL+ SQLPG_DB.exec(request, video.id, video.info.to_json, video.updated)end@@ -17,7 +17,7 @@ module Invidious::Database::Videosrequest = <<-SQLDELETE FROM videos *WHERE id = $1- SQL+ SQLPG_DB.exec(request, id)end@@ -26,7 +26,7 @@ module Invidious::Database::Videosrequest = <<-SQLDELETE FROM videos *WHERE updated < (now() - interval '6 hours')- SQL+ SQLPG_DB.exec(request)end@@ -36,7 +36,7 @@ module Invidious::Database::VideosUPDATE videosSET (id, info, updated) = ($1, $2, $3)WHERE id = $1- SQL+ SQLPG_DB.exec(request, video.id, video.info.to_json, video.updated)end@@ -45,7 +45,7 @@ module Invidious::Database::Videosrequest = <<-SQLSELECT * FROM videosWHERE id = $1- SQL+ SQLreturn PG_DB.query_one?(request, id, as: Video)enddiff --git a/src/invidious/frontend/comments_reddit.cr b/src/invidious/frontend/comments_reddit.crindex 74d9d8d8..6ecca531 100644--- a/src/invidious/frontend/comments_reddit.cr+++ b/src/invidious/frontend/comments_reddit.cr@@ -16,33 +16,33 @@ module Invidious::Frontend::Commentsif child.depth > 0html << <<-END_HTML- <div class="pure-g">- <div class="pure-u-1-24">- </div>- <div class="pure-u-23-24">- END_HTML+ <div class="pure-g">+ <div class="pure-u-1-24">+ </div>+ <div class="pure-u-23-24">+ END_HTMLelsehtml << <<-END_HTML- <div class="pure-g">- <div class="pure-u-1">- END_HTML+ <div class="pure-g">+ <div class="pure-u-1">+ END_HTMLendhtml << <<-END_HTML- <p>- <a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</a>- <b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>- #{I18n.translate_count(locale, "comments_points_count", child.score, I18n::NumberFormatting::Separator)}- <span title="#{child.created_utc.to_s("%a %B %-d %T %Y UTC")}">#{I18n.translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>- <a href="https://www.reddit.com#{child.permalink}" title="#{I18n.translate(locale, "permalink")}">#{I18n.translate(locale, "permalink")}</a>- </p>- <div>- #{body_html}- #{replies_html}- </div>- </div>- </div>- END_HTML+ <p>+ <a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</a>+ <b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>+ #{I18n.translate_count(locale, "comments_points_count", child.score, I18n::NumberFormatting::Separator)}+ <span title="#{child.created_utc.to_s("%a %B %-d %T %Y UTC")}">#{I18n.translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>+ <a href="https://www.reddit.com#{child.permalink}" title="#{I18n.translate(locale, "permalink")}">#{I18n.translate(locale, "permalink")}</a>+ </p>+ <div>+ #{body_html}+ #{replies_html}+ </div>+ </div>+ </div>+ END_HTMLendendenddiff --git a/src/invidious/frontend/comments_youtube.cr b/src/invidious/frontend/comments_youtube.crindex 809f0789..63fafa2d 100644--- a/src/invidious/frontend/comments_youtube.cr+++ b/src/invidious/frontend/comments_youtube.cr@@ -13,16 +13,16 @@ module Invidious::Frontend::Comments)replies_html = <<-END_HTML- <div id="replies" class="pure-g">- <div class="pure-u-1-24"></div>- <div class="pure-u-23-24">- <p>- <a href="javascript:void(0)" data-continuation="#{child["replies"]["continuation"]}"- data-onclick="get_youtube_replies" data-load-replies>#{replies_count_text}</a>- </p>+ <div id="replies" class="pure-g">+ <div class="pure-u-1-24"></div>+ <div class="pure-u-23-24">+ <p>+ <a href="javascript:void(0)" data-continuation="#{child["replies"]["continuation"]}"+ data-onclick="get_youtube_replies" data-load-replies>#{replies_count_text}</a>+ </p>+ </div></div>- </div>- END_HTML+ END_HTMLelsif comments["authorId"]? && !comments["singlePost"]?# for posts we should display a link to the postreplies_count_text = I18n.translate_count(locale,@@ -32,15 +32,15 @@ module Invidious::Frontend::Comments)replies_html = <<-END_HTML- <div class="pure-g">- <div class="pure-u-1-24"></div>- <div class="pure-u-23-24">- <p>- <a href="/post/#{child["commentId"]}?ucid=#{comments["authorId"]}">#{replies_count_text}</a>- </p>+ <div class="pure-g">+ <div class="pure-u-1-24"></div>+ <div class="pure-u-23-24">+ <p>+ <a href="/post/#{child["commentId"]}?ucid=#{comments["authorId"]}">#{replies_count_text}</a>+ </p>+ </div></div>- </div>- END_HTML+ END_HTMLendif !thin_mode@@ -70,18 +70,18 @@ module Invidious::Frontend::Commentsendendhtml << <<-END_HTML- <div class="pure-g" style="width:100%">- <div class="channel-profile pure-u-4-24 pure-u-md-2-24">- <img loading="lazy" style="margin-right:1em;margin-top:1em;width:90%" src="#{author_thumbnail}" alt="" />- </div>- <div class="pure-u-20-24 pure-u-md-22-24">- <p>- <b>- <a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>- </b>- #{sponsor_icon}- <p style="white-space:pre-wrap">#{child["contentHtml"]}</p>- END_HTML+ <div class="pure-g" style="width:100%">+ <div class="channel-profile pure-u-4-24 pure-u-md-2-24">+ <img loading="lazy" style="margin-right:1em;margin-top:1em;width:90%" src="#{author_thumbnail}" alt="" />+ </div>+ <div class="pure-u-20-24 pure-u-md-22-24">+ <p>+ <b>+ <a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>+ </b>+ #{sponsor_icon}+ <p style="white-space:pre-wrap">#{child["contentHtml"]}</p>+ END_HTMLif child["attachment"]?attachment = child["attachment"]@@ -91,25 +91,25 @@ module Invidious::Frontend::Commentsattachment = attachment["imageThumbnails"][1]html << <<-END_HTML- <div class="pure-g">- <div class="pure-u-1 pure-u-md-1-2">- <img loading="lazy" style="width:100%" src="/ggpht#{URI.parse(attachment["url"].as_s).request_target}" alt="" />+ <div class="pure-g">+ <div class="pure-u-1 pure-u-md-1-2">+ <img loading="lazy" style="width:100%" src="/ggpht#{URI.parse(attachment["url"].as_s).request_target}" alt="" />+ </div></div>- </div>- END_HTML+ END_HTMLwhen "video"if attachment["error"]?html << <<-END_HTML- <div class="pure-g video-iframe-wrapper">- <p>#{attachment["error"]}</p>- </div>- END_HTML+ <div class="pure-g video-iframe-wrapper">+ <p>#{attachment["error"]}</p>+ </div>+ END_HTMLelsehtml << <<-END_HTML- <div class="pure-g video-iframe-wrapper">- <iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>- </div>- END_HTML+ <div class="pure-g video-iframe-wrapper">+ <iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>+ </div>+ END_HTMLendwhen "multiImage"html << <<-END_HTML@@ -137,35 +137,34 @@ module Invidious::Frontend::CommentsEND_HTMLendhtml << <<-END_HTML- </div>- <div id="skip-#{child["commentId"]}"></div>- </section>- END_HTML- else nil # Ignore+ </div>+ <div id="skip-#{child["commentId"]}"></div>+ </section>+ END_HTMLendendhtml << <<-END_HTML- <p>- <span title="#{Time.unix(child["published"].as_i64).to_s(I18n.translate(locale, "%A %B %-d, %Y"))}">#{I18n.translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? I18n.translate(locale, "(edited)") : ""}</span>- |- END_HTML+ <p>+ <span title="#{Time.unix(child["published"].as_i64).to_s(I18n.translate(locale, "%A %B %-d, %Y"))}">#{I18n.translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? I18n.translate(locale, "(edited)") : ""}</span>+ |+ END_HTMLif comments["videoId"]?html << <<-END_HTML<a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{I18n.translate(locale, "YouTube comment permalink")}">[YT]</a>|- END_HTML+ END_HTMLelsif comments["authorId"]?html << <<-END_HTML<a rel="noreferrer noopener" href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}" title="#{I18n.translate(locale, "YouTube comment permalink")}">[YT]</a>|- END_HTML+ END_HTMLendhtml << <<-END_HTML<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}- END_HTML+ END_HTMLif child["creatorHeart"]?if !thin_mode@@ -184,28 +183,28 @@ module Invidious::Frontend::Comments</span></span></span>- END_HTML+ END_HTMLendhtml << <<-END_HTML- </p>- #{replies_html}+ </p>+ #{replies_html}+ </div></div>- </div>- END_HTML+ END_HTMLendif comments["continuation"]?html << <<-END_HTML- <div class="pure-g">- <div class="pure-u-1">- <p>- <a href="javascript:void(0)" data-continuation="#{comments["continuation"]}"- data-onclick="get_youtube_replies" data-load-more #{"data-load-replies" if is_replies}>#{I18n.translate(locale, "Load more")}</a>- </p>+ <div class="pure-g">+ <div class="pure-u-1">+ <p>+ <a href="javascript:void(0)" data-continuation="#{comments["continuation"]}"+ data-onclick="get_youtube_replies" data-load-more #{"data-load-replies" if is_replies}>#{I18n.translate(locale, "Load more")}</a>+ </p>+ </div></div>- </div>- END_HTML+ END_HTMLendendenddiff --git a/src/invidious/frontend/search_filters.cr b/src/invidious/frontend/search_filters.crindex f470470f..b50d7fcc 100644--- a/src/invidious/frontend/search_filters.cr+++ b/src/invidious/frontend/search_filters.cr@@ -41,11 +41,11 @@ module Invidious::Frontend::SearchFiltersstr << "\t\t\t\t<div class=\"filter-column\"><fieldset>\n"str << "\t\t\t\t\t<legend><div class=\"filter-name underlined\">"- str << I18n.translate(locale, "search_filters_{{name}}_label")+ str << I18n.translate(locale, "search_filters_{{ name }}_label")str << "</div></legend>\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</fieldset></div>\n"@@ -57,12 +57,12 @@ module Invidious::Frontend::SearchFilters{% date = value.underscore %}str << "\t\t\t\t\t\t<div>"- str << "<input type='radio' name='date' id='filter-date-{{date}}' value='{{date}}'"- str << " checked" if value.{{date}}?+ str << "<input type='radio' name='date' id='filter-date-{{ date }}' value='{{ date }}'"+ str << " checked" if value.{{ date }}?str << '>'- str << "<label for='filter-date-{{date}}'>"- str << I18n.translate(locale, "search_filters_date_option_{{date}}")+ str << "<label for='filter-date-{{ date }}'>"+ str << I18n.translate(locale, "search_filters_date_option_{{ date }}")str << "</label></div>\n"{% end %}end@@ -73,12 +73,12 @@ module Invidious::Frontend::SearchFilters{% type = value.underscore %}str << "\t\t\t\t\t\t<div>"- str << "<input type='radio' name='type' id='filter-type-{{type}}' value='{{type}}'"- str << " checked" if value.{{type}}?+ str << "<input type='radio' name='type' id='filter-type-{{ type }}' value='{{ type }}'"+ str << " checked" if value.{{ type }}?str << '>'- str << "<label for='filter-type-{{type}}'>"- str << I18n.translate(locale, "search_filters_type_option_{{type}}")+ str << "<label for='filter-type-{{ type }}'>"+ str << I18n.translate(locale, "search_filters_type_option_{{ type }}")str << "</label></div>\n"{% end %}end@@ -89,12 +89,12 @@ module Invidious::Frontend::SearchFilters{% duration = value.underscore %}str << "\t\t\t\t\t\t<div>"- str << "<input type='radio' name='duration' id='filter-duration-{{duration}}' value='{{duration}}'"- str << " checked" if value.{{duration}}?+ str << "<input type='radio' name='duration' id='filter-duration-{{ duration }}' value='{{ duration }}'"+ str << " checked" if value.{{ duration }}?str << '>'- str << "<label for='filter-duration-{{duration}}'>"- str << I18n.translate(locale, "search_filters_duration_option_{{duration}}")+ str << "<label for='filter-duration-{{ duration }}'>"+ str << I18n.translate(locale, "search_filters_duration_option_{{ duration }}")str << "</label></div>\n"{% end %}end@@ -106,12 +106,12 @@ module Invidious::Frontend::SearchFilters{% feature = value.underscore %}str << "\t\t\t\t\t\t<div>"- str << "<input type='checkbox' name='features' id='filter-feature-{{feature}}' value='{{feature}}'"- str << " checked" if value.{{feature}}?+ str << "<input type='checkbox' name='features' id='filter-feature-{{ feature }}' value='{{ feature }}'"+ str << " checked" if value.{{ feature }}?str << '>'- str << "<label for='filter-feature-{{feature}}'>"- str << I18n.translate(locale, "search_filters_features_option_{{feature}}")+ str << "<label for='filter-feature-{{ feature }}'>"+ str << I18n.translate(locale, "search_filters_features_option_{{ feature }}")str << "</label></div>\n"{% end %}{% end %}@@ -123,12 +123,12 @@ module Invidious::Frontend::SearchFilters{% sort = value.underscore %}str << "\t\t\t\t\t\t<div>"- str << "<input type='radio' name='sort' id='filter-sort-{{sort}}' value='{{sort}}'"- str << " checked" if value.{{sort}}?+ str << "<input type='radio' name='sort' id='filter-sort-{{ sort }}' value='{{ sort }}'"+ str << " checked" if value.{{ sort }}?str << '>'- str << "<label for='filter-sort-{{sort}}'>"- str << I18n.translate(locale, "search_filters_sort_option_{{sort}}")+ str << "<label for='filter-sort-{{ sort }}'>"+ str << I18n.translate(locale, "search_filters_sort_option_{{ sort }}")str << "</label></div>\n"{% end %}enddiff --git a/src/invidious/helpers/crystal_class_overrides.cr b/src/invidious/helpers/crystal_class_overrides.crindex 6fa89395..5e6d9cec 100644--- a/src/invidious/helpers/crystal_class_overrides.cr+++ b/src/invidious/helpers/crystal_class_overrides.cr@@ -68,7 +68,7 @@ class HTTP::Server::Responseclass Outputprivate def unbuffered_flush@io.flush- rescue ex : IO::Error+ rescue IO::Errorunbuffered_closeendenddiff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.crindex cee6eb2c..c24cb504 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 }})enddef github_details(summary : String, content : String)@@ -22,12 +22,12 @@ def get_issue_template(env : HTTP::Server::Context, exception : Exception) : Tupissue_title = "#{exception.message} (#{exception.class})"issue_template = <<-TEXT- Title: `#{HTML.escape(issue_title)}`- Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`- Route: `#{HTML.escape(env.request.resource)}`- Version: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`+ Title: `#{HTML.escape(issue_title)}`+ Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`+ Route: `#{HTML.escape(env.request.resource)}`+ Version: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`- TEXT+ TEXTissue_template += github_details("Backtrace", exception.inspect_with_backtrace)@@ -80,7 +80,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce<!-- TODO: Add a "copy to clipboard" button --><pre class="error-issue-template">#{issue_template}</pre></div>- END_HTML+ END_HTML# Don't show the usual "next steps" widget. The same options are# proposed above the error message, just worded differently.@@ -106,7 +106,7 @@ end# -------------------macro error_atom(*args)- error_atom_helper(env, {{args.splat}})+ error_atom_helper(env, {{ args.splat }})enddef error_atom_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception)@@ -132,14 +132,14 @@ end# -------------------macro error_json(*args)- error_json_helper(env, {{args.splat}})+ error_json_helper(env, {{ args.splat }})enddef error_json_helper(env : HTTP::Server::Context,status_code : Int32,exception : Exception,- additional_fields : Hash(String, Object) | Nil = nil,+ additional_fields : Hash(String, Object)? = nil,)if exception.is_a?(InfoException)return error_json_helper(env, status_code, exception.message || "", additional_fields)@@ -161,7 +161,7 @@ def error_json_helper(env : HTTP::Server::Context,status_code : Int32,message : String,- additional_fields : Hash(String, Object) | Nil = nil,+ additional_fields : Hash(String, Object)? = nil,)env.response.content_type = "application/json"env.response.status_code = status_code@@ -204,7 +204,7 @@ def error_redirect_helper(env : HTTP::Server::Context)<a rel="noreferrer noopener" href="https://www.youtube.com#{env.request.resource}">#{go_to_youtube}</a></li></ul>- END_HTML+ END_HTMLelsereturn ""enddiff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.crindex 8395c7a4..5e016046 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).newmacro 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 + pathendend@@ -20,8 +20,8 @@ module HTTP::Handlerendclass Kemal::RouteHandler- {% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}- exclude ["/api/v1/*"], {{method}}+ {% for method in %w[GET POST PUT HEAD DELETE PATCH OPTIONS] %}+ exclude ["/api/v1/*"], {{ method }}{% end %}# Processes the route if it's a match. Otherwise renders 404.@@ -44,8 +44,8 @@ class Kemal::RouteHandlerendclass Kemal::ExceptionHandler- {% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}- exclude ["/api/v1/*"], {{method}}+ {% for method in %w[GET POST PUT HEAD DELETE PATCH OPTIONS] %}+ exclude ["/api/v1/*"], {{ method }}{% end %}private def call_exception_with_status_code(context : HTTP::Server::Context, exception : Exception, status_code : Int32)@@ -72,8 +72,8 @@ class FilteredCompressHandler < HTTP::CompressHandlerendclass AuthHandler < Kemal::Handler- {% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}- only ["/api/v1/auth/*"], {{method}}+ {% for method in %w[GET POST PUT HEAD DELETE PATCH OPTIONS] %}+ only ["/api/v1/auth/*"], {{ method }}{% end %}def call(env)@@ -121,8 +121,8 @@ class AuthHandler < Kemal::Handlerendclass APIHandler < Kemal::Handler- {% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}- only ["/api/v1/*"], {{method}}+ {% for method in %w[GET POST PUT HEAD DELETE PATCH OPTIONS] %}+ only ["/api/v1/*"], {{ method }}{% end %}exclude ["/api/v1/auth/notifications"], "GET"exclude ["/api/v1/auth/notifications"], "POST"@@ -134,9 +134,9 @@ class APIHandler < Kemal::Handlerendclass DisableAbusableAPIHandler < Kemal::Handler- {% for method in %w(GET HEAD) %}+ {% for method in %w[GET HEAD] %}# This endpoints make a video request to Invidious companion.- {% for endpoint in %w(videos clips transcripts) %}+ {% for endpoint in %w[videos clips transcripts] %}only ["/api/v1/{{ endpoint.id }}/:id"], {{ method }}{% end %}{% end %}diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.crindex a08135ea..15fec92b 100644--- a/src/invidious/helpers/helpers.cr+++ b/src/invidious/helpers/helpers.cr@@ -93,7 +93,7 @@ module Helperssleep 1.minuteFiber.yieldend- rescue ex+ rescueendendend@@ -149,7 +149,7 @@ module Helpersid += 1end- rescue ex+ rescueensureconnection_channel.send({false, connection})end@@ -163,7 +163,7 @@ module Helpersenv.response.flushsleep (20 + rand(11)).secondsend- rescue ex+ rescueensureconnection_channel.send({false, connection})enddiff --git a/src/invidious/helpers/i18n.cr b/src/invidious/helpers/i18n.crindex 0388d1f6..ffbed92b 100644--- a/src/invidious/helpers/i18n.cr+++ b/src/invidious/helpers/i18n.cr@@ -103,7 +103,7 @@ module I18nreturn localesend- def translate(locale : String?, key : String, text : String | Hash(String, String) | Nil = nil) : String+ def translate(locale : String?, key : String, text : String? | Hash(String, String)? = nil) : String# Log a warning if "key" doesn't exist in en-US locale and return# that key as the text, so this is more or less transparent to the user.if !LOCALES["en-US"].has_key?(key)diff --git a/src/invidious/helpers/logger.cr b/src/invidious/helpers/logger.crindex 03349595..5b06612e 100644--- a/src/invidious/helpers/logger.cr+++ b/src/invidious/helpers/logger.cr@@ -55,10 +55,10 @@ class Invidious::LogHandler < Kemal::BaseLogHandlerendend- {% 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}})))+ {% 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 }})))endend{% end %}diff --git a/src/invidious/helpers/macros.cr b/src/invidious/helpers/macros.crindex 84847321..4e2f4bb2 100644--- a/src/invidious/helpers/macros.cr+++ b/src/invidious/helpers/macros.cr@@ -49,24 +49,24 @@ module JSON::Serializableendmacro 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 }}endmacro 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.closereturnenddiff --git a/src/invidious/helpers/tokens.cr b/src/invidious/helpers/tokens.crindex a44988cd..92686332 100644--- a/src/invidious/helpers/tokens.cr+++ b/src/invidious/helpers/tokens.cr@@ -116,7 +116,7 @@ def scope_includes_scope(scope, subset)subset_endpoint = subset_endpoint.downcaseif methods.empty?- methods = %w(GET POST PUT HEAD DELETE PATCH OPTIONS)+ methods = %w[GET POST PUT HEAD DELETE PATCH OPTIONS]endif methods & subset_methods != subset_methodsdiff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.crindex 6973a93f..d715500a 100644--- a/src/invidious/helpers/utils.cr+++ b/src/invidious/helpers/utils.cr@@ -102,7 +102,7 @@ def decode_date(string : String)# Try to parse as format Jul 10, 2000beginreturn Time.parse(string, "%b %-d, %Y", Time::Location.local)- rescue ex+ rescueendcase string@@ -110,7 +110,6 @@ def decode_date(string : String)return Time.utcwhen "yesterday"return Time.utc - 1.day- else nil # Continueend# String matches format "20 hours ago", "4 months ago", "20s ago", "15min ago"...@@ -177,7 +176,7 @@ def short_text_to_number(short_text : String) : Int64endreturn number.to_i64-rescue ex+rescuereturn 0_i64enddiff --git a/src/invidious/http_server/static_assets_handler.cr b/src/invidious/http_server/static_assets_handler.crindex 7902c95b..024b693d 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/jobs/instance_refresh_job.cr b/src/invidious/jobs/instance_refresh_job.crindex cb4280b9..44eb1d74 100644--- a/src/invidious/jobs/instance_refresh_job.cr+++ b/src/invidious/jobs/instance_refresh_job.cr@@ -69,7 +69,7 @@ class Invidious::Jobs::InstanceListRefreshJob < Invidious::Jobs::BaseJobraw_instance_list = JSON.parse(instance_api_client.get("/instances.json").body).as_ainstance_api_client.close- rescue ex : Socket::ConnectError | IO::TimeoutError | JSON::ParseException+ rescue Socket::ConnectError | IO::TimeoutError | JSON::ParseExceptionraw_instance_list = [] of JSON::Anyenddiff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.crindex e02e0617..c005b5fb 100644--- a/src/invidious/jsonify/api_v1/video_json.cr+++ b/src/invidious/jsonify/api_v1/video_json.cr@@ -138,7 +138,7 @@ module Invidious::JSONify::APIv1if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"])json.field "container", fmt_info["ext"]- json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"]+ json.field("encoding", fmt_info["vcodec"]? || fmt_info["acodec"])end# Livestream chunk infos@@ -198,8 +198,8 @@ module Invidious::JSONify::APIv1endif fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"])- json.field "container", fmt_info["ext"]- json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"]+ json.field("container", fmt_info["ext"])+ json.field("encoding", fmt_info["vcodec"]? || fmt_info["acodec"])endendenddiff --git a/src/invidious/mixes.cr b/src/invidious/mixes.crindex 7dd8a830..c9bbd615 100644--- a/src/invidious/mixes.cr+++ b/src/invidious/mixes.cr@@ -83,14 +83,14 @@ enddef template_mix(mix, listen)html = <<-END_HTML- <h3>- <a href="/mix?list=#{mix["mixId"]}">- #{mix["title"]}- </a>- </h3>- <div class="pure-menu pure-menu-scrollable playlist-restricted">- <ol class="pure-menu-list">- END_HTML+ <h3>+ <a href="/mix?list=#{mix["mixId"]}">+ #{mix["title"]}+ </a>+ </h3>+ <div class="pure-menu pure-menu-scrollable playlist-restricted">+ <ol class="pure-menu-list">+ END_HTMLmix["videos"].as_a.each do |video|html += <<-END_HTML@@ -106,14 +106,14 @@ def template_mix(mix, listen)</p></a></li>- END_HTML+ END_HTMLendhtml += <<-END_HTML- </ol>- </div>- <hr>- END_HTML+ </ol>+ </div>+ <hr>+ END_HTMLhtmlenddiff --git a/src/invidious/playlists.cr b/src/invidious/playlists.crindex e6a06633..2ff1e77c 100644--- a/src/invidious/playlists.cr+++ b/src/invidious/playlists.cr@@ -500,10 +500,10 @@ def extract_playlist_videos(playlist_id : String, initial_data : Hash(String, JS# Find the metadataParts with commandRuns inside, which contains author# information.- metadata_parts = metadata_rows.try &.find { |row|+ metadata_parts = metadata_rows.try &.find do |row|parts = row["metadataParts"]?.try &.as_aparts && parts.any? { |item2| item2.dig?("text", "commandRuns").try &.as_a }- }.try &.["metadataParts"].as_a+ end.try &.["metadataParts"].as_aif author_info = metadata_parts.try &.find(&.dig?("text", "commandRuns")).try &.["text"]@@ -543,14 +543,14 @@ enddef template_playlist(playlist, listen)html = <<-END_HTML- <h3>- <a href="/playlist?list=#{playlist["playlistId"]}">- #{playlist["title"]}- </a>- </h3>- <div class="pure-menu pure-menu-scrollable playlist-restricted">- <ol class="pure-menu-list">- END_HTML+ <h3>+ <a href="/playlist?list=#{playlist["playlistId"]}">+ #{playlist["title"]}+ </a>+ </h3>+ <div class="pure-menu pure-menu-scrollable playlist-restricted">+ <ol class="pure-menu-list">+ END_HTMLplaylist["videos"].as_a.each do |video|html += <<-END_HTML@@ -566,14 +566,14 @@ def template_playlist(playlist, listen)</p></a></li>- END_HTML+ END_HTMLendhtml += <<-END_HTML- </ol>- </div>- <hr>- END_HTML+ </ol>+ </div>+ <hr>+ END_HTMLhtmlenddiff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.crindex 88430029..e5a1348b 100644--- a/src/invidious/routes/api/manifest.cr+++ b/src/invidious/routes/api/manifest.cr@@ -19,9 +19,9 @@ module Invidious::Routes::API::Manifestbeginvideo = get_video(id, region: region)- rescue ex : NotFoundException+ rescue NotFoundExceptionhaltf env, status_code: 404- rescue ex+ rescuehaltf env, status_code: 403enddiff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.crindex da706a9e..11626a80 100644--- a/src/invidious/routes/api/v1/authenticated.cr+++ b/src/invidious/routes/api/v1/authenticated.cr@@ -42,11 +42,11 @@ module Invidious::Routes::API::V1::Authenticateduser = env.get("user").as(User)begin- if body = env.request.body- body = env.request.body.not_nil!.gets_to_end- else- body = "{}"- end+ body = if raw_body = env.request.body+ raw_body.gets_to_end+ else+ "{}"+ endInvidious::User::Import.from_invidious(user, body)rescueenddiff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.crindex 8c21fe19..9647db78 100644--- a/src/invidious/routes/api/v1/channels.cr+++ b/src/invidious/routes/api/v1/channels.cr@@ -31,7 +31,7 @@ module Invidious::Routes::API::V1::Channelsbeginplaylist = get_playlist(channel.ucid.sub("UC", "UULF"))videos = get_playlist_videos(playlist, offset: 0)- rescue ex : InfoException+ rescue InfoException# playlist doesnt exist.videos = [] of PlaylistVideoend@@ -118,7 +118,7 @@ module Invidious::Routes::API::V1::Channels# Fetch related channelsbeginrelated_channels, _ = fetch_related_channels(channel)- rescue ex+ rescuerelated_channels = [] of SearchChannelend@@ -157,7 +157,7 @@ module Invidious::Routes::API::V1::Channelsbeginplaylist = get_playlist(channel.ucid.sub("UC", "UULF"))videos = get_playlist_videos(playlist, offset: 0)- rescue ex : InfoException+ rescue InfoException# playlist doesnt exist.videos = [] of PlaylistVideoend@@ -203,7 +203,7 @@ module Invidious::Routes::API::V1::Channelsbeginplaylist = get_playlist(channel.ucid.sub("UC", "UUSH"))videos = get_playlist_videos(playlist, offset: 0)- rescue ex : InfoException+ rescue InfoException# playlist doesnt exist.videos = [] of PlaylistVideoend@@ -249,7 +249,7 @@ module Invidious::Routes::API::V1::Channelsbeginplaylist = get_playlist(channel.ucid.sub("UC", "UULV"))videos = get_playlist_videos(playlist, offset: 0)- rescue ex : InfoException+ rescue InfoException# playlist doesnt exist.videos = [] of PlaylistVideoenddiff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.crindex 4ae877a8..0da9dcf9 100644--- a/src/invidious/routes/api/v1/misc.cr+++ b/src/invidious/routes/api/v1/misc.cr@@ -53,7 +53,7 @@ module Invidious::Routes::API::V1::Miscplaylist = get_playlist(plid)rescue ex : InfoExceptionreturn error_json(404, ex)- rescue ex+ rescuereturn error_json(404, "Playlist does not exist.")enddiff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.crindex 14221ed0..cdf292fb 100644--- a/src/invidious/routes/api/v1/videos.cr+++ b/src/invidious/routes/api/v1/videos.cr@@ -47,9 +47,9 @@ module Invidious::Routes::API::V1::Videosbeginvideo = get_video(id, region: region)- rescue ex : NotFoundException+ rescue NotFoundExceptionhaltf env, 404- rescue ex+ rescuehaltf env, 500end@@ -187,9 +187,9 @@ module Invidious::Routes::API::V1::Videosbeginvideo = get_video(id, region: region)- rescue ex : NotFoundException+ rescue NotFoundExceptionhaltf env, 404- rescue ex+ rescuehaltf env, 500end@@ -265,8 +265,6 @@ module Invidious::Routes::API::V1::Videoshaltf env, 400end- annotations = ""-case sourcewhen "archive"if CONFIG.cache_annotations && (cached_annotation = Invidious::Database::Annotations.select(video_id))@@ -365,7 +363,7 @@ module Invidious::Routes::API::V1::Videosbegincomments, reddit_thread = Comments.fetch_reddit(id, sort_by: sort_by)- rescue ex+ rescuecomments = nilreddit_thread = nilenddiff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.crindex ff8b0f27..3c5131ed 100644--- a/src/invidious/routes/channels.cr+++ b/src/invidious/routes/channels.cr@@ -44,7 +44,7 @@ module Invidious::Routes::Channelsbeginplaylist = get_playlist(channel.ucid.sub("UC", "UULF"))items = get_playlist_videos(playlist, offset: 0)- rescue ex : InfoException+ rescue InfoException# playlist doesnt exist.items = [] of PlaylistVideoend@@ -79,7 +79,7 @@ module Invidious::Routes::Channelsbeginplaylist = get_playlist(channel.ucid.sub("UC", "UUSH"))items = get_playlist_videos(playlist, offset: 0)- rescue ex : InfoException+ rescue InfoException# playlist doesnt exist.items = [] of PlaylistVideoend@@ -114,7 +114,7 @@ module Invidious::Routes::Channelsbeginplaylist = get_playlist(channel.ucid.sub("UC", "UULV"))items = get_playlist_videos(playlist, offset: 0)- rescue ex : InfoException+ rescue InfoException# playlist doesnt exist.items = [] of PlaylistVideoend@@ -353,7 +353,7 @@ module Invidious::Routes::Channelsbeginresolved_url = YoutubeAPI.resolve_url("https://www.youtube.com#{env.request.path}#{yt_url_params.size > 0 ? "?#{yt_url_params}" : ""}")ucid = resolved_url["endpoint"]["browseEndpoint"]["browseId"]- rescue ex : InfoException | KeyError+ rescue InfoException | KeyErrorreturn error_template(404, I18n.translate(locale, "This channel does not exist."))enddiff --git a/src/invidious/routes/companion.cr b/src/invidious/routes/companion.crindex 811393ab..9236e8ab 100644--- a/src/invidious/routes/companion.cr+++ b/src/invidious/routes/companion.cr@@ -12,7 +12,7 @@ module Invidious::Routes::Companionreturn self.proxy_companion(env, resp)endend- rescue ex+ rescueendend@@ -29,7 +29,7 @@ module Invidious::Routes::Companionreturn self.proxy_companion(env, resp)endend- rescue ex+ rescueendend@@ -45,7 +45,7 @@ module Invidious::Routes::Companionreturn self.proxy_companion(env, resp)endend- rescue ex+ rescueendenddiff --git a/src/invidious/routes/embed.cr b/src/invidious/routes/embed.crindex 41dc517c..fd50609e 100644--- a/src/invidious/routes/embed.cr+++ b/src/invidious/routes/embed.cr@@ -119,7 +119,6 @@ module Invidious::Routes::Embedendreturn env.redirect url- else nil # Continueendparams = Invidious::Videos.process_video_params(env.params.query, preferences)@@ -182,14 +181,14 @@ module Invidious::Routes::Embedcaptions = video.captions- preferred_captions = captions.select { |caption|+ preferred_captions = captions.select do |caption|params.preferred_captions.includes?(caption.name) ||params.preferred_captions.includes?(caption.language_code.split("-")[0])- }- preferred_captions.sort_by! { |caption|+ end+ preferred_captions.sort_by! do |caption|(params.preferred_captions.index(caption.name) ||params.preferred_captions.index(caption.language_code.split("-")[0])).not_nil!- }+ endcaptions = captions - preferred_captionsaspect_ratio = nildiff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.crindex ebb5f04b..58972733 100644--- a/src/invidious/routes/feeds.cr+++ b/src/invidious/routes/feeds.cr@@ -327,7 +327,6 @@ module Invidious::Routes::Feedsrequest_target = URI.parse(node[attribute.name]).request_targetquery_string_opt = request_target.starts_with?("/watch?v=") ? ("&#{params}" if !params.empty?) : ""node[attribute.name] = "#{HOST_URL}#{request_target}#{query_string_opt}"- else nil # Skipendendenddiff --git a/src/invidious/routes/images.cr b/src/invidious/routes/images.crindex d76bcc58..5d8bdb82 100644--- a/src/invidious/routes/images.cr+++ b/src/invidious/routes/images.cr@@ -15,7 +15,7 @@ module Invidious::Routes::ImagesGGPHT_POOL.client &.get(url, headers) do |resp|return self.proxy_image(env, resp)end- rescue ex+ rescueendend@@ -46,7 +46,7 @@ module Invidious::Routes::Imagesenv.response.headers["Connection"] = "close"return self.proxy_image(env, resp)end- rescue ex+ rescueendend@@ -68,7 +68,7 @@ module Invidious::Routes::Imagesget_ytimg_pool(authority).client &.get(url, headers) do |resp|return self.proxy_image(env, resp)end- rescue ex+ rescueendend@@ -108,7 +108,7 @@ module Invidious::Routes::ImagesHelpers.proxy_file(response, env)end- rescue ex+ rescueendend@@ -140,7 +140,7 @@ module Invidious::Routes::Imagesget_ytimg_pool("i").client &.get(url, headers) do |resp|return self.proxy_image(env, resp)end- rescue ex+ rescueendenddiff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.crindex 7d7da487..21b43be8 100644--- a/src/invidious/routes/login.cr+++ b/src/invidious/routes/login.cr@@ -103,7 +103,7 @@ module Invidious::Routes::Loginbeginvalidate_request(tokens[0], answer, env.request, HMAC_KEY, locale)- rescue ex : InfoException+ rescue InfoExceptionreturn error_template(400, InfoException.new("Erroneous CAPTCHA"))rescue exreturn error_template(400, ex)diff --git a/src/invidious/routes/playlists.cr b/src/invidious/routes/playlists.crindex 3a633d50..c858f9f7 100644--- a/src/invidious/routes/playlists.cr+++ b/src/invidious/routes/playlists.cr@@ -164,7 +164,7 @@ module Invidious::Routes::Playlistsbeginitems = get_playlist_videos(playlist, offset: (page - 1) * 100)- rescue ex+ rescueitems = [] of PlaylistVideoend@@ -255,7 +255,7 @@ module Invidious::Routes::Playlistsbeginquery = Invidious::Search::Query.new(env.params.query, :playlist, region)items = query.process.select(SearchVideo).map(&.as(SearchVideo))- rescue ex+ rescueitems = [] of SearchVideoenddiff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.crindex 77ea02e9..c5de293d 100644--- a/src/invidious/routes/preferences.cr+++ b/src/invidious/routes/preferences.cr@@ -362,7 +362,6 @@ module Invidious::Routes::PreferencesRouteresponse: error_template(415, "Uploaded file is too large"))end- else nil # Ignoreendendenddiff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.crindex f7909c8e..d0d8042d 100644--- a/src/invidious/routes/video_playback.cr+++ b/src/invidious/routes/video_playback.cr@@ -115,7 +115,7 @@ module Invidious::Routes::VideoPlaybackIO.copy(resp.body_io, env.response)end- rescue ex+ rescueendelseif query_params["title"]? && CONFIG.disabled?("downloads") ||diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.crindex 4bca3753..c551ab21 100644--- a/src/invidious/routes/watch.cr+++ b/src/invidious/routes/watch.cr@@ -82,7 +82,7 @@ module Invidious::Routes::Watchif source == "youtube"begincomment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"]- rescue ex+ rescueif preferences.comments[1] == "reddit"comments, reddit_thread = Comments.fetch_reddit(id)comment_html = Frontend::Comments.template_reddit(comments, locale)@@ -98,7 +98,7 @@ module Invidious::Routes::Watchcomment_html = Comments.fill_links(comment_html, "https", "www.reddit.com")comment_html = Comments.replace_links(comment_html)- rescue ex+ rescueif preferences.comments[1] == "youtube"comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"]end@@ -143,14 +143,14 @@ module Invidious::Routes::Watchcaptions = video.captions- preferred_captions = captions.select { |caption|+ preferred_captions = captions.select do |caption|params.preferred_captions.includes?(caption.name) ||params.preferred_captions.includes?(caption.language_code.split("-")[0])- }- preferred_captions.sort_by! { |caption|+ end+ preferred_captions.sort_by! do |caption|(params.preferred_captions.index(caption.name) ||params.preferred_captions.index(caption.language_code.split("-")[0])).not_nil!- }+ endcaptions = captions - preferred_captionsaspect_ratio = "16:9"diff --git a/src/invidious/routing.cr b/src/invidious/routing.crindex 12bf5459..a44e5f38 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)endend@@ -241,91 +241,91 @@ module Invidious::Routingdef 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_tokenif 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, :notificationsend# 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 %}endenddiff --git a/src/invidious/search/processors.cr b/src/invidious/search/processors.crindex ecf9aeb3..0fc32363 100644--- a/src/invidious/search/processors.cr+++ b/src/invidious/search/processors.cr@@ -39,7 +39,7 @@ module Invidious::Searchdef subscriptions(query : Query, user : Invidious::User) : Array(ChannelVideo)view_name = "subscriptions_#{sha256(user.email)}"- return PG_DB.query_all("+ return PG_DB.query_all(<<-SQL,SELECT id,title,published,updated,ucid,author,length_secondsFROM (SELECT *,@@ -47,7 +47,8 @@ module Invidious::Searchto_tsvector(#{view_name}.author)as documentFROM #{view_name}- ) v_search WHERE v_search.document @@ plainto_tsquery($1) LIMIT 20 OFFSET $2;",+ ) v_search WHERE v_search.document @@ plainto_tsquery($1) LIMIT 20 OFFSET $2;+ SQLquery.text, (query.page - 1) * 20,as: ChannelVideo)diff --git a/src/invidious/trending.cr b/src/invidious/trending.crindex 622fe517..2f9d7335 100644--- a/src/invidious/trending.cr+++ b/src/invidious/trending.cr@@ -2,10 +2,10 @@ def fetch_trending(trending_type, region, locale)region ||= "US"region = region.upcase+ # 2026-10-12: plid is only used in line 47+ # so we can remove this later.plid = nil- browse_id = ""-case trending_type.try &.downcasewhen "gaming"browse_id = "UCOpNcN46UbXVtpKMrmU4Abg"diff --git a/src/invidious/user/captcha.cr b/src/invidious/user/captcha.crindex b175c3b9..e46105e0 100644--- a/src/invidious/user/captcha.cr+++ b/src/invidious/user/captcha.cr@@ -20,28 +20,28 @@ struct Invidious::Userendclock_svg = <<-END_SVG- <svg viewBox="0 0 100 100" width="200px" height="200px">- <circle cx="50" cy="50" r="45" fill="#eee" stroke="black" stroke-width="2"></circle>-- <text x="69" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 1</text>- <text x="82.909" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 2</text>- <text x="88" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 3</text>- <text x="82.909" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 4</text>- <text x="69" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 5</text>- <text x="50" y="91" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 6</text>- <text x="31" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 7</text>- <text x="17.091" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 8</text>- <text x="12" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 9</text>- <text x="17.091" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">10</text>- <text x="31" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">11</text>- <text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>-- <circle cx="50" cy="50" r="3" fill="black"></circle>- <line id="second" transform="rotate(#{second_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="12" fill="black" stroke="black" stroke-width="1"></line>- <line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>- <line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>- </svg>- END_SVG+ <svg viewBox="0 0 100 100" width="200px" height="200px">+ <circle cx="50" cy="50" r="45" fill="#eee" stroke="black" stroke-width="2"></circle>++ <text x="69" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 1</text>+ <text x="82.909" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 2</text>+ <text x="88" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 3</text>+ <text x="82.909" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 4</text>+ <text x="69" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 5</text>+ <text x="50" y="91" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 6</text>+ <text x="31" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 7</text>+ <text x="17.091" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 8</text>+ <text x="12" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 9</text>+ <text x="17.091" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">10</text>+ <text x="31" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">11</text>+ <text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>++ <circle cx="50" cy="50" r="3" fill="black"></circle>+ <line id="second" transform="rotate(#{second_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="12" fill="black" stroke="black" stroke-width="1"></line>+ <line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>+ <line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>+ </svg>+ END_SVGimage = "data:image/png;base64,"image += Process.run(%(rsvg-convert -w 400 -h 400 -b none -f png), shell: true,diff --git a/src/invidious/user/imports.cr b/src/invidious/user/imports.crindex 7c4101cc..c06c4ae9 100644--- a/src/invidious/user/imports.cr+++ b/src/invidious/user/imports.cr@@ -56,7 +56,7 @@ struct Invidious::Userbeginvideo = get_video(video_id)- rescue ex+ rescuenextend@@ -130,7 +130,7 @@ struct Invidious::Userbeginvideo = get_video(video_id, false)- rescue ex+ rescuenextenddiff --git a/src/invidious/user/preferences.cr b/src/invidious/user/preferences.crindex ad4a9bc7..1ac1c6dd 100644--- a/src/invidious/user/preferences.cr+++ b/src/invidious/user/preferences.cr@@ -73,7 +73,7 @@ struct Preferenceselseresultend- rescue ex+ rescueif value.read_bool"dark"else@@ -199,7 +199,7 @@ struct Preferencesvalue.read_array doresult << HTML.escape(value.read_string[0, 100])end- rescue ex+ rescueresult = [HTML.escape(value.read_string[0, 100]), ""]end@@ -228,7 +228,7 @@ struct Preferencesresult << HTML.escape(item.value[0, 100])end- rescue ex+ rescueif node.is_a?(YAML::Nodes::Scalar)result = [HTML.escape(node.value[0, 100]), ""]elsediff --git a/src/invidious/user/user.cr b/src/invidious/user/user.crindex a6d05fd1..a7aaf5df 100644--- a/src/invidious/user/user.cr+++ b/src/invidious/user/user.cr@@ -19,7 +19,7 @@ struct Invidious::Userdef self.from_rs(rs)beginPreferences.from_json(rs.read(String))- rescue ex+ rescuePreferences.from_json("{}")endenddiff --git a/src/invidious/users.cr b/src/invidious/users.crindex 65566d20..5158fc22 100644--- a/src/invidious/users.cr+++ b/src/invidious/users.cr@@ -45,7 +45,6 @@ def get_subscription_feed(user, max_results = 40, page = 1)notifications.sort_by!(&.author)when "channel name - reverse"notifications.sort_by!(&.author).reverse!- else nil # Ignoreendelseif user.preferences.latest_only@@ -94,7 +93,6 @@ def get_subscription_feed(user, max_results = 40, page = 1)videos.sort_by!(&.author)when "channel name - reverse"videos.sort_by!(&.author).reverse!- else nil # Ignoreendnotifications = Invidious::Database::Users.select_notifications(user)diff --git a/src/invidious/videos.cr b/src/invidious/videos.crindex ba947b2b..dfaab3d3 100644--- a/src/invidious/videos.cr+++ b/src/invidious/videos.cr@@ -48,7 +48,7 @@ struct Videoendend- def to_json(json : JSON::Builder | Nil = nil)+ def to_json(json : JSON::Builder? = nil)to_json(nil, json)end@@ -150,7 +150,7 @@ struct Videodef dash_manifest_url : String?raw_dash_url = info.dig?("streamingData", "dashManifestUrl").try &.as_s- return nil if raw_dash_url.nil?+ return if raw_dash_url.nil?# Use manifest v5 parameter to reduce file size# See https://github.com/iv-org/invidious/issues/4186@@ -183,14 +183,14 @@ struct Videoenddef music : Array(VideoMusic)- info["music"].as_a.map { |music_json|+ info["music"].as_a.map do |music_json|VideoMusic.new(music_json["song"].as_s,music_json["album"].as_s,music_json["artist"].as_s,music_json["license"].as_s)- }+ endend# Returns true if comments are enabled on the video@@ -201,37 +201,37 @@ struct Video# Macros defining getters/setters for various types of dataprivate 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 %}endprivate 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 Stringend- # 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 }}enddef \{{name.id.underscore}}=(value : Int)@@ -243,32 +243,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 || falseend- # 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 || falseend- # 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 abovediff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.crindex 8367fcd7..85c1acd8 100644--- a/src/invidious/videos/parser.cr+++ b/src/invidious/videos/parser.cr@@ -10,7 +10,7 @@ module Invidious::Videos::Parser# TODO: "compactRadioRenderer" (Mix) and# TODO: Use a proper struct/class instead of a hacky JSON objectdef parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?- return nil if !related["videoId"]?+ return if !related["videoId"]?# The compact renderer has video length in seconds, where the end# screen rendered has a full text version ("42:40")@@ -60,7 +60,7 @@ module Invidious::Videos::Parserplayer_response = YoutubeAPI.player(video_id: video_id)if player_response.nil?- return nil+ returnendplayability_status = player_response.dig?("playabilityStatus", "status").try &.as_s@@ -150,7 +150,7 @@ module Invidious::Videos::Parserelsif playability_status == "OK"return responseelse- return nil+ returnendenddiff --git a/src/invidious/views/user/login.ecr b/src/invidious/views/user/login.ecrindex 4324133a..064035cd 100644--- a/src/invidious/views/user/login.ecr+++ b/src/invidious/views/user/login.ecr@@ -25,8 +25,7 @@<% end %><% if captcha %>- <% captcha = captcha.not_nil! %>- <img style="width:50%" src='<%= captcha[:question] %>'/>+ <img src='<%= captcha[:question] %>' style="width:50%"/><% captcha[:tokens].each_with_index do |token, i| %><input type="hidden" name="token[<%= i %>]" value="<%= HTML.escape(token) %>"><% end %>diff --git a/src/invidious/yt_backend/connection_pool.cr b/src/invidious/yt_backend/connection_pool.crindex fb3da86c..2b22a1f2 100644--- a/src/invidious/yt_backend/connection_pool.cr+++ b/src/invidious/yt_backend/connection_pool.cr@@ -20,7 +20,7 @@ struct YoutubeConnectionPoolbeginresponse = yield conn- rescue ex+ rescueconn.closeconn = make_client(url, force_resolve: true)@@ -88,7 +88,7 @@ struct CompanionConnectionPoolbeginresponse = yield wrapper- rescue ex+ rescuewrapper.closecompanion = CONFIG.invidious_companion.samplediff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.crindex b2226e74..ac8757df 100644--- a/src/invidious/yt_backend/extractors.cr+++ b/src/invidious/yt_backend/extractors.cr@@ -40,8 +40,8 @@ private module Parsersbeginreturn 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)@@ -152,7 +152,6 @@ private module Parserswhen "Premium"# TODO: Potentially available as item_contents["topStandaloneBadge"]["metadataBadgeRenderer"]badges |= VideoBadges::Premium- else nil # Ignoreendend@@ -173,7 +172,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -240,7 +239,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -289,7 +288,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -334,7 +333,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -395,7 +394,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -467,7 +466,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -496,7 +495,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -527,7 +526,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -626,7 +625,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -655,6 +654,10 @@ private module Parsersthumbnail_view_model = item_contents.dig("contentImage", "thumbnailViewModel")+ # TODO: This is an useless assignment, is not used anywhere+ # so check if it can be used somewhere later.+ #+ # ameba:disable Lint/UselessAssignthumbnail = thumbnail_view_model.dig("image", "sources", 0, "url").as_svideo_id = item_contents["contentId"].as_s@@ -739,9 +742,9 @@ private module Parsersvideo_count = thumbnail_view_model.dig("overlays").as_a.compact_map(&.dig?("thumbnailOverlayBadgeViewModel", "thumbnailBadges").try &.as_a).flatten- .find(nil, &.dig?("thumbnailBadgeViewModel", "text").try { |node|+ .find(nil, &.dig?("thumbnailBadgeViewModel", "text").try do |node|{"episodes", "videos", "lessons"}.any? { |str| node.as_s.ends_with?(str) }- })+ end).try &.dig("thumbnailBadgeViewModel", "text").as_s.to_i(strict: false)metadata = item_contents.dig("metadata", "lockupMetadataViewModel")@@ -790,10 +793,10 @@ private module Parsers# ]#metadata_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a- metadata_parts = metadata_rows.try &.find { |row|+ metadata_parts = metadata_rows.try &.find do |row|parts = row["metadataParts"]?.try &.as_aparts && !parts.any? { |item| item.dig?("text", "content").try &.as_s == "View full playlist" }- }.try &.["metadataParts"].as_a+ end.try &.["metadataParts"].as_aif author_info = metadata_parts.try &.find(&.dig?("text", "commandRuns")).try &.["text"]@@ -831,7 +834,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -889,7 +892,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -918,7 +921,7 @@ private module Parsersenddef self.parser_name- return {{@type.name}}+ return {{ @type.name }}endendend@@ -1005,7 +1008,7 @@ private module Extractorsenddef self.extractor_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -1046,7 +1049,7 @@ private module Extractorsenddef self.extractor_name- return {{@type.name}}+ return {{ @type.name }}endend@@ -1080,7 +1083,7 @@ private module Extractorsenddef self.extractor_name- return {{@type.name}}+ return {{ @type.name }}endendenddiff --git a/src/invidious/yt_backend/extractors_utils.cr b/src/invidious/yt_backend/extractors_utils.crindex c83a2de5..3ee849d0 100644--- a/src/invidious/yt_backend/extractors_utils.cr+++ b/src/invidious/yt_backend/extractors_utils.cr@@ -17,15 +17,13 @@# another nil will be returned.def extract_text(item : JSON::Any?) : String?if item.nil?- return nil+ returnendif text_container = item["simpleText"]?return text_container.as_selsif text_container = item["runs"]?return text_container.as_a.map(&.["text"].as_s).join("")- else- nilendenddiff --git a/src/invidious/yt_backend/url_sanitizer.cr b/src/invidious/yt_backend/url_sanitizer.crindex d539dadb..856a18d6 100644--- a/src/invidious/yt_backend/url_sanitizer.cr+++ b/src/invidious/yt_backend/url_sanitizer.cr@@ -46,7 +46,7 @@ module UrlSanitizerwhen "results", "search"return :searchelse # hashtag, post, trending, brand URLs, etc..- return nil+ returnendenddiff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.crindex 6a38ded6..da89b379 100644--- a/src/invidious/yt_backend/youtube_api.cr+++ b/src/invidious/yt_backend/youtube_api.cr@@ -210,7 +210,7 @@ module YoutubeAPI# Region to provide to youtube, e.g to alter search results# (this is passed as the `gl` parameter).- property region : String | Nil+ property region : String?# Initialization functiondef initialize(@@ -286,7 +286,7 @@ module YoutubeAPI# Return, as a Hash, the "context" data required to request the# youtube API endpoints.#- private def make_context(client_config : ClientConfig | Nil, video_id = "dQw4w9WgXcQ") : Hash+ private def make_context(client_config : ClientConfig?, video_id = "dQw4w9WgXcQ") : Hash# Use the default client config if nil is passedclient_config ||= DEFAULT_CLIENT_CONFIG@@ -356,7 +356,7 @@ module YoutubeAPI## - A playlist ID (parameters MUST be an empty string)#- def browse(continuation : String, client_config : ClientConfig | Nil = nil)+ def browse(continuation : String, client_config : ClientConfig? = nil)# JSON Request data, required by the APIdata = {"context" => self.make_context(client_config),@@ -371,7 +371,7 @@ module YoutubeAPIbrowse_id : String,*, # Force the following parameters to be passed by nameparams : String,- client_config : ClientConfig | Nil = nil,+ client_config : ClientConfig? = nil,)# JSON Request data, required by the APIdata = {@@ -424,7 +424,7 @@ module YoutubeAPI# })# ```#- def next(continuation : String, *, client_config : ClientConfig | Nil = nil)+ def next(continuation : String, *, client_config : ClientConfig? = nil)# JSON Request data, required by the APIdata = {"context" => self.make_context(client_config),@@ -435,7 +435,7 @@ module YoutubeAPIend# :ditto:- def next(data : Hash, *, client_config : ClientConfig | Nil = nil)+ def next(data : Hash, *, client_config : ClientConfig? = nil)# JSON Request data, required by the APIdata2 = data.merge({"context" => self.make_context(client_config),@@ -445,7 +445,7 @@ module YoutubeAPIend# Allow a NamedTuple to be passed, too.- def next(data : NamedTuple, *, client_config : ClientConfig | Nil = nil)+ def next(data : NamedTuple, *, client_config : ClientConfig? = nil)return self.next(data.to_h, client_config: client_config)end@@ -466,7 +466,7 @@ module YoutubeAPIif CONFIG.invidious_companion.present?return self._post_invidious_companion("/youtubei/v1/player", data)else- return nil+ returnendend@@ -498,7 +498,7 @@ module YoutubeAPI# channel_b = YoutubeAPI.resolve_url("https://www.youtube.com/c/invalid")# ```#- def resolve_url(url : String, client_config : ClientConfig | Nil = nil)+ def resolve_url(url : String, client_config : ClientConfig? = nil)data = {"context" => self.make_context(nil),"url" => url,@@ -524,7 +524,7 @@ module YoutubeAPIdef search(search_query : String,params : String,- client_config : ClientConfig | Nil = nil,+ client_config : ClientConfig? = nil,)# JSON Request data, required by the APIdata = {@@ -550,7 +550,7 @@ module YoutubeAPIdef get_transcript(params : String,- client_config : ClientConfig | Nil = nil,+ client_config : ClientConfig? = nil,) : Hash(String, JSON::Any)data = {"context" => self.make_context(client_config),@@ -572,7 +572,7 @@ module YoutubeAPIdef _post_json(endpoint : String,data : Hash,- client_config : ClientConfig | Nil,+ client_config : ClientConfig?,) : Hash(String, JSON::Any)# Use the default client config if nil is passedclient_config ||= DEFAULT_CLIENT_CONFIG