Skip to content

Commit

Permalink
feat: (Beta) skipping sponsor blocks manually.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixkk committed Dec 15, 2024
1 parent 047b6de commit 7a4168c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
54 changes: 45 additions & 9 deletions NUXT/components/Player/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@
>
<track default kind="captions" id="captions" src=""/>
</video>
<button id="skipButton"
ref="skipButton" class="skip-button"
:style="{
backgroundColor: 'primary',
display: isSegment ? 'block' : 'none',
}"

>Skip {{ sBblockCategoryText }}</button>

<audio ref="audio" mediagroup="vuetubecute" :src="hls || dash ? '' : audSrc" />

<!-- // TODO: merge the bottom 2 into 1 reusable component -->
Expand Down Expand Up @@ -444,10 +453,14 @@ export default {
isMusic: false,
sponsorBlocks: [],
vid: null,
isSegment: false,
sBblockCategoryText: "",
endBlockTime: -1,
poster: "",
};
},
async mounted() {
this.isSegment = false;
this.poster = await $youtube.getThumbnail(this.$route.query.v, '', []);
console.log("SPSR BLCK" + this.sponsorBlocks);
Expand Down Expand Up @@ -714,21 +727,31 @@ export default {
let vidTime = this.vid.currentTime;
// this.sponsorBlocks = data;
// console.warn(data);
this.endBlockTime = -1;
this.sponsorBlocks?.segments?.forEach((block) => {
// block.segments.forEach((segments) => {
// console.log(this.vid.duration);
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];
if (this.vid.duration < block.segment[1]) {
this.videoEnded = true;
// this.vid.pause();
if (vidTime >= block.segment[0] && vidTime < block.segment[1]) {
this.endBlockTime = block.segment[1];
this.isSegment = true;
this.sBblockCategoryText = block.category;
this.$refs.skipButton.onclick = skipSegment.bind(null, this.$refs.player, this.vid.duration, this.$youtube, block.segment[1], block.category);
function skipSegment(param1, param2, param3, param4, param5) {
console.log("skipped");
param1.currentTime = param4;
param3.showToast("Skipped " + param5 + " sponsor");
}
// this.$refs.audio.currentTime = this.$refs.player.currentTime;
return;
}
// this.$refs.audio.currentTime = this.$refs.player.currentTime;
}
// });
});
if (vidTime > this.endBlockTime) {
this.isSegment = false;
}
},
endedEvent() {
this.videoEnded = true;
Expand Down Expand Up @@ -1030,4 +1053,17 @@ export default {
transform: translateY(10%) !important;
}
}
.skip-button {
position: absolute;
bottom: 10px;
right: 10px;
margin-bottom: 5rem;
background-color: var(--v-primary-base);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
//display: block;
z-index: 9999;
}
</style>
2 changes: 1 addition & 1 deletion NUXT/pages/mods/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
color: 'var(--v-primary-base)',
}"
>
{{ "mdi-block-helper" }}
{{ "mdi-account-cancel" }}
</v-icon>
<div
class="my-auto pa-4 ml-n4 background ma-0"
Expand Down
6 changes: 3 additions & 3 deletions NUXT/pages/mods/sponsorblock/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
>
{{
sponsorBlockIntegration
? "mdi-block-helper"
: "mdi-block-helper"
? "mdi-account-cancel"
: "mdi-account-cancel"
}}
</v-icon>
<div
Expand All @@ -79,7 +79,7 @@
:class="$vuetify.theme.dark ? 'text--lighten-4' : 'text--darken-4'"
style="font-size: 0.75rem; margin-top: -0.25rem !important"
>
Enable SponsorBlock integration with skipping all segments.
Enable SponsorBlock integration.
</div>
</div>
<v-switch
Expand Down
2 changes: 1 addition & 1 deletion NUXT/pages/mods/sponsorblock/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default {
settingsItems: [
{
name: "SponsorBlock General",
icon: "mdi-block-helper",
icon: "mdi-account-cancel",
to: "/mods/sponsorblock/general",
},
],
Expand Down

0 comments on commit 7a4168c

Please sign in to comment.