From c5fac9fcd7d8e0a10d922592006b007daf2deedf Mon Sep 17 00:00:00 2001
From: Luca Hohmann <34301369+GilgusMaximus@users.noreply.github.com>
Date: Thu, 1 Apr 2021 15:54:45 +0200
Subject: [PATCH] Video meta file removal option (#1154)
* Implemented video meta file removal option
* Lint fix
---
.../privacy-settings/privacy-settings.js | 12 ++++++++
.../privacy-settings/privacy-settings.vue | 9 ++++++
src/renderer/store/modules/settings.js | 21 +++++++++++++
src/renderer/views/Watch/Watch.js | 30 +++++++++++++++++--
static/locales/en-US.yaml | 4 +++
5 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/src/renderer/components/privacy-settings/privacy-settings.js b/src/renderer/components/privacy-settings/privacy-settings.js
index 53b4421f..3e9f42b6 100644
--- a/src/renderer/components/privacy-settings/privacy-settings.js
+++ b/src/renderer/components/privacy-settings/privacy-settings.js
@@ -33,6 +33,10 @@ export default Vue.extend({
saveWatchedProgress: function () {
return this.$store.getters.getSaveWatchedProgress
},
+ removeVideoMetaFiles: function () {
+ return this.$store.getters.getRemoveVideoMetaFiles
+ },
+
profileList: function () {
return this.$store.getters.getProfileList
},
@@ -66,6 +70,13 @@ export default Vue.extend({
this.updateRememberHistory(value)
},
+ handleVideoMetaFiles: function (value) {
+ if (!value) {
+ this.updateRemoveVideoMetaFiles(false)
+ }
+ this.updateRemoveVideoMetaFiles(value)
+ },
+
handleRemoveHistory: function (option) {
this.showRemoveHistoryPrompt = false
@@ -102,6 +113,7 @@ export default Vue.extend({
...mapActions([
'updateRememberHistory',
+ 'updateRemoveVideoMetaFiles',
'removeAllHistory',
'updateSaveWatchedProgress',
'clearSessionSearchHistory',
diff --git a/src/renderer/components/privacy-settings/privacy-settings.vue b/src/renderer/components/privacy-settings/privacy-settings.vue
index e0191eda..d39b7214 100644
--- a/src/renderer/components/privacy-settings/privacy-settings.vue
+++ b/src/renderer/components/privacy-settings/privacy-settings.vue
@@ -23,6 +23,15 @@
@change="updateSaveWatchedProgress"
/>
+
+
+
diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js
index 1c427b05..bd12ed7c 100644
--- a/src/renderer/store/modules/settings.js
+++ b/src/renderer/store/modules/settings.js
@@ -47,6 +47,7 @@ const state = {
enableSearchSuggestions: true,
rememberHistory: true,
saveWatchedProgress: true,
+ removeVideoMetaFiles: true,
autoplayVideos: true,
autoplayPlaylists: true,
playNextVideo: false,
@@ -141,6 +142,10 @@ const getters = {
return state.saveWatchedProgress
},
+ getRemoveVideoMetaFiles: () => {
+ return state.removeVideoMetaFiles
+ },
+
getAutoplayVideos: () => {
return state.autoplayVideos
},
@@ -330,6 +335,9 @@ const actions = {
case 'saveWatchedProgress':
commit('setSaveWatchedProgress', result.value)
break
+ case 'removeVideoMetaFiles':
+ commit('setRemoveVideoMetaFiles', result.value)
+ break
case 'autoplayVideos':
commit('setAutoplayVideos', result.value)
break
@@ -555,6 +563,14 @@ const actions = {
})
},
+ updateRemoveVideoMetaFiles ({ commit }, removeVideoMetaFiles) {
+ settingsDb.update({ _id: 'removeVideoMetaFiles' }, { _id: 'removeVideoMetaFiles', value: removeVideoMetaFiles }, { upsert: true }, (err, numReplaced) => {
+ if (!err) {
+ commit('setRemoveVideoMetaFiles', removeVideoMetaFiles)
+ }
+ })
+ },
+
updateAutoplayVideos ({ commit }, autoplayVideos) {
settingsDb.update({ _id: 'autoplayVideos' }, { _id: 'autoplayVideos', value: autoplayVideos }, { upsert: true }, (err, numReplaced) => {
if (!err) {
@@ -822,6 +838,11 @@ const mutations = {
setSaveWatchedProgress (state, saveWatchedProgress) {
state.saveWatchedProgress = saveWatchedProgress
},
+
+ setRemoveVideoMetaFiles (state, removeVideoMetaFiles) {
+ state.removeVideoMetaFiles = removeVideoMetaFiles
+ },
+
setAutoplayVideos (state, autoplayVideos) {
state.autoplayVideos = autoplayVideos
},
diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js
index 00745b4d..1e5c4990 100644
--- a/src/renderer/views/Watch/Watch.js
+++ b/src/renderer/views/Watch/Watch.js
@@ -91,6 +91,9 @@ export default Vue.extend({
rememberHistory: function () {
return this.$store.getters.getRememberHistory
},
+ removeVideoMetaFiles: function () {
+ return this.$store.getters.getRemoveVideoMetaFiles
+ },
saveWatchedProgress: function () {
return this.$store.getters.getSaveWatchedProgress
},
@@ -899,8 +902,6 @@ export default Vue.extend({
videoId: this.videoId,
watchProgress: currentTime
}
-
- console.log('update watch progress')
this.updateWatchProgress(payload)
}
}
@@ -928,6 +929,31 @@ export default Vue.extend({
}, 200)
}
}
+
+ if (this.removeVideoMetaFiles) {
+ const userData = remote.app.getPath('userData')
+ if (this.isDev) {
+ const dashFileLocation = `dashFiles/${this.videoId}.xml`
+ const vttFileLocation = `storyboards/${this.videoId}.vtt`
+ // only delete the file it actually exists
+ if (fs.existsSync('dashFiles/') && fs.existsSync(dashFileLocation)) {
+ fs.rmSync(dashFileLocation)
+ }
+ if (fs.existsSync('storyboards/') && fs.existsSync(vttFileLocation)) {
+ fs.rmSync(vttFileLocation)
+ }
+ } else {
+ const dashFileLocation = `${userData}/dashFiles/${this.videoId}.xml`
+ const vttFileLocation = `${userData}/storyboards/${this.videoId}.vtt`
+
+ if (fs.existsSync(`${userData}/dashFiles/`) && fs.existsSync(dashFileLocation)) {
+ fs.rmSync(dashFileLocation)
+ }
+ if (fs.existsSync(`${userData}/storyboards/`) && fs.existsSync(vttFileLocation)) {
+ fs.rmSync(vttFileLocation)
+ }
+ }
+ }
},
handleVideoError: function (error) {
diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml
index 4b969536..d73f551e 100644
--- a/static/locales/en-US.yaml
+++ b/static/locales/en-US.yaml
@@ -195,6 +195,7 @@ Settings:
Privacy Settings: Privacy Settings
Remember History: Remember History
Save Watched Progress: Save Watched Progress
+ Automatically Remove Video Meta Files: Automatically Remove Video Meta Files
Clear Search Cache: Clear Search Cache
Are you sure you want to clear out your search cache?: Are you sure you want to
clear out your search cache?
@@ -571,6 +572,9 @@ Tooltips:
Fetch Feeds from RSS: When enabled, FreeTube will use RSS instead of its default
method for grabbing your subscription feed. RSS is faster and prevents IP blocking,
but doesn't provide certain information like video duration or live status
+ Privacy Settings:
+ Remove Video Meta Files: When enabled, FreeTube automatically deletes meta files created during video playback,
+ when the watch page is closed.
# Toast Messages
Local API Error (Click to copy): Local API Error (Click to copy)