Remove LOGGER statements

This commit is contained in:
broquemonsieur 2023-08-06 01:39:29 -07:00
parent f7fc05eb67
commit 0d968a320f
13 changed files with 35 additions and 72 deletions

View File

@ -111,11 +111,8 @@ function get_compilation(compid) {
compid_url = '/api/v1/compilations/' + compid + compid_url = '/api/v1/compilations/' + compid +
'?index=' + video_data.index + '?index=' + video_data.index +
'&continuation=' + video_data.id + '&continuation=' + video_data.id +
//'&t=' + video_data.video_data.starting_timestamp_seconds +
'&format=html&hl=' + video_data.preferences.locale; '&format=html&hl=' + video_data.preferences.locale;
console.log("Send "+compid_url);
helpers.xhr('GET', compid_url, {retries: 5, entity_name: 'compilation'}, { helpers.xhr('GET', compid_url, {retries: 5, entity_name: 'compilation'}, {
on200: function (response) { on200: function (response) {
compilation.innerHTML = response.compilationHtml; compilation.innerHTML = response.compilationHtml;

View File

@ -249,9 +249,7 @@ struct InvidiousCompilation
end end
def create_compilation(title, privacy, user) def create_compilation(title, privacy, user)
LOGGER.info("2. create_compilation")
compid = "IVCMP#{Random::Secure.urlsafe_base64(24)[0, 31]}" compid = "IVCMP#{Random::Secure.urlsafe_base64(24)[0, 31]}"
LOGGER.info("generated compilation id")
compilation = InvidiousCompilation.new({ compilation = InvidiousCompilation.new({
title: title.byte_slice(0, 150), title: title.byte_slice(0, 150),
@ -267,10 +265,8 @@ def create_compilation(title, privacy, user)
first_video_starting_timestamp_seconds: 0, first_video_starting_timestamp_seconds: 0,
first_video_ending_timestamp_seconds: 0 first_video_ending_timestamp_seconds: 0
}) })
LOGGER.info("Creating compilation db")
Invidious::Database::Compilations.insert(compilation) Invidious::Database::Compilations.insert(compilation)
LOGGER.info("inserted compilation db entry")
return compilation return compilation
end end
@ -332,14 +328,12 @@ def produce_compilation_continuation(id, index)
end end
def get_compilation(compid : String) def get_compilation(compid : String)
#if compid.starts_with? "IVCMP"
if compilation = Invidious::Database::Compilations.select(id: compid) if compilation = Invidious::Database::Compilations.select(id: compid)
update_first_video_params(compid) update_first_video_params(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
def update_first_video_params(compid : String) def update_first_video_params(compid : String)
@ -361,8 +355,6 @@ def update_first_video_params(compid : String)
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)
LOGGER.info("1. get_compilation")
LOGGER.info("Getting compilation")
# Show empty compilation if requested page is out of range # Show empty compilation if requested page is out of range
# (e.g, when a new compilation has been created, offset will be negative) # (e.g, when a new compilation has been created, offset will be negative)
if offset >= compilation.video_count || offset < 0 if offset >= compilation.video_count || offset < 0

View File

@ -80,7 +80,7 @@ module Invidious::Database::Compilations
PG_DB.exec(request, index, id) PG_DB.exec(request, index, id)
end end
def move_video_before(id : String, index : Array(Int64)) def move_video_position(id : String, index : Array(Int64))
request = <<-SQL request = <<-SQL
UPDATE compilations UPDATE compilations
SET index = $2 SET index = $2

View File

@ -240,8 +240,6 @@ struct InvidiousPlaylist
end end
def create_playlist(title, privacy, user) def create_playlist(title, privacy, user)
LOGGER.info("2. create_playlist")
LOGGER.info("create playlist inv/pl.cr")
plid = "IVPL#{Random::Secure.urlsafe_base64(24)[0, 31]}" plid = "IVPL#{Random::Secure.urlsafe_base64(24)[0, 31]}"
playlist = InvidiousPlaylist.new({ playlist = InvidiousPlaylist.new({
@ -315,7 +313,6 @@ def produce_playlist_continuation(id, index)
end end
def get_playlist(plid : String) def get_playlist(plid : String)
LOGGER.info("8. get_playlist")
if plid.starts_with? "IV" if plid.starts_with? "IV"
if playlist = Invidious::Database::Playlists.select(id: plid) if playlist = Invidious::Database::Playlists.select(id: plid)
return playlist return playlist
@ -404,8 +401,6 @@ def fetch_playlist(plid : String)
end end
def get_playlist_videos(playlist : InvidiousPlaylist | Playlist, offset : Int32, video_id = nil) def get_playlist_videos(playlist : InvidiousPlaylist | Playlist, offset : Int32, video_id = nil)
LOGGER.info("1. get_playlist_videos")
LOGGER.info("get_playlist_videos")
# Show empty playlist if requested page is out of range # Show empty playlist if requested page is out of range
# (e.g, when a new playlist has been created, offset will be negative) # (e.g, when a new playlist has been created, offset will be negative)
if offset >= playlist.video_count || offset < 0 if offset >= playlist.video_count || offset < 0

View File

@ -223,40 +223,32 @@ module Invidious::Routes::API::V1::Authenticated
end end
def self.create_compilation(env) def self.create_compilation(env)
LOGGER.info("creating comp in auth fashion")
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)
LOGGER.info("app json compilation")
title = env.params.json["title"]?.try &.as(String).delete("<>").byte_slice(0, 150) title = env.params.json["title"]?.try &.as(String).delete("<>").byte_slice(0, 150)
if !title if !title
return error_json(400, "Invalid title.") return error_json(400, "Invalid title.")
end end
LOGGER.info("set title")
privacy = env.params.json["privacy"]?.try { |p| CompilationPrivacy.parse(p.as(String).downcase) } privacy = env.params.json["privacy"]?.try { |p| CompilationPrivacy.parse(p.as(String).downcase) }
if !privacy if !privacy
return error_json(400, "Invalid privacy setting.") return error_json(400, "Invalid privacy setting.")
end end
LOGGER.info("set privacy")
if Invidious::Database::Compilations.count_owned_by(user.email) >= 100 if Invidious::Database::Compilations.count_owned_by(user.email) >= 100
return error_json(400, "User cannot have more than 100 compilations.") return error_json(400, "User cannot have more than 100 compilations.")
end end
LOGGER.info("400 forgone")
compilation = create_compilation(title, privacy, user) compilation = create_compilation(title, privacy, user)
env.response.headers["Location"] = "#{HOST_URL}/api/v1/auth/compilations/#{compilation.id}" env.response.headers["Location"] = "#{HOST_URL}/api/v1/auth/compilations/#{compilation.id}"
env.response.status_code = 201 env.response.status_code = 201
LOGGER.info("location set")
{ {
"title" => title, "title" => title,
"compilationId" => compilation.id, "compilationId" => compilation.id,
}.to_json }.to_json
LOGGER.info("Creating json")
end end
def self.create_playlist(env) def self.create_playlist(env)
LOGGER.info("7. create_playlist")
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)

View File

@ -11,10 +11,8 @@ module Invidious::Routes::API::V1::Misc
end end
def self.get_compilation(env : HTTP::Server::Context) def self.get_compilation(env : HTTP::Server::Context)
LOGGER.info("15. get_compilation")
env.response.content_type = "application/json" env.response.content_type = "application/json"
compid = env.params.url["compid"] compid = env.params.url["compid"]
LOGGER.info("the compid is #{compid}")
offset = env.params.query["index"]?.try &.to_i? offset = env.params.query["index"]?.try &.to_i?
offset ||= env.params.query["page"]?.try &.to_i?.try { |page| (page - 1) * 100 } offset ||= env.params.query["page"]?.try &.to_i?.try { |page| (page - 1) * 100 }
offset ||= 0 offset ||= 0

View File

@ -2,7 +2,6 @@
module Invidious::Routes::Compilations module Invidious::Routes::Compilations
def self.new(env) def self.new(env)
LOGGER.info("15. new")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
user = env.get? "user" user = env.get? "user"
@ -19,7 +18,6 @@ module Invidious::Routes::Compilations
end end
def self.create(env) def self.create(env)
LOGGER.info("3. create")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
user = env.get? "user" user = env.get? "user"
@ -198,7 +196,6 @@ module Invidious::Routes::Compilations
def self.adjust_timestamps(env) def self.adjust_timestamps(env)
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
LOGGER.info("Handle POST request for edit compilation")
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user") user = env.get("user")
sid = env.get? "sid" sid = env.get? "sid"
@ -274,7 +271,6 @@ module Invidious::Routes::Compilations
def self.add_compilation_items_page(env) def self.add_compilation_items_page(env)
LOGGER.info("13. add_compilation_items")
prefs = env.get("preferences").as(Preferences) prefs = env.get("preferences").as(Preferences)
locale = prefs.locale locale = prefs.locale
@ -321,7 +317,6 @@ module Invidious::Routes::Compilations
end end
def self.compilation_ajax(env) def self.compilation_ajax(env)
LOGGER.info("14. compilation_ajax")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
user = env.get? "user" user = env.get? "user"
@ -391,7 +386,6 @@ module Invidious::Routes::Compilations
case action case action
when "action_edit_compilation" when "action_edit_compilation"
# TODO: Compilation stub # TODO: Compilation stub
LOGGER.info("Begin handling of Compilation edit")
when "action_add_video" when "action_add_video"
if compilation.index.size >= CONFIG.compilation_length_limit if compilation.index.size >= CONFIG.compilation_length_limit
@ -441,10 +435,8 @@ module Invidious::Routes::Compilations
update_first_video_params(compilation_id) update_first_video_params(compilation_id)
when "action_move_video_before" when "action_move_video_before"
# TODO: Compilation stub # TODO: Compilation stub
#video_index = compilation.index
video_index = env.params.query["video_index"] video_index = env.params.query["video_index"]
begin begin
#video_index = get_video(video_index)
compilation_video = Invidious::Database::CompilationVideos.select_video(compilation_id, compilation.index, video_index, 0, 1) compilation_video = Invidious::Database::CompilationVideos.select_video(compilation_id, compilation.index, video_index, 0, 1)
compilation_index_array = compilation.index compilation_index_array = compilation.index
rescue ex : NotFoundException rescue ex : NotFoundException
@ -457,11 +449,32 @@ module Invidious::Routes::Compilations
end end
end end
compilation_index_array_position = compilation_index_array.index(compilation_video[0].index) compilation_index_array_position = compilation_index_array.index(compilation_video[0].index)
LOGGER.info("for #{compilation_index_array}, the item #{compilation_video[0].index} is a position #{compilation_index_array.index(compilation_video[0].index)}")
if !compilation_index_array_position.nil? if !compilation_index_array_position.nil?
compilation_index_array.delete_at(compilation_index_array_position) compilation_index_array.delete_at(compilation_index_array_position)
compilation_index_array.insert(compilation_index_array_position-1,compilation_video[0].index) compilation_index_array.insert(compilation_index_array_position-1,compilation_video[0].index)
Invidious::Database::Compilations.move_video_before(compilation_id, compilation_index_array) Invidious::Database::Compilations.move_video_position(compilation_id, compilation_index_array)
end
update_first_video_params(compilation_id)
when "action_move_video_after"
# TODO: Compilation stub
video_index = env.params.query["video_index"]
begin
compilation_video = Invidious::Database::CompilationVideos.select_video(compilation_id, compilation.index, video_index, 0, 1)
compilation_index_array = compilation.index
rescue ex : NotFoundException
return error_json(404, ex)
rescue ex
if redirect
return error_template(500, ex)
else
return error_json(500, ex)
end
end
compilation_index_array_position = compilation_index_array.index(compilation_video[0].index)
if !compilation_index_array_position.nil?
compilation_index_array.delete_at(compilation_index_array_position)
compilation_index_array.insert(compilation_index_array_position+1,compilation_video[0].index)
Invidious::Database::Compilations.move_video_position(compilation_id, compilation_index_array)
end end
update_first_video_params(compilation_id) update_first_video_params(compilation_id)
else else
@ -477,7 +490,6 @@ module Invidious::Routes::Compilations
end end
def self.show(env) def self.show(env)
LOGGER.info("4. show | comp")
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)

View File

@ -31,7 +31,6 @@ module Invidious::Routes::Embed
end end
def self.show(env) def self.show(env)
LOGGER.info("9? show")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
id = env.params.url["id"] id = env.params.url["id"]

View File

@ -10,7 +10,6 @@ module Invidious::Routes::Feeds
end end
def self.compilations(env) def self.compilations(env)
LOGGER.info("5. compilations")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
user = env.get? "user" user = env.get? "user"
@ -37,8 +36,6 @@ module Invidious::Routes::Feeds
end end
def self.playlists(env) def self.playlists(env)
LOGGER.info("5. playlists")
LOGGER.info("Generating the playlist items")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
user = env.get? "user" user = env.get? "user"

View File

@ -18,8 +18,6 @@ module Invidious::Routes::Playlists
end end
def self.create(env) def self.create(env)
LOGGER.info("3. create")
LOGGER.info("creating a play")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
user = env.get? "user" user = env.get? "user"
@ -398,7 +396,6 @@ module Invidious::Routes::Playlists
end end
def self.show(env) def self.show(env)
LOGGER.info("4. show")
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)

View File

@ -2,7 +2,6 @@
module Invidious::Routes::Watch module Invidious::Routes::Watch
def self.handle(env) def self.handle(env)
LOGGER.info("6. handle")
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale
region = env.params.query["region"]? region = env.params.query["region"]?
@ -230,7 +229,6 @@ module Invidious::Routes::Watch
end end
def self.redirect(env) def self.redirect(env)
LOGGER.info("10? redirect")
url = "/watch?v=#{env.params.url["id"]}" url = "/watch?v=#{env.params.url["id"]}"
if env.params.query.size > 0 if env.params.query.size > 0
url += "&#{env.params.query}" url += "&#{env.params.query}"
@ -304,7 +302,6 @@ module Invidious::Routes::Watch
end end
def self.clip(env) def self.clip(env)
LOGGER.info("11? clip")
clip_id = env.params.url["clip"]? clip_id = env.params.url["clip"]?
return error_template(400, "A clip ID is required") if !clip_id return error_template(400, "A clip ID is required") if !clip_id

View File

@ -9,28 +9,15 @@
<i class="icon ion-md-arrow-up"></i> <i class="icon ion-md-arrow-up"></i>
</button> </button>
</form> </form>
<%- form_parameters = "action_move_video_after=1&set_video_id=#{compilation_video.index}&compilation_id=#{compilation_video.compid}&referer=#{env.get("current_page")}" -%> <%- form_parameters = "action_move_video_after=1&video_index=#{compilation_video.index}&compilation_id=#{compilation_video.compid}" -%>
<form data-onsubmit="return_false" action="/compilation_ajax?<%= form_parameters %>" method="post"> <form action="/compilation_ajax?<%= form_parameters %>" method="post">
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>"> <input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<button type="submit" style="margin:10px" class="pure-button pure-button-secondary low-profile" <button type="submit" style="margin:10px" class="pure-button pure-button-secondary low-profile">
data-onclick="move_compilation_video_after" data-index="<%= compilation_video.index %>" data-compid="<%= compilation_video.compid %>">
<i class="icon ion-md-arrow-down"></i> <i class="icon ion-md-arrow-down"></i>
</button> </button>
</form> </form>
</div> </div>
<img loading="lazy" style="margin:10px;" src="/vi/<%= compilation_video.id %>/mqdefault.jpg" alt="" /> <img loading="lazy" style="margin:10px;" src="/vi/<%= compilation_video.id %>/mqdefault.jpg" alt="" />
<!-- <div class="compilation-video-thumbnail">
<img loading="lazy" style="margin:10px;" src="/vi/<%= compilation_video.id %>/mqdefault.jpg" alt="" />
<form data-onsubmit="return_false" action="/playlist_ajax?action_remove_video=1&set_video_id=<%= compilation_video.index %>&referer=<%= env.get("current_page") %>" method="post">
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<p class="watched">
<button type="submit" style="all:unset" data-onclick="remove_playlist_item" data-index="<%= compilation_video.index %>"><i class="icon ion-md-trash"></i></button>
</p>
</form>
<% if !compilation_video.responds_to?(:live_now) && compilation_video.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(compilation_video.length_seconds) %></p>
<% end %>
</div> -->
<div class="compilation-video-input-panel"> <div class="compilation-video-input-panel">
<div class="compilation-video-title"> <div class="compilation-video-title">
<span class="compilation-video-title" dir="auto"><%= HTML.escape(compilation_video.title) %></span> <span class="compilation-video-title" dir="auto"><%= HTML.escape(compilation_video.title) %></span>