mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-23 05:57:21 +00:00
Merge pull request #2027 from Bnyro/export-history
Support for exporting the watch history as playlist
This commit is contained in:
commit
6db0106064
@ -4,6 +4,8 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div>
|
<div>
|
||||||
<button class="btn" v-t="'actions.clear_history'" @click="clearHistory" />
|
<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>
|
||||||
|
|
||||||
<div class="right-1">
|
<div class="right-1">
|
||||||
@ -71,6 +73,22 @@ export default {
|
|||||||
}
|
}
|
||||||
this.videos = [];
|
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>
|
</script>
|
||||||
|
@ -241,8 +241,8 @@ const mixin = {
|
|||||||
return localSubscriptions.join(",");
|
return localSubscriptions.join(",");
|
||||||
},
|
},
|
||||||
/* generate a temporary file and ask the user to download it */
|
/* generate a temporary file and ask the user to download it */
|
||||||
download(text, filename, type) {
|
download(text, filename, mimeType) {
|
||||||
var file = new Blob([text], { type: type });
|
var file = new Blob([text], { type: mimeType });
|
||||||
|
|
||||||
const elem = document.createElement("a");
|
const elem = document.createElement("a");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user