mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Added support for import and export of youtube playlists
This commit is contained in:
parent
961cae2b9a
commit
7b600cd4e1
2 changed files with 21 additions and 0 deletions
|
@ -4,6 +4,7 @@ struct Invidious::User
|
|||
|
||||
def to_invidious(user : User)
|
||||
playlists = Invidious::Database::Playlists.select_like_iv(user.email)
|
||||
youtube_playlists = Invidious::Database::Playlists.select_not_like_iv(user.email)
|
||||
|
||||
return JSON.build do |json|
|
||||
json.object do
|
||||
|
@ -28,6 +29,16 @@ struct Invidious::User
|
|||
end
|
||||
end
|
||||
end
|
||||
json.field "youtube_playlists" do
|
||||
json.array do
|
||||
youtube_playlists.each do |playlist|
|
||||
json.object do
|
||||
json.field "title", playlist.title
|
||||
json.field "id", playlist.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -101,6 +101,16 @@ struct Invidious::User
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if youtube_playlists = data["youtube_playlists"]?.try &.as_a?
|
||||
playlists.each do |item|
|
||||
begin
|
||||
playlist = get_playlist(item["id"])
|
||||
subscribe_playlist(user, playlist)
|
||||
rescue ex
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# -------------------
|
||||
|
|
Loading…
Reference in a new issue