mirror of https://github.com/iv-org/invidious.git
Add end marker continuation utility
This commit is contained in:
parent
510d85c045
commit
f48083da33
|
@ -209,8 +209,13 @@ if (video_data.params.video_start > 0 || video_data.params.video_end > 0) {
|
|||
|
||||
player.markers({
|
||||
onMarkerReached: function (marker) {
|
||||
if (marker.text === 'End')
|
||||
player.loop() ? player.markers.prev('Start') : player.pause();
|
||||
if (marker.text === 'End') {
|
||||
if (video_data.ending_timestamp_seconds) {
|
||||
player.currentTime(player.duration());
|
||||
} else {
|
||||
player.loop() ? player.markers.prev('Start') : player.pause();
|
||||
}
|
||||
}
|
||||
},
|
||||
markers: markers
|
||||
});
|
||||
|
|
|
@ -140,6 +140,7 @@ function get_compilation(compid) {
|
|||
if (video_data.params.local !== video_data.preferences.local)
|
||||
url.searchParams.set('local', video_data.params.local);
|
||||
url.searchParams.set('t',video_data.starting_timestamp_seconds);
|
||||
url.searchParams.set('end',video_data.ending_timestamp_seconds);
|
||||
|
||||
location.assign(url.pathname + url.search);
|
||||
});
|
||||
|
|
|
@ -23,7 +23,9 @@ CREATE TABLE IF NOT EXISTS public.compilations
|
|||
updated timestamptz,
|
||||
privacy compilation_privacy,
|
||||
index int8[],
|
||||
first_video_id text
|
||||
first_video_id text,
|
||||
first_video_starting_timestamp_seconds integer,
|
||||
first_video_ending_timestamp_seconds integer
|
||||
);
|
||||
|
||||
GRANT ALL ON public.compilations TO current_user;
|
||||
|
|
|
@ -96,6 +96,8 @@ struct Compilation
|
|||
property updated : Time
|
||||
property thumbnail : String?
|
||||
property first_video_id : String
|
||||
property first_video_starting_timestamp_seconds : Int32
|
||||
property first_video_ending_timestamp_seconds : Int32
|
||||
|
||||
def to_json(offset, json : JSON::Builder, video_id : String? = nil)
|
||||
json.object do
|
||||
|
@ -171,6 +173,8 @@ struct InvidiousCompilation
|
|||
property privacy : CompilationPrivacy = CompilationPrivacy::Private
|
||||
property index : Array(Int64)
|
||||
property first_video_id : String
|
||||
property first_video_starting_timestamp_seconds : Int32
|
||||
property first_video_ending_timestamp_seconds : Int32
|
||||
|
||||
@[DB::Field(ignore: true)]
|
||||
property thumbnail_id : String?
|
||||
|
@ -250,16 +254,18 @@ def create_compilation(title, privacy, user)
|
|||
LOGGER.info("generated compilation id")
|
||||
|
||||
compilation = InvidiousCompilation.new({
|
||||
title: title.byte_slice(0, 150),
|
||||
id: compid,
|
||||
author: user.email,
|
||||
description: "", # Max 5000 characters
|
||||
video_count: 0,
|
||||
created: Time.utc,
|
||||
updated: Time.utc,
|
||||
privacy: privacy,
|
||||
index: [] of Int64,
|
||||
first_video_id: ""
|
||||
title: title.byte_slice(0, 150),
|
||||
id: compid,
|
||||
author: user.email,
|
||||
description: "", # Max 5000 characters
|
||||
video_count: 0,
|
||||
created: Time.utc,
|
||||
updated: Time.utc,
|
||||
privacy: privacy,
|
||||
index: [] of Int64,
|
||||
first_video_id: "",
|
||||
first_video_starting_timestamp_seconds: 0,
|
||||
first_video_ending_timestamp_seconds: 0
|
||||
})
|
||||
LOGGER.info("Creating compilation db")
|
||||
|
||||
|
@ -280,7 +286,9 @@ def subscribe_compilation(user, compilation)
|
|||
updated: compilation.updated,
|
||||
privacy: CompilationPrivacy::Private,
|
||||
index: [] of Int64,
|
||||
first_video_id: ""
|
||||
first_video_id: "",
|
||||
first_video_starting_timestamp_seconds: 0,
|
||||
first_video_ending_timestamp_seconds: 0
|
||||
})
|
||||
|
||||
Invidious::Database::Compilations.insert(compilation)
|
||||
|
@ -326,6 +334,7 @@ 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.")
|
||||
|
@ -333,13 +342,18 @@ def get_compilation(compid : String)
|
|||
#end
|
||||
end
|
||||
|
||||
def update_first_video_id(compid : String)
|
||||
def update_first_video_params(compid : String)
|
||||
if compilation = Invidious::Database::Compilations.select(id: compid)
|
||||
compilation_index_array = compilation.index
|
||||
first_index = compilation_index_array[0]
|
||||
first_id = Invidious::Database::CompilationVideos.select_id_from_index(first_index)
|
||||
if !first_id.nil?
|
||||
Invidious::Database::Compilations.update_first_video_id(compid, first_id)
|
||||
timestamps = Invidious::Database::CompilationVideos.select_timestamps(compid, first_id)
|
||||
if (!timestamps.nil?)
|
||||
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
|
||||
else
|
||||
raise NotFoundException.new("Compilation does not exist.")
|
||||
|
|
|
@ -90,14 +90,16 @@ module Invidious::Database::Compilations
|
|||
PG_DB.exec(request, id, index)
|
||||
end
|
||||
|
||||
def update_first_video_id(id : String, first_video_id : String)
|
||||
def update_first_video_params(id : String, first_video_id : String, starting_timestamp_seconds : Int32, ending_timestamp_seconds : Int32)
|
||||
request = <<-SQL
|
||||
UPDATE compilations
|
||||
SET first_video_id = $2
|
||||
SET first_video_id = $2,
|
||||
first_video_starting_timestamp_seconds = $3,
|
||||
first_video_ending_timestamp_seconds = $4
|
||||
WHERE id = $1
|
||||
SQL
|
||||
|
||||
PG_DB.exec(request, id, first_video_id)
|
||||
PG_DB.exec(request, id, first_video_id, starting_timestamp_seconds, ending_timestamp_seconds)
|
||||
end
|
||||
# -------------------
|
||||
# Select
|
||||
|
|
|
@ -25,7 +25,9 @@ module Invidious::Database::Migrations
|
|||
updated timestamptz,
|
||||
privacy compilation_privacy,
|
||||
index int8[],
|
||||
first_video_id text
|
||||
first_video_id text,
|
||||
first_video_starting_timestamp_seconds integer,
|
||||
first_video_ending_timestamp_seconds integer
|
||||
);
|
||||
SQL
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ module Invidious::Routes::Compilations
|
|||
end
|
||||
compilation_video = Invidious::Database::CompilationVideos.select_video(compid, compilation.index, compilation_video_index, 0, 1)
|
||||
json_timestamp_query_end = compilation_video_index.to_s + "_end_timestamp"
|
||||
end_timestamp = env.params.json[json_timestamp_query_end]?.try &.as(String).byte_slice(0, 8)
|
||||
end_timestamp = env.params.body[json_timestamp_query_end]?.try &.as(String).byte_slice(0, 8)
|
||||
if !end_timestamp.nil? && !compilation_video[0].id.nil?
|
||||
end_timestamp_seconds = decode_length_seconds(end_timestamp)
|
||||
if !end_timestamp_seconds.nil?
|
||||
|
@ -267,6 +267,8 @@ module Invidious::Routes::Compilations
|
|||
|
||||
end
|
||||
|
||||
update_first_video_params(compid)
|
||||
|
||||
env.redirect "/compilation?list=#{compid}"
|
||||
end
|
||||
|
||||
|
@ -431,12 +433,12 @@ module Invidious::Routes::Compilations
|
|||
|
||||
Invidious::Database::CompilationVideos.insert(compilation_video)
|
||||
Invidious::Database::Compilations.update_video_added(compilation_id, compilation_video.index)
|
||||
update_first_video_id(compilation_id)
|
||||
update_first_video_params(compilation_id)
|
||||
when "action_remove_video"
|
||||
index = env.params.query["set_video_id"]
|
||||
Invidious::Database::CompilationVideos.delete(index)
|
||||
Invidious::Database::Compilations.update_video_removed(compilation_id, index)
|
||||
update_first_video_id(compilation_id)
|
||||
update_first_video_params(compilation_id)
|
||||
when "action_move_video_before"
|
||||
# TODO: Compilation stub
|
||||
#video_index = compilation.index
|
||||
|
@ -461,7 +463,7 @@ module Invidious::Routes::Compilations
|
|||
compilation_index_array.insert(compilation_index_array_position-1,compilation_video[0].index)
|
||||
Invidious::Database::Compilations.move_video_before(compilation_id, compilation_index_array)
|
||||
end
|
||||
update_first_video_id(compilation_id)
|
||||
update_first_video_params(compilation_id)
|
||||
else
|
||||
return error_json(400, "Unsupported action #{action}")
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<%- if compilation.is_a?(InvidiousCompilation) && compilation.author == user.try &.email -%>
|
||||
<%- if compilation.index.size > 0 -%>
|
||||
<div class="pure-u">
|
||||
<a class="pure-button pure-button-secondary low-profile" dir="auto" href="/watch?v=<%= compilation.first_video_id %>&list=<%= compid %>&index=<%= compilation.index[0] %>">
|
||||
<a class="pure-button pure-button-secondary low-profile" dir="auto" href="/watch?v=<%= compilation.first_video_id %>&list=<%= compid %>&index=<%= compilation.index[0] %>&t=<%= compilation.first_video_starting_timestamp_seconds %>&end=<%= compilation.first_video_ending_timestamp_seconds %>">
|
||||
<i class="icon ion-md-play"></i> <%= translate(locale, "compilation_button_play") %>
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue