diff --git a/src/components/PlaylistsPage.vue b/src/components/PlaylistsPage.vue
index 716524b5..e2e0b84f 100644
--- a/src/components/PlaylistsPage.vue
+++ b/src/components/PlaylistsPage.vue
@@ -3,7 +3,13 @@
@@ -111,6 +117,36 @@ export default {
else this.fetchPlaylists();
});
},
+ exportPlaylists() {
+ if (!this.playlists) return;
+ let json = {
+ playlists: [],
+ };
+ let playlistsSize = this.playlists.length;
+ for (var i = 0; i < playlistsSize; i++) {
+ this.fetchPlaylistJson(this.playlists[i].id, playlist => {
+ json.playlists.push(playlist);
+ if (playlistsSize != json.playlists.length) return;
+ this.download(JSON.stringify(json), "playlists.json", "application/json");
+ });
+ }
+ },
+ async fetchPlaylistJson(playlistId, onSuccess) {
+ let playlist = await this.fetchJson(this.authApiUrl() + "/playlists/" + playlistId);
+ let playlistJson = {
+ name: playlist.name,
+ // possible other types: history, watch later, ...
+ type: "playlist",
+ // as Invidious supports public and private playlists
+ visibility: "private",
+ // list of the videos, starting with "https://youtube.com" to clarify that those are YT videos
+ videos: [],
+ };
+ for (var i = 0; i < playlist.relatedStreams.length; i++) {
+ playlistJson.videos.push("https://youtube.com" + playlist.relatedStreams[i].url);
+ }
+ onSuccess(playlistJson);
+ },
},
};