diff --git a/config/sql/compilation_videos.sql b/config/sql/compilation_videos.sql index 91eb886c..aae5e8a1 100644 --- a/config/sql/compilation_videos.sql +++ b/config/sql/compilation_videos.sql @@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS public.compilation_videos published timestamptz, compid text references compilations(id), index int8, + order_index integer, PRIMARY KEY (index,compid) ); diff --git a/src/invidious/compilations.cr b/src/invidious/compilations.cr index b75622f3..e87a1a7a 100644 --- a/src/invidious/compilations.cr +++ b/src/invidious/compilations.cr @@ -11,6 +11,7 @@ struct CompilationVideo property published : Time property compid : String property index : Int64 + property order_index : Int32 def to_xml(xml : XML::Builder) xml.element("entry") do @@ -18,6 +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("link", rel: "alternate", href: "#{HOST_URL}/watch?v=#{self.id}") xml.element("author") do @@ -67,6 +69,7 @@ struct CompilationVideo json.field "index", self.index end + json.field "orderIndex", self.order_index json.field "lengthSeconds", self.length_seconds json.field "startingTimestampSeconds", self.starting_timestamp_seconds json.field "endingTimestampSeconds", self.ending_timestamp_seconds @@ -413,6 +416,7 @@ def extract_compilation_videos(initial_data : Hash(String, JSON::Any)) published: Time.utc, compid: compid, index: index, + order_index: order_index }) end end diff --git a/src/invidious/routes/compilations.cr b/src/invidious/routes/compilations.cr index eb459e98..253ac22e 100644 --- a/src/invidious/routes/compilations.cr +++ b/src/invidious/routes/compilations.cr @@ -340,6 +340,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 }) Invidious::Database::CompilationVideos.insert(compilation_video) diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index ac01694d..dc7aadd8 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -87,6 +87,8 @@ module Invidious::Routing post "/create_compilation", Routes::Compilations, :create post "/compilation_ajax", Routes::Compilations, :compilation_ajax get "/add_compilation_items", Routes::Compilations, :add_compilation_items_page + get "/edit_compilation", Routes::Compilations, :edit + post "/edit_compilation", Routes::Compilations, :update end def register_iv_playlist_routes diff --git a/src/invidious/views/components/compilation_video.ecr b/src/invidious/views/components/compilation_video.ecr index ee586aa0..84dafc2a 100644 --- a/src/invidious/views/components/compilation_video.ecr +++ b/src/invidious/views/components/compilation_video.ecr @@ -26,12 +26,21 @@