From 8a801ab404b2474808b6516e44513ec0a3c4e776 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 27 Jan 2023 17:27:40 +0100 Subject: [PATCH] Support for exporting the watch history as playlist --- src/components/HistoryPage.vue | 18 ++++++++++++++++++ src/main.js | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/HistoryPage.vue b/src/components/HistoryPage.vue index 0d65910b..3c650b8e 100644 --- a/src/components/HistoryPage.vue +++ b/src/components/HistoryPage.vue @@ -4,6 +4,8 @@
@@ -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"); + }, }, }; diff --git a/src/main.js b/src/main.js index 12cf63ef..7aa789d9 100644 --- a/src/main.js +++ b/src/main.js @@ -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");