diff --git a/src/components/PlaylistPage.vue b/src/components/PlaylistPage.vue index 67e5e9a7..550f29b6 100644 --- a/src/components/PlaylistPage.vue +++ b/src/components/PlaylistPage.vue @@ -18,6 +18,9 @@ + @@ -133,6 +136,22 @@ 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"); + }, + download(text, filename) { + var element = document.createElement("a"); + element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(text)); + element.setAttribute("download", filename); + element.style.display = "none"; + document.body.appendChild(element); + element.click(); + document.body.removeChild(element); + }, }, }; diff --git a/src/locales/en.json b/src/locales/en.json index 64f403b3..229cacb5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -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", diff --git a/src/main.js b/src/main.js index 171e6a33..0225cb79 100644 --- a/src/main.js +++ b/src/main.js @@ -220,6 +220,15 @@ const mixin = { const localSubscriptions = this.getLocalSubscriptions(); return localSubscriptions.join(","); }, + download(text, filename) { + var element = document.createElement("a"); + element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(text)); + element.setAttribute("download", filename); + element.style.display = "none"; + document.body.appendChild(element); + element.click(); + document.body.removeChild(element); + }, }, computed: { theme() {