From 128d54132352dff5bbf0401cb5b30aca81100c93 Mon Sep 17 00:00:00 2001 From: broquemonsieur Date: Thu, 29 Jun 2023 20:36:11 -0700 Subject: [PATCH] Remove compid check for Nil error debugging --- src/invidious/compilations.cr | 5 ++--- src/invidious/database/compilations.cr | 4 ++-- src/invidious/database/playlists.cr | 4 ++-- src/invidious/routes/compilations.cr | 18 +----------------- src/invidious/routes/playlists.cr | 1 - 5 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/invidious/compilations.cr b/src/invidious/compilations.cr index 8e9ee21b..b75622f3 100644 --- a/src/invidious/compilations.cr +++ b/src/invidious/compilations.cr @@ -317,14 +317,13 @@ def produce_compilation_continuation(id, index) end def get_compilation(compid : String) - LOGGER.info("8. get_compilation") - if compid.starts_with? "IV" + #if compid.starts_with? "IV" if compilation = Invidious::Database::Compilations.select(id: compid) return compilation else raise NotFoundException.new("Compilation does not exist.") end - end + #end end def get_compilation_videos(compilation : InvidiousCompilation | Compilation, offset : Int32, video_id = nil) diff --git a/src/invidious/database/compilations.cr b/src/invidious/database/compilations.cr index f0306364..a3372ac7 100644 --- a/src/invidious/database/compilations.cr +++ b/src/invidious/database/compilations.cr @@ -81,7 +81,7 @@ module Invidious::Database::Compilations end # ------------------- - # Salect + # Select # ------------------- def select(*, id : String) : InvidiousCompilation? @@ -103,7 +103,7 @@ module Invidious::Database::Compilations end # ------------------- - # Salect (filtered) + # Select (filtered) # ------------------- def select_like_iv(email : String) : Array(InvidiousCompilation) diff --git a/src/invidious/database/playlists.cr b/src/invidious/database/playlists.cr index a51deab6..2fed2d95 100644 --- a/src/invidious/database/playlists.cr +++ b/src/invidious/database/playlists.cr @@ -91,7 +91,7 @@ module Invidious::Database::Playlists end # ------------------- - # Salect + # Select # ------------------- def select(*, id : String) : InvidiousPlaylist? @@ -113,7 +113,7 @@ module Invidious::Database::Playlists end # ------------------- - # Salect (filtered) + # Select (filtered) # ------------------- def select_like_iv(email : String) : Array(InvidiousPlaylist) diff --git a/src/invidious/routes/compilations.cr b/src/invidious/routes/compilations.cr index 5a0dd726..eb459e98 100644 --- a/src/invidious/routes/compilations.cr +++ b/src/invidious/routes/compilations.cr @@ -1,9 +1,6 @@ {% skip_file if flag?(:api_only) %} module Invidious::Routes::Compilations - def self.handle(env) - return "

Hello

" - end def self.new(env) LOGGER.info("15. new") locale = env.get("preferences").as(Preferences).locale @@ -54,8 +51,7 @@ module Invidious::Routes::Compilations if Invidious::Database::Compilations.count_owned_by(user.email) >= 100 return error_template(400, "User cannot have more than 100 compilations.") end - LOGGER.info("creating a compilation") - # POST /create_compilation?referer=%2Ffeed%2Fcompilations 12.11ms + compilation = create_compilation(title, privacy, user) env.redirect "/compilation?list=#{compilation.id}" @@ -370,26 +366,20 @@ module Invidious::Routes::Compilations LOGGER.info("4. show | comp") locale = env.get("preferences").as(Preferences).locale - LOGGER.info("set locale") user = env.get?("user").try &.as(User) - LOGGER.info("got user") referer = get_referer(env) - LOGGER.info("got referer") compid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "") - LOGGER.info("got compid comp") if !compid return env.redirect "/" end page = env.params.query["page"]?.try &.to_i? page ||= 1 - LOGGER.info("set page") if compid.starts_with? "RD" return env.redirect "/mix?list=#{compid}" end - LOGGER.info("RD comp") begin compilation = get_compilation(compid) @@ -398,33 +388,27 @@ module Invidious::Routes::Compilations rescue ex return error_template(500, ex) end - LOGGER.info("got 200 comp") page_count = (compilation.video_count / 200).to_i page_count += 1 if (compilation.video_count % 200) > 0 - LOGGER.info("set page count") if page > page_count return env.redirect "/compilation?list=#{compid}&page=#{page_count}" end - if compilation.privacy == CompilationPrivacy::Private && compilation.author != user.try &.email return error_template(403, "This compilation is private.") end - LOGGER.info("set privacy") begin videos = get_compilation_videos(compilation, offset: (page - 1) * 200) rescue ex return error_template(500, "Error encountered while retrieving compilation videos.
#{ex.message}") end - LOGGER.info("set offset") if compilation.author == user.try &.email env.set "remove_compilation_items", compid end - LOGGER.info("showing author") templated "compilation" end diff --git a/src/invidious/routes/playlists.cr b/src/invidious/routes/playlists.cr index dc06d364..240c7583 100644 --- a/src/invidious/routes/playlists.cr +++ b/src/invidious/routes/playlists.cr @@ -399,7 +399,6 @@ module Invidious::Routes::Playlists def self.show(env) LOGGER.info("4. show") - LOGGER.info("showing a play") locale = env.get("preferences").as(Preferences).locale user = env.get?("user").try &.as(User)