diff --git a/src/renderer/components/video/player.vue b/src/renderer/components/video/player.vue index 50791ff..61c7019 100644 --- a/src/renderer/components/video/player.vue +++ b/src/renderer/components/video/player.vue @@ -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 + } } } } diff --git a/src/renderer/mixins/video/tracking.js b/src/renderer/mixins/video/tracking.js index d38a9ea..458bc1b 100644 --- a/src/renderer/mixins/video/tracking.js +++ b/src/renderer/mixins/video/tracking.js @@ -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',