mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-04 20:49:13 +05:30
Add authenticated API for compilation creation
This commit is contained in:
parent
7c92b051b3
commit
b6181b9d97
@ -759,3 +759,10 @@ h1, h2, h3, h4, h5, p,
|
|||||||
.channel-emoji {
|
.channel-emoji {
|
||||||
margin: 0 2px;
|
margin: 0 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.compilation-video-panel {
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
color: #d9d9d9;
|
||||||
|
}
|
||||||
|
@ -207,6 +207,32 @@ module Invidious::Routes::API::V1::Authenticated
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.create_compilation(env)
|
||||||
|
env.response.content_type = "application/json"
|
||||||
|
user = env.get("user").as(User)
|
||||||
|
|
||||||
|
title = env.params.json["title"]?.try &.as(String).delete("<>").byte_slice(0, 150)
|
||||||
|
if !title
|
||||||
|
return error_json(400, "Invalid title.")
|
||||||
|
end
|
||||||
|
|
||||||
|
privacy = env.params.json["privacy"]?.try { |p| CompilationPrivacy.parse(p.as(String).downcase) }
|
||||||
|
if !privacy
|
||||||
|
return error_json(400, "Invalid privacy setting.")
|
||||||
|
end
|
||||||
|
|
||||||
|
if Invidious::Database::Compilations.count_owned_by(user.email) >= 100
|
||||||
|
return error_json(400, "User cannot have more than 100 compilations.")
|
||||||
|
end
|
||||||
|
|
||||||
|
compilation = create_compilation(title, privacy, user)
|
||||||
|
env.response.headers["Location"] = "#{HOST_URL}/api/v1/auth/compilations/#{playlist.id}"
|
||||||
|
env.response.status_code = 201
|
||||||
|
{
|
||||||
|
"title" => title,
|
||||||
|
"compilationId" => compilation.id,
|
||||||
|
}.to_json
|
||||||
|
|
||||||
def self.create_playlist(env)
|
def self.create_playlist(env)
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
user = env.get("user").as(User)
|
user = env.get("user").as(User)
|
||||||
|
@ -274,6 +274,8 @@ module Invidious::Routing
|
|||||||
post "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :subscribe_channel
|
post "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :subscribe_channel
|
||||||
delete "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :unsubscribe_channel
|
delete "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :unsubscribe_channel
|
||||||
|
|
||||||
|
get "/api/v1/auth/compilations", {{namespace}}::Authenticated, :create_compilation
|
||||||
|
|
||||||
get "/api/v1/auth/playlists", {{namespace}}::Authenticated, :list_playlists
|
get "/api/v1/auth/playlists", {{namespace}}::Authenticated, :list_playlists
|
||||||
post "/api/v1/auth/playlists", {{namespace}}::Authenticated, :create_playlist
|
post "/api/v1/auth/playlists", {{namespace}}::Authenticated, :create_playlist
|
||||||
patch "/api/v1/auth/playlists/:plid",{{namespace}}:: Authenticated, :update_playlist_attribute
|
patch "/api/v1/auth/playlists/:plid",{{namespace}}:: Authenticated, :update_playlist_attribute
|
||||||
|
@ -90,6 +90,9 @@
|
|||||||
<% when CompilationVideo %>
|
<% when CompilationVideo %>
|
||||||
<a style="width:100%" href="/watch?v=<%= item.id %>&list=<%= item.compid %>&index=<%= item.index %>">
|
<a style="width:100%" href="/watch?v=<%= item.id %>&list=<%= item.compid %>&index=<%= item.index %>">
|
||||||
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
||||||
|
<div class="compilation-video-panel">
|
||||||
|
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</a>
|
</a>
|
||||||
<% when Category %>
|
<% when Category %>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3">
|
<div class="pure-u-1-3">
|
||||||
<h3 style="text-align:center">
|
<h3 style="text-align:center">
|
||||||
<a href="/create_compilations?referer=<%= URI.encode_www_form("/feed/compilations") %>"><%= translate(locale, "Create compilation") %></a>
|
<a href="/create_compilation?referer=<%= URI.encode_www_form("/feed/compilations") %>"><%= translate(locale, "Create compilation") %></a>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3">
|
<div class="pure-u-1-3">
|
||||||
|
Loading…
Reference in New Issue
Block a user