mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Support for exporting the watch history as playlist
This commit is contained in:
parent
604eb5edcc
commit
8a801ab404
2 changed files with 20 additions and 2 deletions
|
@ -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>
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in a new issue