mirror of https://github.com/iv-org/invidious.git
Remove compid check for Nil error debugging
This commit is contained in:
parent
8c15c1e8cc
commit
128d541323
|
@ -317,14 +317,13 @@ def produce_compilation_continuation(id, index)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_compilation(compid : String)
|
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)
|
if compilation = Invidious::Database::Compilations.select(id: compid)
|
||||||
return compilation
|
return compilation
|
||||||
else
|
else
|
||||||
raise NotFoundException.new("Compilation does not exist.")
|
raise NotFoundException.new("Compilation does not exist.")
|
||||||
end
|
end
|
||||||
end
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_compilation_videos(compilation : InvidiousCompilation | Compilation, offset : Int32, video_id = nil)
|
def get_compilation_videos(compilation : InvidiousCompilation | Compilation, offset : Int32, video_id = nil)
|
||||||
|
|
|
@ -81,7 +81,7 @@ module Invidious::Database::Compilations
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
# Salect
|
# Select
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
def select(*, id : String) : InvidiousCompilation?
|
def select(*, id : String) : InvidiousCompilation?
|
||||||
|
@ -103,7 +103,7 @@ module Invidious::Database::Compilations
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
# Salect (filtered)
|
# Select (filtered)
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
def select_like_iv(email : String) : Array(InvidiousCompilation)
|
def select_like_iv(email : String) : Array(InvidiousCompilation)
|
||||||
|
|
|
@ -91,7 +91,7 @@ module Invidious::Database::Playlists
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
# Salect
|
# Select
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
def select(*, id : String) : InvidiousPlaylist?
|
def select(*, id : String) : InvidiousPlaylist?
|
||||||
|
@ -113,7 +113,7 @@ module Invidious::Database::Playlists
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
# Salect (filtered)
|
# Select (filtered)
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
def select_like_iv(email : String) : Array(InvidiousPlaylist)
|
def select_like_iv(email : String) : Array(InvidiousPlaylist)
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
{% skip_file if flag?(:api_only) %}
|
{% skip_file if flag?(:api_only) %}
|
||||||
|
|
||||||
module Invidious::Routes::Compilations
|
module Invidious::Routes::Compilations
|
||||||
def self.handle(env)
|
|
||||||
return "<htm><body><p>Hello</p></body></html>"
|
|
||||||
end
|
|
||||||
def self.new(env)
|
def self.new(env)
|
||||||
LOGGER.info("15. new")
|
LOGGER.info("15. new")
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
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
|
if Invidious::Database::Compilations.count_owned_by(user.email) >= 100
|
||||||
return error_template(400, "User cannot have more than 100 compilations.")
|
return error_template(400, "User cannot have more than 100 compilations.")
|
||||||
end
|
end
|
||||||
LOGGER.info("creating a compilation")
|
|
||||||
# POST /create_compilation?referer=%2Ffeed%2Fcompilations 12.11ms
|
|
||||||
compilation = create_compilation(title, privacy, user)
|
compilation = create_compilation(title, privacy, user)
|
||||||
|
|
||||||
env.redirect "/compilation?list=#{compilation.id}"
|
env.redirect "/compilation?list=#{compilation.id}"
|
||||||
|
@ -370,26 +366,20 @@ module Invidious::Routes::Compilations
|
||||||
LOGGER.info("4. show | comp")
|
LOGGER.info("4. show | comp")
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
LOGGER.info("set locale")
|
|
||||||
user = env.get?("user").try &.as(User)
|
user = env.get?("user").try &.as(User)
|
||||||
LOGGER.info("got user")
|
|
||||||
referer = get_referer(env)
|
referer = get_referer(env)
|
||||||
LOGGER.info("got referer")
|
|
||||||
|
|
||||||
compid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
compid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
||||||
LOGGER.info("got compid comp")
|
|
||||||
if !compid
|
if !compid
|
||||||
return env.redirect "/"
|
return env.redirect "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?.try &.to_i?
|
||||||
page ||= 1
|
page ||= 1
|
||||||
LOGGER.info("set page")
|
|
||||||
|
|
||||||
if compid.starts_with? "RD"
|
if compid.starts_with? "RD"
|
||||||
return env.redirect "/mix?list=#{compid}"
|
return env.redirect "/mix?list=#{compid}"
|
||||||
end
|
end
|
||||||
LOGGER.info("RD comp")
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
compilation = get_compilation(compid)
|
compilation = get_compilation(compid)
|
||||||
|
@ -398,33 +388,27 @@ module Invidious::Routes::Compilations
|
||||||
rescue ex
|
rescue ex
|
||||||
return error_template(500, ex)
|
return error_template(500, ex)
|
||||||
end
|
end
|
||||||
LOGGER.info("got 200 comp")
|
|
||||||
|
|
||||||
page_count = (compilation.video_count / 200).to_i
|
page_count = (compilation.video_count / 200).to_i
|
||||||
page_count += 1 if (compilation.video_count % 200) > 0
|
page_count += 1 if (compilation.video_count % 200) > 0
|
||||||
LOGGER.info("set page count")
|
|
||||||
|
|
||||||
if page > page_count
|
if page > page_count
|
||||||
return env.redirect "/compilation?list=#{compid}&page=#{page_count}"
|
return env.redirect "/compilation?list=#{compid}&page=#{page_count}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if compilation.privacy == CompilationPrivacy::Private && compilation.author != user.try &.email
|
if compilation.privacy == CompilationPrivacy::Private && compilation.author != user.try &.email
|
||||||
return error_template(403, "This compilation is private.")
|
return error_template(403, "This compilation is private.")
|
||||||
end
|
end
|
||||||
LOGGER.info("set privacy")
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
videos = get_compilation_videos(compilation, offset: (page - 1) * 200)
|
videos = get_compilation_videos(compilation, offset: (page - 1) * 200)
|
||||||
rescue ex
|
rescue ex
|
||||||
return error_template(500, "Error encountered while retrieving compilation videos.<br>#{ex.message}")
|
return error_template(500, "Error encountered while retrieving compilation videos.<br>#{ex.message}")
|
||||||
end
|
end
|
||||||
LOGGER.info("set offset")
|
|
||||||
|
|
||||||
if compilation.author == user.try &.email
|
if compilation.author == user.try &.email
|
||||||
env.set "remove_compilation_items", compid
|
env.set "remove_compilation_items", compid
|
||||||
end
|
end
|
||||||
LOGGER.info("showing author")
|
|
||||||
|
|
||||||
templated "compilation"
|
templated "compilation"
|
||||||
end
|
end
|
||||||
|
|
|
@ -399,7 +399,6 @@ module Invidious::Routes::Playlists
|
||||||
|
|
||||||
def self.show(env)
|
def self.show(env)
|
||||||
LOGGER.info("4. show")
|
LOGGER.info("4. show")
|
||||||
LOGGER.info("showing a play")
|
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
user = env.get?("user").try &.as(User)
|
user = env.get?("user").try &.as(User)
|
||||||
|
|
Loading…
Reference in New Issue