- {{ $t("This part of the app is not ready yet. Come back later when progress has been made.") }}
+ {{ $t("History['Your history list is currently empty.']") }}
+
+
+
+
diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js
index 7ba0bafd..ac63c2ec 100644
--- a/src/renderer/views/Watch/Watch.js
+++ b/src/renderer/views/Watch/Watch.js
@@ -47,6 +47,7 @@ export default Vue.extend({
videoViewCount: 0,
videoLikeCount: 0,
videoDislikeCount: 0,
+ videoLengthSeconds: 0,
channelName: '',
channelThumbnail: '',
channelId: '',
@@ -72,6 +73,14 @@ export default Vue.extend({
return this.$store.getters.getUsingElectron
},
+ historyCache: function () {
+ return this.$store.getters.getHistoryCache
+ },
+
+ rememberHistory: function () {
+ return this.$store.getters.getRememberHistory
+ },
+
backendPreference: function () {
return this.$store.getters.getBackendPreference
},
@@ -276,6 +285,7 @@ export default Vue.extend({
this.activeSourceList = this.videoSourceList
}
} else {
+ this.videoLengthSeconds = parseInt(result.videoDetails.lengthSeconds)
this.videoSourceList = result.player_response.streamingData.formats
this.audioSourceList = result.player_response.streamingData.adaptiveFormats.filter((format) => {
@@ -395,6 +405,7 @@ export default Vue.extend({
} else if (this.forceLocalBackendForLegacy) {
this.getLegacyFormats()
} else {
+ this.videoLengthSeconds = result.lengthSeconds
this.videoSourceList = result.formatStreams.reverse()
this.audioSourceList = result.adaptiveFormats.filter((format) => {
@@ -441,6 +452,46 @@ export default Vue.extend({
})
},
+ addToHistory: function (watchProgress) {
+ const videoData = {
+ videoId: this.videoId,
+ title: this.videoTitle,
+ author: this.channelName,
+ authorId: this.channelId,
+ published: this.videoPublished,
+ description: this.videoDescription,
+ viewCount: this.videoViewCount,
+ lengthSeconds: this.videoLengthSeconds,
+ watchProgress: watchProgress,
+ timeWatched: new Date().getTime(),
+ isLive: false,
+ paid: false,
+ type: 'video'
+ }
+
+ this.updateHistory(videoData)
+ },
+
+ checkIfWatched: function () {
+ const historyIndex = this.historyCache.findIndex((video) => {
+ return video.videoId === this.videoId
+ })
+
+ console.log(historyIndex)
+
+ if (historyIndex !== -1 && !this.isLive) {
+ console.log(this.historyCache[historyIndex])
+ const watchProgress = this.historyCache[historyIndex].watchProgress
+ this.$refs.videoPlayer.player.currentTime(watchProgress)
+ }
+
+ if (this.rememberHistory && historyIndex !== -1) {
+ this.addToHistory(this.historyCache[historyIndex].watchProgress)
+ } else if (this.rememberHistory) {
+ this.addToHistory(0)
+ }
+ },
+
checkIfPlaylist: function () {
if (typeof (this.$route.query) !== 'undefined') {
this.playlistId = this.$route.query.playlistId
@@ -630,7 +681,24 @@ export default Vue.extend({
...mapActions([
'showToast',
- 'buildVTTFileLocally'
+ 'buildVTTFileLocally',
+ 'updateHistory',
+ 'updateWatchProgress'
])
+ },
+ beforeRouteLeave: function (to, from, next) {
+ if (this.rememberHistory) {
+ const currentTime = this.$refs.videoPlayer.player.currentTime()
+ console.log(currentTime)
+ const payload = {
+ videoId: this.videoId,
+ watchProgress: currentTime
+ }
+
+ console.log('update watch progress')
+ this.updateWatchProgress(payload)
+ }
+
+ next()
}
})
diff --git a/src/renderer/views/Watch/Watch.vue b/src/renderer/views/Watch/Watch.vue
index 95ca9ab4..298347f9 100644
--- a/src/renderer/views/Watch/Watch.vue
+++ b/src/renderer/views/Watch/Watch.vue
@@ -23,6 +23,7 @@
:thumbnail="thumbnail"
class="videoPlayer"
:class="{ theatrePlayer: useTheatreMode }"
+ @ready="checkIfWatched"
@ended="handleVideoEnded"
@error="handleVideoError"
/>
diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml
index ad60dcc2..821604bd 100644
--- a/static/locales/en-US.yaml
+++ b/static/locales/en-US.yaml
@@ -95,6 +95,7 @@ History:
# On History Page
History: History
Watch History: Watch History
+ Your history list is currently empty.: Your history list is currently empty.
Settings:
# On Settings Page
Settings: Settings
@@ -264,6 +265,10 @@ Channel:
Channel Description: Channel Description
Featured Channels: Featured Channels
Video:
+ Mark As Watched: Mark As Watched
+ Remove From History: Remove From History
+ Video has been marked as watched: Video has been marked as watched
+ Video has been removed from your history: Video has been removed from your history
Open in YouTube: Open in YouTube
Copy YouTube Link: Copy YouTube Link
Open YouTube Embedded Player: Open YouTube Embedded Player