mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-02 11:41:08 +05:30
Remove LOGGER statements
This commit is contained in:
parent
f7fc05eb67
commit
0d968a320f
@ -111,11 +111,8 @@ function get_compilation(compid) {
|
||||
compid_url = '/api/v1/compilations/' + compid +
|
||||
'?index=' + video_data.index +
|
||||
'&continuation=' + video_data.id +
|
||||
//'&t=' + video_data.video_data.starting_timestamp_seconds +
|
||||
'&format=html&hl=' + video_data.preferences.locale;
|
||||
|
||||
console.log("Send "+compid_url);
|
||||
|
||||
helpers.xhr('GET', compid_url, {retries: 5, entity_name: 'compilation'}, {
|
||||
on200: function (response) {
|
||||
compilation.innerHTML = response.compilationHtml;
|
||||
|
@ -249,9 +249,7 @@ struct InvidiousCompilation
|
||||
end
|
||||
|
||||
def create_compilation(title, privacy, user)
|
||||
LOGGER.info("2. create_compilation")
|
||||
compid = "IVCMP#{Random::Secure.urlsafe_base64(24)[0, 31]}"
|
||||
LOGGER.info("generated compilation id")
|
||||
|
||||
compilation = InvidiousCompilation.new({
|
||||
title: title.byte_slice(0, 150),
|
||||
@ -267,10 +265,8 @@ def create_compilation(title, privacy, user)
|
||||
first_video_starting_timestamp_seconds: 0,
|
||||
first_video_ending_timestamp_seconds: 0
|
||||
})
|
||||
LOGGER.info("Creating compilation db")
|
||||
|
||||
Invidious::Database::Compilations.insert(compilation)
|
||||
LOGGER.info("inserted compilation db entry")
|
||||
|
||||
return compilation
|
||||
end
|
||||
@ -332,14 +328,12 @@ def produce_compilation_continuation(id, index)
|
||||
end
|
||||
|
||||
def get_compilation(compid : String)
|
||||
#if compid.starts_with? "IVCMP"
|
||||
if compilation = Invidious::Database::Compilations.select(id: compid)
|
||||
update_first_video_params(compid)
|
||||
return compilation
|
||||
else
|
||||
raise NotFoundException.new("Compilation does not exist.")
|
||||
end
|
||||
#end
|
||||
if compilation = Invidious::Database::Compilations.select(id: compid)
|
||||
update_first_video_params(compid)
|
||||
return compilation
|
||||
else
|
||||
raise NotFoundException.new("Compilation does not exist.")
|
||||
end
|
||||
end
|
||||
|
||||
def update_first_video_params(compid : String)
|
||||
@ -361,8 +355,6 @@ def update_first_video_params(compid : String)
|
||||
end
|
||||
|
||||
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
|
||||
# (e.g, when a new compilation has been created, offset will be negative)
|
||||
if offset >= compilation.video_count || offset < 0
|
||||
|
@ -80,7 +80,7 @@ module Invidious::Database::Compilations
|
||||
PG_DB.exec(request, index, id)
|
||||
end
|
||||
|
||||
def move_video_before(id : String, index : Array(Int64))
|
||||
def move_video_position(id : String, index : Array(Int64))
|
||||
request = <<-SQL
|
||||
UPDATE compilations
|
||||
SET index = $2
|
||||
|
@ -240,8 +240,6 @@ struct InvidiousPlaylist
|
||||
end
|
||||
|
||||
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]}"
|
||||
|
||||
playlist = InvidiousPlaylist.new({
|
||||
@ -315,7 +313,6 @@ def produce_playlist_continuation(id, index)
|
||||
end
|
||||
|
||||
def get_playlist(plid : String)
|
||||
LOGGER.info("8. get_playlist")
|
||||
if plid.starts_with? "IV"
|
||||
if playlist = Invidious::Database::Playlists.select(id: plid)
|
||||
return playlist
|
||||
@ -404,8 +401,6 @@ def fetch_playlist(plid : String)
|
||||
end
|
||||
|
||||
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
|
||||
# (e.g, when a new playlist has been created, offset will be negative)
|
||||
if offset >= playlist.video_count || offset < 0
|
||||
|
@ -223,40 +223,32 @@ module Invidious::Routes::API::V1::Authenticated
|
||||
end
|
||||
|
||||
def self.create_compilation(env)
|
||||
LOGGER.info("creating comp in auth fashion")
|
||||
env.response.content_type = "application/json"
|
||||
user = env.get("user").as(User)
|
||||
LOGGER.info("app json compilation")
|
||||
|
||||
title = env.params.json["title"]?.try &.as(String).delete("<>").byte_slice(0, 150)
|
||||
if !title
|
||||
return error_json(400, "Invalid title.")
|
||||
end
|
||||
LOGGER.info("set title")
|
||||
privacy = env.params.json["privacy"]?.try { |p| CompilationPrivacy.parse(p.as(String).downcase) }
|
||||
if !privacy
|
||||
return error_json(400, "Invalid privacy setting.")
|
||||
end
|
||||
LOGGER.info("set privacy")
|
||||
|
||||
if Invidious::Database::Compilations.count_owned_by(user.email) >= 100
|
||||
return error_json(400, "User cannot have more than 100 compilations.")
|
||||
end
|
||||
LOGGER.info("400 forgone")
|
||||
|
||||
compilation = create_compilation(title, privacy, user)
|
||||
env.response.headers["Location"] = "#{HOST_URL}/api/v1/auth/compilations/#{compilation.id}"
|
||||
env.response.status_code = 201
|
||||
LOGGER.info("location set")
|
||||
{
|
||||
"title" => title,
|
||||
"compilationId" => compilation.id,
|
||||
}.to_json
|
||||
LOGGER.info("Creating json")
|
||||
end
|
||||
|
||||
def self.create_playlist(env)
|
||||
LOGGER.info("7. create_playlist")
|
||||
env.response.content_type = "application/json"
|
||||
user = env.get("user").as(User)
|
||||
|
||||
|
@ -11,10 +11,8 @@ module Invidious::Routes::API::V1::Misc
|
||||
end
|
||||
|
||||
def self.get_compilation(env : HTTP::Server::Context)
|
||||
LOGGER.info("15. get_compilation")
|
||||
env.response.content_type = "application/json"
|
||||
compid = env.params.url["compid"]
|
||||
LOGGER.info("the compid is #{compid}")
|
||||
offset = env.params.query["index"]?.try &.to_i?
|
||||
offset ||= env.params.query["page"]?.try &.to_i?.try { |page| (page - 1) * 100 }
|
||||
offset ||= 0
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
module Invidious::Routes::Compilations
|
||||
def self.new(env)
|
||||
LOGGER.info("15. new")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get? "user"
|
||||
@ -19,7 +18,6 @@ module Invidious::Routes::Compilations
|
||||
end
|
||||
|
||||
def self.create(env)
|
||||
LOGGER.info("3. create")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get? "user"
|
||||
@ -198,7 +196,6 @@ module Invidious::Routes::Compilations
|
||||
|
||||
def self.adjust_timestamps(env)
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
LOGGER.info("Handle POST request for edit compilation")
|
||||
env.response.content_type = "application/json"
|
||||
user = env.get("user")
|
||||
sid = env.get? "sid"
|
||||
@ -274,7 +271,6 @@ module Invidious::Routes::Compilations
|
||||
|
||||
|
||||
def self.add_compilation_items_page(env)
|
||||
LOGGER.info("13. add_compilation_items")
|
||||
prefs = env.get("preferences").as(Preferences)
|
||||
locale = prefs.locale
|
||||
|
||||
@ -321,7 +317,6 @@ module Invidious::Routes::Compilations
|
||||
end
|
||||
|
||||
def self.compilation_ajax(env)
|
||||
LOGGER.info("14. compilation_ajax")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get? "user"
|
||||
@ -391,7 +386,6 @@ module Invidious::Routes::Compilations
|
||||
case action
|
||||
when "action_edit_compilation"
|
||||
# TODO: Compilation stub
|
||||
LOGGER.info("Begin handling of Compilation edit")
|
||||
|
||||
when "action_add_video"
|
||||
if compilation.index.size >= CONFIG.compilation_length_limit
|
||||
@ -441,10 +435,8 @@ module Invidious::Routes::Compilations
|
||||
update_first_video_params(compilation_id)
|
||||
when "action_move_video_before"
|
||||
# TODO: Compilation stub
|
||||
#video_index = compilation.index
|
||||
video_index = env.params.query["video_index"]
|
||||
begin
|
||||
#video_index = get_video(video_index)
|
||||
compilation_video = Invidious::Database::CompilationVideos.select_video(compilation_id, compilation.index, video_index, 0, 1)
|
||||
compilation_index_array = compilation.index
|
||||
rescue ex : NotFoundException
|
||||
@ -457,11 +449,32 @@ module Invidious::Routes::Compilations
|
||||
end
|
||||
end
|
||||
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?
|
||||
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_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
|
||||
update_first_video_params(compilation_id)
|
||||
else
|
||||
@ -477,7 +490,6 @@ module Invidious::Routes::Compilations
|
||||
end
|
||||
|
||||
def self.show(env)
|
||||
LOGGER.info("4. show | comp")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get?("user").try &.as(User)
|
||||
|
@ -31,7 +31,6 @@ module Invidious::Routes::Embed
|
||||
end
|
||||
|
||||
def self.show(env)
|
||||
LOGGER.info("9? show")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
id = env.params.url["id"]
|
||||
|
||||
|
@ -10,7 +10,6 @@ module Invidious::Routes::Feeds
|
||||
end
|
||||
|
||||
def self.compilations(env)
|
||||
LOGGER.info("5. compilations")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get? "user"
|
||||
@ -37,8 +36,6 @@ module Invidious::Routes::Feeds
|
||||
end
|
||||
|
||||
def self.playlists(env)
|
||||
LOGGER.info("5. playlists")
|
||||
LOGGER.info("Generating the playlist items")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get? "user"
|
||||
|
@ -18,8 +18,6 @@ module Invidious::Routes::Playlists
|
||||
end
|
||||
|
||||
def self.create(env)
|
||||
LOGGER.info("3. create")
|
||||
LOGGER.info("creating a play")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get? "user"
|
||||
@ -398,7 +396,6 @@ module Invidious::Routes::Playlists
|
||||
end
|
||||
|
||||
def self.show(env)
|
||||
LOGGER.info("4. show")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
user = env.get?("user").try &.as(User)
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
module Invidious::Routes::Watch
|
||||
def self.handle(env)
|
||||
LOGGER.info("6. handle")
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
region = env.params.query["region"]?
|
||||
|
||||
@ -230,7 +229,6 @@ module Invidious::Routes::Watch
|
||||
end
|
||||
|
||||
def self.redirect(env)
|
||||
LOGGER.info("10? redirect")
|
||||
url = "/watch?v=#{env.params.url["id"]}"
|
||||
if env.params.query.size > 0
|
||||
url += "&#{env.params.query}"
|
||||
@ -304,7 +302,6 @@ module Invidious::Routes::Watch
|
||||
end
|
||||
|
||||
def self.clip(env)
|
||||
LOGGER.info("11? clip")
|
||||
clip_id = env.params.url["clip"]?
|
||||
|
||||
return error_template(400, "A clip ID is required") if !clip_id
|
||||
|
@ -9,28 +9,15 @@
|
||||
<i class="icon ion-md-arrow-up"></i>
|
||||
</button>
|
||||
</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 data-onsubmit="return_false" action="/compilation_ajax?<%= form_parameters %>" method="post">
|
||||
<%- form_parameters = "action_move_video_after=1&video_index=#{compilation_video.index}&compilation_id=#{compilation_video.compid}" -%>
|
||||
<form action="/compilation_ajax?<%= form_parameters %>" method="post">
|
||||
<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"
|
||||
data-onclick="move_compilation_video_after" data-index="<%= compilation_video.index %>" data-compid="<%= compilation_video.compid %>">
|
||||
<button type="submit" style="margin:10px" class="pure-button pure-button-secondary low-profile">
|
||||
<i class="icon ion-md-arrow-down"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<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-title">
|
||||
<span class="compilation-video-title" dir="auto"><%= HTML.escape(compilation_video.title) %></span>
|
||||
|
Loading…
Reference in New Issue
Block a user