mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-28 07:28:31 +00:00
feat(playlists): helper method to add new video
This commit is contained in:
parent
40ede85503
commit
d65803872e
@ -237,6 +237,27 @@ struct InvidiousPlaylist
|
|||||||
def description_html
|
def description_html
|
||||||
HTML.escape(self.description)
|
HTML.escape(self.description)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def add_new_video(video : Video)
|
||||||
|
playlist_video = PlaylistVideo.new(
|
||||||
|
{
|
||||||
|
title: video.title,
|
||||||
|
id: video.id,
|
||||||
|
author: video.author,
|
||||||
|
ucid: video.ucid,
|
||||||
|
length_seconds: video.length_seconds,
|
||||||
|
published: video.published,
|
||||||
|
plid: @id,
|
||||||
|
live_now: video.live_now,
|
||||||
|
index: Random::Secure.rand(0_i64..Int64::MAX),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Invidious::Database::PlaylistVideos.insert(playlist_video)
|
||||||
|
Invidious::Database::Playlists.update_video_added(@id, playlist_video.index)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_playlist(title, privacy, user)
|
def create_playlist(title, privacy, user)
|
||||||
|
Loading…
Reference in New Issue
Block a user