From a0109e910a10b41ff9cfbef1a4621e13addc98c9 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 2 Aug 2022 10:41:35 +0200 Subject: [PATCH 1/5] fix unauthenticated subscribe status --- src/components/ChannelPage.vue | 10 +++++++--- src/components/WatchVideo.vue | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/ChannelPage.vue b/src/components/ChannelPage.vue index 42dceb4d..aceff744 100644 --- a/src/components/ChannelPage.vue +++ b/src/components/ChannelPage.vue @@ -49,7 +49,7 @@ export default { data() { return { channel: null, - subscribed: this.authenticated ? false : this.isSubscribedLocally(this.channelId), + subscribed: false, }; }, mounted() { @@ -68,7 +68,11 @@ export default { }, methods: { async fetchSubscribedStatus() { - if (!this.channelId || !this.authenticated) return; + if (!this.channel.id) return; + if (!this.authenticated) { + this.subscribed = this.isSubscribedLocally(this.channel.id); + return; + } this.fetchJson( this.authApiUrl() + "/subscribed", @@ -94,7 +98,7 @@ export default { .then(() => { if (!this.channel.error) { document.title = this.channel.name + " - Piped"; - if (this.authenticated) this.fetchSubscribedStatus(); + this.fetchSubscribedStatus(); this.updateWatched(this.channel.relatedStreams); } }); diff --git a/src/components/WatchVideo.vue b/src/components/WatchVideo.vue index deb65dae..d6a46c89 100644 --- a/src/components/WatchVideo.vue +++ b/src/components/WatchVideo.vue @@ -427,7 +427,10 @@ export default { }, async fetchSubscribedStatus() { if (!this.channelId) return; - if (!this.authenticated) this.subscribed = this.isSubscribedLocally(this.channelId); + if (!this.authenticated) { + this.subscribed = this.isSubscribedLocally(this.channelId); + return; + } this.fetchJson( this.authApiUrl() + "/subscribed", From 4bacca566eab1afa2a9e2d98cd1644283a649f40 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 4 Aug 2022 11:38:04 +0530 Subject: [PATCH 2/5] Fix error when subscriptions are null. --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 171e6a33..ed0f4fee 100644 --- a/src/main.js +++ b/src/main.js @@ -217,7 +217,7 @@ const mixin = { localStorage.setItem("localSubscriptions", JSON.stringify(localSubscriptions)); }, getUnauthenticatedChannels() { - const localSubscriptions = this.getLocalSubscriptions(); + const localSubscriptions = this.getLocalSubscriptions() ?? []; return localSubscriptions.join(","); }, }, From 8e458f4a0ef002b310b99087f94c692af5d73a9e Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Fri, 5 Aug 2022 22:25:51 +0530 Subject: [PATCH 3/5] Fix an error on import page when subscriptions are null. --- src/components/ImportPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ImportPage.vue b/src/components/ImportPage.vue index 4d8791d8..2af7cd6a 100644 --- a/src/components/ImportPage.vue +++ b/src/components/ImportPage.vue @@ -155,7 +155,7 @@ export default { importSubscriptionsLocally(newChannels) { const subscriptions = this.override ? [...new Set(newChannels)] - : [...new Set(this.getLocalSubscriptions().concat(newChannels))]; + : [...new Set((this.getLocalSubscriptions() ?? []).concat(newChannels))]; // Sort for better cache hits subscriptions.sort(); localStorage.setItem("localSubscriptions", JSON.stringify(subscriptions)); From a574cedea39b3a494ccb77c5b1183720a406b556 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sat, 6 Aug 2022 15:33:31 +0530 Subject: [PATCH 4/5] Add keybind to navigate next. Closes #1278 --- src/components/VideoPlayer.vue | 59 ++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue index 247790ff..a6c0a39d 100644 --- a/src/components/VideoPlayer.vue +++ b/src/components/VideoPlayer.vue @@ -85,7 +85,7 @@ export default { this.hotkeysPromise.then(() => { var self = this; this.$hotkeys( - "f,m,j,k,l,c,space,up,down,left,right,0,1,2,3,4,5,6,7,8,9,shift+,,shift+.", + "f,m,j,k,l,c,space,up,down,left,right,0,1,2,3,4,5,6,7,8,9,shift+n,shift+,,shift+.", function (e, handler) { const videoEl = self.$refs.videoEl; switch (handler.key) { @@ -171,6 +171,10 @@ export default { videoEl.currentTime = videoEl.duration * 0.9; e.preventDefault(); break; + case "shift+n": + self.navigateNext(); + e.preventDefault(); + break; case "shift+,": self.$player.trickPlay(Math.max(videoEl.playbackRate - 0.25, 0.25)); break; @@ -372,30 +376,12 @@ export default { }); videoEl.addEventListener("ended", () => { - if (!this.selectedAutoLoop && this.selectedAutoPlay && this.video.relatedStreams.length > 0) { - const params = this.$route.query; - let url = this.playlist?.relatedStreams?.[this.index]?.url ?? this.video.relatedStreams[0].url; - const searchParams = new URLSearchParams(); - for (var param in params) - switch (param) { - case "v": - case "t": - break; - case "index": - if (this.index < this.playlist.relatedStreams.length) - searchParams.set("index", this.index + 1); - break; - case "list": - if (this.index < this.playlist.relatedStreams.length) - searchParams.set("list", params.list); - break; - default: - searchParams.set(param, params[param]); - break; - } - const paramStr = searchParams.toString(); - if (paramStr.length > 0) url += "&" + paramStr; - this.$router.push(url); + if ( + !this.selectedAutoLoop && + this.selectedAutoPlay && + (this.playlist?.relatedStreams?.length > 0 || this.video.relatedStreams.length > 0) + ) { + this.navigateNext(); } }); } @@ -558,6 +544,29 @@ export default { this.$refs.videoEl.currentTime = time; } }, + navigateNext() { + const params = this.$route.query; + let url = this.playlist?.relatedStreams?.[this.index]?.url ?? this.video.relatedStreams[0].url; + const searchParams = new URLSearchParams(); + for (var param in params) + switch (param) { + case "v": + case "t": + break; + case "index": + if (this.index < this.playlist.relatedStreams.length) searchParams.set("index", this.index + 1); + break; + case "list": + if (this.index < this.playlist.relatedStreams.length) searchParams.set("list", params.list); + break; + default: + searchParams.set(param, params[param]); + break; + } + const paramStr = searchParams.toString(); + if (paramStr.length > 0) url += "&" + paramStr; + this.$router.push(url); + }, updateMarkers() { const markers = this.$refs.container.querySelector(".shaka-ad-markers"); const array = ["to right"]; From cd689ea3c7f4732cb67edd6cb31981bc9cf89869 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sat, 6 Aug 2022 15:43:41 +0530 Subject: [PATCH 5/5] Don't seek if saved position is > 90% of the video. Closes #1277 --- src/components/VideoPlayer.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue index a6c0a39d..e0d6a74e 100644 --- a/src/components/VideoPlayer.vue +++ b/src/components/VideoPlayer.vue @@ -229,8 +229,11 @@ export default { var request = store.get(this.video.id); request.onsuccess = function (event) { var video = event.target.result; - if (video?.currentTime) { - videoEl.currentTime = video.currentTime; + const currentTime = video?.currentTime; + if (currentTime) { + if (currentTime < component.video.duration * 0.9) { + videoEl.currentTime = currentTime; + } } };