Video meta file removal option (#1154)

* Implemented video meta file removal option

* Lint fix
This commit is contained in:
Luca Hohmann 2021-04-01 15:54:45 +02:00 committed by GitHub
parent f6f9ba7a6c
commit c5fac9fcd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 2 deletions

View File

@ -33,6 +33,10 @@ export default Vue.extend({
saveWatchedProgress: function () { saveWatchedProgress: function () {
return this.$store.getters.getSaveWatchedProgress return this.$store.getters.getSaveWatchedProgress
}, },
removeVideoMetaFiles: function () {
return this.$store.getters.getRemoveVideoMetaFiles
},
profileList: function () { profileList: function () {
return this.$store.getters.getProfileList return this.$store.getters.getProfileList
}, },
@ -66,6 +70,13 @@ export default Vue.extend({
this.updateRememberHistory(value) this.updateRememberHistory(value)
}, },
handleVideoMetaFiles: function (value) {
if (!value) {
this.updateRemoveVideoMetaFiles(false)
}
this.updateRemoveVideoMetaFiles(value)
},
handleRemoveHistory: function (option) { handleRemoveHistory: function (option) {
this.showRemoveHistoryPrompt = false this.showRemoveHistoryPrompt = false
@ -102,6 +113,7 @@ export default Vue.extend({
...mapActions([ ...mapActions([
'updateRememberHistory', 'updateRememberHistory',
'updateRemoveVideoMetaFiles',
'removeAllHistory', 'removeAllHistory',
'updateSaveWatchedProgress', 'updateSaveWatchedProgress',
'clearSessionSearchHistory', 'clearSessionSearchHistory',

View File

@ -23,6 +23,15 @@
@change="updateSaveWatchedProgress" @change="updateSaveWatchedProgress"
/> />
</div> </div>
<div class="switchColumn">
<ft-toggle-switch
:label="$t('Settings.Privacy Settings.Automatically Remove Video Meta Files')"
:compact="true"
:default-value="removeVideoMetaFiles"
:tooltip="$t('Tooltips.Privacy Settings.Remove Video Meta Files')"
@change="handleVideoMetaFiles"
/>
</div>
</div> </div>
<br> <br>
<ft-flex-box> <ft-flex-box>

View File

@ -47,6 +47,7 @@ const state = {
enableSearchSuggestions: true, enableSearchSuggestions: true,
rememberHistory: true, rememberHistory: true,
saveWatchedProgress: true, saveWatchedProgress: true,
removeVideoMetaFiles: true,
autoplayVideos: true, autoplayVideos: true,
autoplayPlaylists: true, autoplayPlaylists: true,
playNextVideo: false, playNextVideo: false,
@ -141,6 +142,10 @@ const getters = {
return state.saveWatchedProgress return state.saveWatchedProgress
}, },
getRemoveVideoMetaFiles: () => {
return state.removeVideoMetaFiles
},
getAutoplayVideos: () => { getAutoplayVideos: () => {
return state.autoplayVideos return state.autoplayVideos
}, },
@ -330,6 +335,9 @@ const actions = {
case 'saveWatchedProgress': case 'saveWatchedProgress':
commit('setSaveWatchedProgress', result.value) commit('setSaveWatchedProgress', result.value)
break break
case 'removeVideoMetaFiles':
commit('setRemoveVideoMetaFiles', result.value)
break
case 'autoplayVideos': case 'autoplayVideos':
commit('setAutoplayVideos', result.value) commit('setAutoplayVideos', result.value)
break 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) { updateAutoplayVideos ({ commit }, autoplayVideos) {
settingsDb.update({ _id: 'autoplayVideos' }, { _id: 'autoplayVideos', value: autoplayVideos }, { upsert: true }, (err, numReplaced) => { settingsDb.update({ _id: 'autoplayVideos' }, { _id: 'autoplayVideos', value: autoplayVideos }, { upsert: true }, (err, numReplaced) => {
if (!err) { if (!err) {
@ -822,6 +838,11 @@ const mutations = {
setSaveWatchedProgress (state, saveWatchedProgress) { setSaveWatchedProgress (state, saveWatchedProgress) {
state.saveWatchedProgress = saveWatchedProgress state.saveWatchedProgress = saveWatchedProgress
}, },
setRemoveVideoMetaFiles (state, removeVideoMetaFiles) {
state.removeVideoMetaFiles = removeVideoMetaFiles
},
setAutoplayVideos (state, autoplayVideos) { setAutoplayVideos (state, autoplayVideos) {
state.autoplayVideos = autoplayVideos state.autoplayVideos = autoplayVideos
}, },

View File

@ -91,6 +91,9 @@ export default Vue.extend({
rememberHistory: function () { rememberHistory: function () {
return this.$store.getters.getRememberHistory return this.$store.getters.getRememberHistory
}, },
removeVideoMetaFiles: function () {
return this.$store.getters.getRemoveVideoMetaFiles
},
saveWatchedProgress: function () { saveWatchedProgress: function () {
return this.$store.getters.getSaveWatchedProgress return this.$store.getters.getSaveWatchedProgress
}, },
@ -899,8 +902,6 @@ export default Vue.extend({
videoId: this.videoId, videoId: this.videoId,
watchProgress: currentTime watchProgress: currentTime
} }
console.log('update watch progress')
this.updateWatchProgress(payload) this.updateWatchProgress(payload)
} }
} }
@ -928,6 +929,31 @@ export default Vue.extend({
}, 200) }, 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) { handleVideoError: function (error) {

View File

@ -195,6 +195,7 @@ Settings:
Privacy Settings: Privacy Settings Privacy Settings: Privacy Settings
Remember History: Remember History Remember History: Remember History
Save Watched Progress: Save Watched Progress Save Watched Progress: Save Watched Progress
Automatically Remove Video Meta Files: Automatically Remove Video Meta Files
Clear Search Cache: Clear Search Cache Clear Search Cache: Clear Search Cache
Are you sure you want to clear out your search cache?: Are you sure you want to Are you sure you want to clear out your search cache?: Are you sure you want to
clear out your search cache? clear out your search cache?
@ -571,6 +572,9 @@ Tooltips:
Fetch Feeds from RSS: When enabled, FreeTube will use RSS instead of its default 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, 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 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 # Toast Messages
Local API Error (Click to copy): Local API Error (Click to copy) Local API Error (Click to copy): Local API Error (Click to copy)