Merge pull request #1273 from Bnyro/playlist

Export playlists as .txt to allow downloading the videos via yt-dlp
This commit is contained in:
Kavin 2022-08-06 16:43:36 +05:30 committed by GitHub
commit 791a944d7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 9 deletions

View file

@ -18,6 +18,9 @@
<button class="btn mr-1" v-if="authenticated && !isPipedPlaylist" @click="clonePlaylist">
{{ $t("actions.clone_playlist") }}<font-awesome-icon class="ml-3" icon="clone" />
</button>
<button class="btn mr-1" @click="downloadPlaylistAsTxt">
{{ $t("actions.download_as_txt") }}
</button>
<a class="btn" :href="getRssUrl">
<font-awesome-icon icon="rss" />
</a>
@ -133,6 +136,13 @@ export default {
} else alert(resp.error);
});
},
downloadPlaylistAsTxt() {
var data = "";
this.playlist.relatedStreams.forEach(element => {
data += "https://piped.kavin.rocks" + element.url + "\n";
});
this.download(data, this.playlist.name + ".txt", "text/plain");
},
},
};
</script>

View file

@ -97,14 +97,7 @@ export default {
subscriptions: subscriptions,
});
var file = new Blob([json], { type: "application/json" });
const elem = document.createElement("a");
elem.href = URL.createObjectURL(file);
elem.download = "subscriptions.json";
elem.click();
elem.remove();
this.download(json, "subscriptions.json", "application/json");
},
},
};

View file

@ -88,7 +88,8 @@
"different_auth_instance": "Use a different instance for authentication",
"instance_auth_selection": "Autentication Instance Selection",
"clone_playlist": "Clone Playlist",
"clone_playlist_success": "Successfully cloned!"
"clone_playlist_success": "Successfully cloned!",
"download_as_txt": "Download as .txt"
},
"comment": {
"pinned_by": "Pinned by",

View file

@ -220,6 +220,17 @@ const mixin = {
const localSubscriptions = this.getLocalSubscriptions() ?? [];
return localSubscriptions.join(",");
},
/* generate a temporary file and ask the user to download it */
download(text, filename, type) {
var file = new Blob([text], { type: type });
const elem = document.createElement("a");
elem.href = URL.createObjectURL(file);
elem.download = filename;
elem.click();
elem.remove();
},
},
computed: {
theme() {