Use map() instead of for loops

This commit is contained in:
Bnyro 2023-01-01 20:00:22 +01:00
parent 58cd6f8f37
commit 5dbc82168a
2 changed files with 2 additions and 9 deletions

@ -1 +0,0 @@
Subproject commit 51f030d755a9115f06341ecd78fbbf75ec600059

View file

@ -134,10 +134,7 @@ export default {
version: 1, version: 1,
playlists: [], playlists: [],
}; };
let tasks = []; let tasks = this.playlists.map(playlist => this.fetchPlaylistJson(playlist.id));
for (var i = 0; i < this.playlists.length; i++) {
tasks.push(this.fetchPlaylistJson(this.playlists[i].id));
}
json.playlists = await Promise.all(tasks); json.playlists = await Promise.all(tasks);
this.download(JSON.stringify(json), "playlists.json", "application/json"); this.download(JSON.stringify(json), "playlists.json", "application/json");
}, },
@ -150,11 +147,8 @@ export default {
// as Invidious supports public and private playlists // as Invidious supports public and private playlists
visibility: "private", visibility: "private",
// list of the videos, starting with "https://youtube.com" to clarify that those are YT videos // list of the videos, starting with "https://youtube.com" to clarify that those are YT videos
videos: [], videos: playlist.relatedStreams.map(stream => "https://youtube.com" + stream.url),
}; };
for (var i = 0; i < playlist.relatedStreams.length; i++) {
playlistJson.videos.push("https://youtube.com" + playlist.relatedStreams[i].url);
}
return playlistJson; return playlistJson;
}, },
async importPlaylists() { async importPlaylists() {