mirror of https://github.com/iv-org/invidious.git
Run Crystal formatting tool
This commit is contained in:
parent
205c5493db
commit
93ac7cdeb4
|
@ -19,7 +19,7 @@ struct CompilationVideo
|
|||
xml.element("yt:videoId") { xml.text self.id }
|
||||
xml.element("yt:channelId") { xml.text self.ucid }
|
||||
xml.element("title") { xml.text self.title }
|
||||
xml.element("orderIndex") {xml.text self.order_index }
|
||||
xml.element("orderIndex") { xml.text self.order_index }
|
||||
xml.element("link", rel: "alternate", href: "#{HOST_URL}/watch?v=#{self.id}")
|
||||
|
||||
xml.element("author") do
|
||||
|
@ -263,7 +263,7 @@ def create_compilation(title, privacy, user)
|
|||
index: [] of Int64,
|
||||
first_video_id: "",
|
||||
first_video_starting_timestamp_seconds: 0,
|
||||
first_video_ending_timestamp_seconds: 0
|
||||
first_video_ending_timestamp_seconds: 0,
|
||||
})
|
||||
|
||||
Invidious::Database::Compilations.insert(compilation)
|
||||
|
@ -273,18 +273,18 @@ end
|
|||
|
||||
def subscribe_compilation(user, compilation)
|
||||
compilation = InvidiousCompilation.new({
|
||||
title: compilation.title.byte_slice(0, 150),
|
||||
id: compilation.id,
|
||||
author: user.email,
|
||||
description: "", # Max 5000 characters
|
||||
video_count: compilation.video_count,
|
||||
created: Time.utc,
|
||||
updated: compilation.updated,
|
||||
privacy: CompilationPrivacy::Private,
|
||||
index: [] of Int64,
|
||||
first_video_id: "",
|
||||
title: compilation.title.byte_slice(0, 150),
|
||||
id: compilation.id,
|
||||
author: user.email,
|
||||
description: "", # Max 5000 characters
|
||||
video_count: compilation.video_count,
|
||||
created: Time.utc,
|
||||
updated: compilation.updated,
|
||||
privacy: CompilationPrivacy::Private,
|
||||
index: [] of Int64,
|
||||
first_video_id: "",
|
||||
first_video_starting_timestamp_seconds: 0,
|
||||
first_video_ending_timestamp_seconds: 0
|
||||
first_video_ending_timestamp_seconds: 0,
|
||||
})
|
||||
|
||||
Invidious::Database::Compilations.insert(compilation)
|
||||
|
@ -345,8 +345,8 @@ def update_first_video_params(compid : String)
|
|||
if !first_id.nil?
|
||||
timestamps = Invidious::Database::CompilationVideos.select_timestamps(compid, first_id)
|
||||
if (!timestamps.nil?)
|
||||
starting_timestamp_seconds=timestamps[0]
|
||||
ending_timestamp_seconds=timestamps[1]
|
||||
starting_timestamp_seconds = timestamps[0]
|
||||
ending_timestamp_seconds = timestamps[1]
|
||||
Invidious::Database::Compilations.update_first_video_params(compid, first_id, starting_timestamp_seconds, ending_timestamp_seconds)
|
||||
end
|
||||
end
|
||||
|
@ -368,7 +368,7 @@ def get_compilation_videos(compilation : InvidiousCompilation | Compilation, off
|
|||
else
|
||||
if video_id
|
||||
initial_data = YoutubeAPI.next({
|
||||
"videoId" => video_id,
|
||||
"videoId" => video_id,
|
||||
"compilationId" => compilation.id,
|
||||
})
|
||||
offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "compilation", "compilation", "currentIndex").try &.as_i || offset
|
||||
|
@ -441,7 +441,7 @@ def extract_compilation_videos(initial_data : Hash(String, JSON::Any))
|
|||
published: Time.utc,
|
||||
compid: compid,
|
||||
index: index,
|
||||
order_index: order_index
|
||||
order_index: order_index,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -101,6 +101,7 @@ module Invidious::Database::Compilations
|
|||
|
||||
PG_DB.exec(request, id, first_video_id, starting_timestamp_seconds, ending_timestamp_seconds)
|
||||
end
|
||||
|
||||
# -------------------
|
||||
# Select
|
||||
# -------------------
|
||||
|
@ -261,15 +262,13 @@ module Invidious::Database::CompilationVideos
|
|||
end
|
||||
|
||||
def select_timestamps(compid : String, vid : String)
|
||||
|
||||
request = <<-SQL
|
||||
SELECT starting_timestamp_seconds,ending_timestamp_seconds FROM compilation_videos
|
||||
WHERE compid = $1 AND id = $2
|
||||
LIMIT 1
|
||||
SQL
|
||||
|
||||
return PG_DB.query_one?(request, compid, vid, as: {Int32,Int32})
|
||||
|
||||
return PG_DB.query_one?(request, compid, vid, as: {Int32, Int32})
|
||||
end
|
||||
|
||||
def select_id_from_order_index(order_index : Int32)
|
||||
|
|
|
@ -243,7 +243,7 @@ module Invidious::Routes::API::V1::Authenticated
|
|||
env.response.headers["Location"] = "#{HOST_URL}/api/v1/auth/compilations/#{compilation.id}"
|
||||
env.response.status_code = 201
|
||||
{
|
||||
"title" => title,
|
||||
"title" => title,
|
||||
"compilationId" => compilation.id,
|
||||
}.to_json
|
||||
end
|
||||
|
|
|
@ -68,15 +68,14 @@ module Invidious::Routes::API::V1::Misc
|
|||
|
||||
response = {
|
||||
"compilationHtml" => compilation_html,
|
||||
"index" => index,
|
||||
"nextVideo" => next_video,
|
||||
"index" => index,
|
||||
"nextVideo" => next_video,
|
||||
}.to_json
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
|
||||
# APIv1 currently uses the same logic for both
|
||||
# user playlists and Invidious playlists. This means that we can't
|
||||
# reasonably split them yet. This should be addressed in APIv2
|
||||
|
|
|
@ -218,7 +218,6 @@ module Invidious::Routes::Compilations
|
|||
return error_template(400, ex)
|
||||
end
|
||||
|
||||
|
||||
if !compid || compid.empty?
|
||||
return error_json(400, "A compilation ID is required")
|
||||
end
|
||||
|
@ -261,7 +260,6 @@ module Invidious::Routes::Compilations
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
update_first_video_params(compid)
|
||||
|
@ -269,7 +267,6 @@ module Invidious::Routes::Compilations
|
|||
env.redirect "/compilation?list=#{compid}"
|
||||
end
|
||||
|
||||
|
||||
def self.add_compilation_items_page(env)
|
||||
prefs = env.get("preferences").as(Preferences)
|
||||
locale = prefs.locale
|
||||
|
@ -326,7 +323,7 @@ module Invidious::Routes::Compilations
|
|||
redirect = env.params.query["redirect"]?
|
||||
redirect ||= "true"
|
||||
redirect = redirect == "true"
|
||||
if !user
|
||||
if !user
|
||||
if redirect
|
||||
return env.redirect referer
|
||||
else
|
||||
|
@ -422,7 +419,7 @@ module Invidious::Routes::Compilations
|
|||
compid: compilation_id,
|
||||
live_now: video.live_now,
|
||||
index: Random::Secure.rand(0_i64..Int64::MAX),
|
||||
order_index: compilation.index.size
|
||||
order_index: compilation.index.size,
|
||||
})
|
||||
|
||||
Invidious::Database::CompilationVideos.insert(compilation_video)
|
||||
|
@ -451,7 +448,7 @@ module Invidious::Routes::Compilations
|
|||
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)
|
||||
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)
|
||||
|
@ -473,7 +470,11 @@ module Invidious::Routes::Compilations
|
|||
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)
|
||||
if (compilation_index_array_position == compilation_index_array.size)
|
||||
compilation_index_array.insert(compilation_index_array_position, compilation_video[0].index)
|
||||
else
|
||||
compilation_index_array.insert(compilation_index_array_position + 1, compilation_video[0].index)
|
||||
end
|
||||
Invidious::Database::Compilations.move_video_position(compilation_id, compilation_index_array)
|
||||
end
|
||||
update_first_video_params(compilation_id)
|
||||
|
|
|
@ -44,22 +44,22 @@ module Invidious::Routes::Watch
|
|||
elsif env.params.query["list"]?.try &.starts_with? "IVCMP"
|
||||
compid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
||||
if (!compid.nil?)
|
||||
index=Invidious::Database::CompilationVideos.select_index(compid,id)
|
||||
indices_array=Invidious::Database::Compilations.select_index_array(compid)
|
||||
index = Invidious::Database::CompilationVideos.select_index(compid, id)
|
||||
indices_array = Invidious::Database::Compilations.select_index_array(compid)
|
||||
if (!indices_array.nil?)
|
||||
position_of_index=indices_array.index(index)
|
||||
position_of_index = indices_array.index(index)
|
||||
if (!position_of_index.nil? && position_of_index != indices_array.size - 1)
|
||||
next_index=indices_array[position_of_index+1]
|
||||
next_index = indices_array[position_of_index + 1]
|
||||
else
|
||||
next_index=indices_array[0]
|
||||
next_index = indices_array[0]
|
||||
end
|
||||
if (!next_index.nil?)
|
||||
next_id=Invidious::Database::CompilationVideos.select_id_from_index(next_index)
|
||||
next_id = Invidious::Database::CompilationVideos.select_id_from_index(next_index)
|
||||
if (!next_id.nil?)
|
||||
timestamps = Invidious::Database::CompilationVideos.select_timestamps(compid, next_id)
|
||||
if (!timestamps.nil?)
|
||||
starting_timestamp_seconds=timestamps[0]
|
||||
ending_timestamp_seconds=timestamps[1]
|
||||
starting_timestamp_seconds = timestamps[0]
|
||||
ending_timestamp_seconds = timestamps[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue