Skip to content

Commit

Permalink
fix: Sponsorblock fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pixkk committed Apr 6, 2024
1 parent d2a1d71 commit 6cf16d0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
8 changes: 7 additions & 1 deletion NUXT/components/Player/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand All @@ -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];
Expand All @@ -604,6 +606,9 @@ export default {
// });
});
},
endedEvent() {
this.videoEnded = true;
},
progressEvent() {
if (this.bufferingDetected) {
this.$refs.audio.currentTime = this.vid.currentTime;
Expand All @@ -630,6 +635,7 @@ export default {
}
},
playingEvent() {
this.videoEnded = false;
if (this.bufferingDetected != false) {
clearTimeout(this.bufferingDetected);
this.$refs.audio.currentTime = this.vid.currentTime;
Expand Down
1 change: 0 additions & 1 deletion NUXT/components/Player/playpause.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default {
props: {
video: {},
buffering: {
type: Boolean,
required: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion NUXT/components/Player/sponsorblock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
export default {
props: {
blocks: {
type: Array,
// type: Array,
required: true,
},
duration: {
Expand Down
6 changes: 4 additions & 2 deletions NUXT/pages/mods/player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export default {
icon: "mdi-volume-off",
},
],
preferedCodecValue: "",
preferedCodecValue: "avc and av01",
tabs: [
{
label: "avc and av01",
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion NUXT/plugins/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 4 additions & 2 deletions NUXT/store/player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 6cf16d0

Please sign in to comment.