Re implemented episode tracking and history

This commit is contained in:
Kylart 2020-01-16 01:00:26 +01:00
parent 8cd907671a
commit 1e3eef2861
2 changed files with 36 additions and 13 deletions

View File

@ -71,7 +71,9 @@ export default {
hasSubs: false,
tracks: {},
currentSubLang: null
currentSubLang: null,
parsedName: null
}
},
@ -132,6 +134,9 @@ export default {
if (name.match(/^volume$/)) return this.setVolume(value)
if (name.match(/^eof-reached$/) && value) return this.$emit('sendNext')
// Originally media-title
if (name.match(/^name$/)) return this.addToHistory(value)
if (!this.hasOwnProperty(name)) return
this.$set(this, name, value)
@ -221,6 +226,35 @@ export default {
onMouseMove (e) {
if (Math.abs(e.movementX) > 1 || Math.abs(e.movementY) > 1) this.$refs.layout.reveal()
},
/**
* Will add current file to the history
*
* @param {String} value Title as found by MPV
*/
addToHistory (value) {
// If we are streaming a torrent, the name will come from the torrent's name
// Otherwise, it will be from the file itself once parsed by MPV.
const name = this.torrent ? this.$store.state.streaming.player.name : value
try {
// Simply parsing and applying the name
this.parsedName = this.$ipc.sendSync(this.$eventsList.parse.main, name)
this.name = `${this.parsedName.anime_title} - ${this.parsedName.episode_number}`
} catch (e) {
// We fallback to the found value
this.name = value
}
if (!this.hasAppendedToHistory) {
this.$store.dispatch('history/append', {
type: this.torrent ? 'Stream' : 'Play',
text: this.name
})
this.hasAppendedToHistory = true
}
}
}
}

View File

@ -2,7 +2,7 @@ import { mapActions, mapMutations } from 'vuex'
export default {
beforeDestroy () {
const { name: refName, ep: refEp } = this.parsedName
const { anime_title: refName, episode_number: refEp } = this.parsedName
const { autoTracking } = this.$store.state.config.config
const providersAutoTracking = Object.keys(autoTracking).reduce((acc, provider) => {
return provider === 'local'
@ -16,17 +16,6 @@ export default {
providersAutoTracking.some(Boolean) && this.trackProviders(refName, refEp, providersAutoTracking)
},
computed: {
parsedName () {
const parts = this.videoTitle.split(' - ')
return {
name: parts[0],
ep: parts[1]
}
}
},
methods: {
...mapActions('watchLists', {
localMove: 'move',