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"> <button class="btn mr-1" v-if="authenticated && !isPipedPlaylist" @click="clonePlaylist">
{{ $t("actions.clone_playlist") }}<font-awesome-icon class="ml-3" icon="clone" /> {{ $t("actions.clone_playlist") }}<font-awesome-icon class="ml-3" icon="clone" />
</button> </button>
<button class="btn mr-1" @click="downloadPlaylistAsTxt">
{{ $t("actions.download_as_txt") }}
</button>
<a class="btn" :href="getRssUrl"> <a class="btn" :href="getRssUrl">
<font-awesome-icon icon="rss" /> <font-awesome-icon icon="rss" />
</a> </a>
@ -133,6 +136,13 @@ export default {
} else alert(resp.error); } 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> </script>

View File

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

View File

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

View File

@ -220,6 +220,17 @@ const mixin = {
const localSubscriptions = this.getLocalSubscriptions() ?? []; const localSubscriptions = this.getLocalSubscriptions() ?? [];
return localSubscriptions.join(","); 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: { computed: {
theme() { theme() {