From 6cf16d00329bf5b87fc02c86021718f07091a4b2 Mon Sep 17 00:00:00 2001 From: Georgiy Date: Sat, 6 Apr 2024 19:22:37 +0300 Subject: [PATCH] fix: Sponsorblock fix --- NUXT/components/Player/index.vue | 8 +++++++- NUXT/components/Player/playpause.vue | 1 - NUXT/components/Player/sponsorblock.vue | 2 +- NUXT/pages/mods/player.vue | 6 ++++-- NUXT/plugins/youtube.js | 3 ++- NUXT/store/player/index.js | 6 ++++-- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/NUXT/components/Player/index.vue b/NUXT/components/Player/index.vue index 2de64a0d..6ac5ad2a 100644 --- a/NUXT/components/Player/index.vue +++ b/NUXT/components/Player/index.vue @@ -407,6 +407,7 @@ export default { audSrc: "", isVerticalVideo: false, // maybe rename(refactor everywhere used) to isShort bufferingDetected: false, + videoEnded: false, isMusic: false, sponsorBlocks: [], vid: null, @@ -581,6 +582,7 @@ export default { this.$refs.player.addEventListener("progress", this.progressEvent); this.$refs.player.addEventListener("waiting", this.waitingEvent); this.$refs.player.addEventListener("playing", this.playingEvent); + this.$refs.player.addEventListener("ended", this.endedEvent); } }, timeUpdateEvent() { @@ -595,7 +597,7 @@ export default { // console.warn(data); this.sponsorBlocks.segments.forEach((block) => { // block.segments.forEach((segments) => { - if (vidTime >= block.segment[0] && vidTime <= block.segment[1]) { + if (vidTime >= block.segment[0] && vidTime < block.segment[1] && this.videoEnded == false) { console.log("Skipping the sponsor"); this.$youtube.showToast("Skipped "+ block.category + " sponsor"); this.$refs.player.currentTime = block.segment[1]; @@ -604,6 +606,9 @@ export default { // }); }); }, + endedEvent() { + this.videoEnded = true; + }, progressEvent() { if (this.bufferingDetected) { this.$refs.audio.currentTime = this.vid.currentTime; @@ -630,6 +635,7 @@ export default { } }, playingEvent() { + this.videoEnded = false; if (this.bufferingDetected != false) { clearTimeout(this.bufferingDetected); this.$refs.audio.currentTime = this.vid.currentTime; diff --git a/NUXT/components/Player/playpause.vue b/NUXT/components/Player/playpause.vue index 92e4d501..c5ae61be 100644 --- a/NUXT/components/Player/playpause.vue +++ b/NUXT/components/Player/playpause.vue @@ -20,7 +20,6 @@ export default { props: { video: {}, buffering: { - type: Boolean, required: false, }, }, diff --git a/NUXT/components/Player/sponsorblock.vue b/NUXT/components/Player/sponsorblock.vue index d08b19f8..358bb564 100644 --- a/NUXT/components/Player/sponsorblock.vue +++ b/NUXT/components/Player/sponsorblock.vue @@ -29,7 +29,7 @@ export default { props: { blocks: { - type: Array, + // type: Array, required: true, }, duration: { diff --git a/NUXT/pages/mods/player.vue b/NUXT/pages/mods/player.vue index a03bc350..2021483c 100644 --- a/NUXT/pages/mods/player.vue +++ b/NUXT/pages/mods/player.vue @@ -430,7 +430,7 @@ export default { icon: "mdi-volume-off", }, ], - preferedCodecValue: "", + preferedCodecValue: "avc and av01", tabs: [ { label: "avc and av01", @@ -496,7 +496,9 @@ export default { }, mounted() { this.preferedCodecValue = localStorage.getItem("preferedCodec"); - const vpTab = this.tabs.find((tab) => tab.label === this.preferedCodecValue); + const vpTab = this.tabs.find( + (tab) => tab.label === this.preferedCodecValue + ); if (vpTab) { this.selectedTab = vpTab.id; } diff --git a/NUXT/plugins/youtube.js b/NUXT/plugins/youtube.js index 86c37db4..8d96ab0e 100644 --- a/NUXT/plugins/youtube.js +++ b/NUXT/plugins/youtube.js @@ -71,7 +71,8 @@ const searchModule = { url: `https://sponsor.ajay.app/api/skipSegments/` + hashedVideoId + - "?categories=%5B%22sponsor%22%2C%22poi_highlight%22%2C%22exclusive_access%22%2C%22chapter%22%2C%22selfpromo%22%2C%22interaction%22%2C%22intro%22%2C%22outro%22%2C%22preview%22%2C%22filler%22%2C%22music_offtopic%22%5D&actionTypes=%5B%22skip%22%2C%22poi%22%2C%22chapter%22%2C%22mute%22%2C%22full%22%5D&userAgent=mnjggcdmjocbbbhaepdhchncahnbgone", + // "?categories=%5B%22sponsor%22%2C%22poi_highlight%22%2C%22exclusive_access%22%2C%22chapter%22%2C%22selfpromo%22%2C%22interaction%22%2C%22intro%22%2C%22outro%22%2C%22preview%22%2C%22filler%22%2C%22music_offtopic%22%5D&actionTypes=%5B%22skip%22%2C%22poi%22%2C%22chapter%22%2C%22mute%22%2C%22full%22%5D&userAgent=mnjggcdmjocbbbhaepdhchncahnbgone", + "?categories=%5B%22sponsor%22%2C%22poi_highlight%22%2C%22exclusive_access%22%2C%22chapter%22%2C%22selfpromo%22%2C%22interaction%22%2C%22intro%22%2C%22outro%22%2C%22preview%22%2C%22filler%22%2C%22music_offtopic%22%5D&actionTypes=%5B%22skip%22%2C%22mute%22%2C%22full%22%5D&userAgent=mnjggcdmjocbbbhaepdhchncahnbgone", // params: { videoID: hashedVideoId }, }) .then((res) => { diff --git a/NUXT/store/player/index.js b/NUXT/store/player/index.js index 5ec0a026..c610aaf1 100644 --- a/NUXT/store/player/index.js +++ b/NUXT/store/player/index.js @@ -4,7 +4,7 @@ export const state = () => ({ speedAutosave: null, preload: null, preloadUpTo: 100, - preferedCodec: null, + preferedCodec: "avc and av01", // quality: null, // qualityAutoSwitch: null, // shortFullscreen: null, @@ -27,7 +27,9 @@ export const mutations = { state.preload = JSON.parse(localStorage.getItem("preload")) === true; // defaults to false state.preloadUpTo = JSON.parse(localStorage.getItem("preloadUpTo")) || 100; // defaults to 100(percent) - state.preferedCodec = localStorage.getItem("preferedCodec"); // defaults to null + state.preferedCodec = localStorage.getItem("preferedCodec") + ? localStorage.getItem("preferedCodec") + : "avc and av01"; // defaults to null } }, setLoop(state, payload) {