Merge pull request #2027 from Bnyro/export-history

Support for exporting the watch history as playlist
This commit is contained in:
Kavin 2023-01-27 17:55:29 +00:00 committed by GitHub
commit 6db0106064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -4,6 +4,8 @@
<div class="flex">
<div>
<button class="btn" v-t="'actions.clear_history'" @click="clearHistory" />
<button class="btn mx-3" v-t="'actions.export_to_json'" @click="exportHistory" />
</div>
<div class="right-1">
@ -71,6 +73,22 @@ export default {
}
this.videos = [];
},
exportHistory() {
const dateStr = new Date().toISOString().split(".")[0];
let json = {
format: "Piped",
version: 1,
playlists: [
{
name: `Piped History ${dateStr}`,
type: "history",
visibility: "private",
videos: this.videos.map(video => "https://youtube.com" + video.url),
},
],
};
this.download(JSON.stringify(json), `piped_history_${dateStr}.json`, "application/json");
},
},
};
</script>

View File

@ -241,8 +241,8 @@ const mixin = {
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 });
download(text, filename, mimeType) {
var file = new Blob([text], { type: mimeType });
const elem = document.createElement("a");