sponsorblock

This commit is contained in:
Sushi 2022-05-31 20:50:55 -06:00
parent 339bd4eb15
commit 3acb70ca06
2 changed files with 30 additions and 0 deletions

View File

@ -213,6 +213,21 @@ export default {
this.vidSrc = this.sources[this.sources.length - 1].url;
// TODO: detect orientation change and enter fullscreen
// TODO: detect video loading state and send this.loading to play button :loading = loading
this.$youtube.getSponsorBlock(this.$route.query.v, (data) => {
sponsorBlock = data.segment;
});
this.$refs.player.ontimeupdate = () => {
let vidTime = this.$refs.player.currentTime;
for (let i = 0; i < sponsorBlock.length; i++) {
if (vidTime > sponsorBlock[i][0] && vidTime < sponsorBlock[0][i]) {
this.$refs.player.currentTime = sponsorBlock[i][0];
break;
}
}
}
},
beforeDestroy() {
if (this.isFullscreen) this.exitFullscreen();

View File

@ -64,6 +64,21 @@ const searchModule = {
callback(err);
});
},
getSponsorBlock(id, callback) {
Http.request({
method: "GET",
url: `https://sponsor.ajay.app/api/skipSegments`,
params: { videoID: id },
})
.then((res) => {
logger("sponsorBlock", res.data);
callback(res.data);
})
.catch((err) => {
logger("codeRun", err, true);
callback(err);
});
}
};
//--- Recommendations ---//