Video meta file removal option (#1154)
* Implemented video meta file removal option * Lint fix
This commit is contained in:
parent
f6f9ba7a6c
commit
c5fac9fcd7
|
@ -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',
|
||||
|
|
|
@ -23,6 +23,15 @@
|
|||
@change="updateSaveWatchedProgress"
|
||||
/>
|
||||
</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>
|
||||
<br>
|
||||
<ft-flex-box>
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue