diff --git a/tubearchivist/home/templates/home/video.html b/tubearchivist/home/templates/home/video.html
index d1ff3a7..3848f16 100644
--- a/tubearchivist/home/templates/home/video.html
+++ b/tubearchivist/home/templates/home/video.html
@@ -5,31 +5,11 @@
diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js
index ee95b6f..4031ec0 100644
--- a/tubearchivist/static/script.js
+++ b/tubearchivist/static/script.js
@@ -333,24 +333,21 @@ function createPlayer(button) {
var videoData = getVideoData(videoId);
var sponsorBlockElements = '';
- if (videoData.config.downloads.integrate_sponsorblock && (typeof(videoData.data.channel.channel_overwrites) == "undefined" || typeof(videoData.data.channel.channel_overwrites.integrate_sponsorblock) == "undefined" || videoData.data.channel.channel_overwrites.integrate_sponsorblock == true)) {
+ if (videoData.data.sponsorblock.is_enabled) {
sponsorBlock = videoData.data.sponsorblock;
- if (!sponsorBlock) {
+ if (sponsorBlock.segments.length == 0) {
sponsorBlockElements = `
`;
} else {
- for(let i in sponsorBlock) {
- if(sponsorBlock[i].locked != 1) {
- sponsorBlockElements = `
-
- `;
- break;
- }
+ if (sponsorBlock.has_unlocked) {
+ sponsorBlockElements = `
+
+ `;
}
}
}
@@ -425,53 +422,6 @@ function createPlayer(button) {
divPlayer.innerHTML = markup;
}
-// function sendSponsorBlockVote(uuid, vote) {
-// var videoId = getVideoPlayerVideoId();
-// postSponsorSegmentVote(videoId, uuid, vote);
-// }
-
-// var sponsorBlockTimestamps = [];
-// function sendSponsorBlockSegment() {
-// var videoId = getVideoPlayerVideoId();
-// var currentTime = getVideoPlayerCurrentTime();
-// var sponsorBlockElement = document.getElementById("sponsorblock");
-// if (sponsorBlockTimestamps[1]) {
-// if (sponsorBlockTimestamps[1] > sponsorBlockTimestamps[0]) {
-// postSponsorSegment(videoId, sponsorBlockTimestamps[0], sponsorBlockTimestamps[1]);
-// sponsorBlockElement.innerHTML = `
-// Timestamps sent! (Not really)
-// `;
-// setTimeout(function(){
-// sponsorBlockElement.innerHTML = `
-// Start
-// `;
-// }, 3000);
-// } else {
-// sponsorBlockElement.innerHTML = `
-// Invalid Timestamps!
-// `;
-// setTimeout(function(){
-// sponsorBlockElement.innerHTML = `
-// Start
-// `;
-// }, 3000);
-// }
-// sponsorBlockTimestamps = [];
-// } else if (sponsorBlockTimestamps[0]) {
-// sponsorBlockTimestamps.push(currentTime);
-// sponsorBlockElement.innerHTML = `
-// ${sponsorBlockTimestamps[0].toFixed(1)} s |
-// ${sponsorBlockTimestamps[1].toFixed(1)} s |
-// Confirm
-// `;
-// } else {
-// sponsorBlockTimestamps.push(currentTime);
-// sponsorBlockElement.innerHTML = `
-// End
-// `;
-// }
-// }
-
// Add video tag to video page when passed a video id, function loaded on page load `video.html (115-117)`
function insertVideoTag(videoData, videoProgress) {
var videoTag = createVideoTag(videoData, videoProgress);
@@ -563,23 +513,14 @@ function onVideoProgress() {
var videoElement = getVideoPlayer();
// var sponsorBlockElement = document.getElementById("sponsorblock");
var notificationsElement = document.getElementById("notifications");
- if (sponsorBlock) {
- for(let i in sponsorBlock) {
- if(sponsorBlock[i].segment[0] <= currentTime + 0.3 && sponsorBlock[i].segment[0] >= currentTime) {
- videoElement.currentTime = sponsorBlock[i].segment[1];
- notificationsElement.innerHTML += ``;
+ if (sponsorBlock.segments.length > 0) {
+ for(let i in sponsorBlock.segments) {
+ if(sponsorBlock.segments[i].segment[0] <= currentTime + 0.3 && sponsorBlock.segments[i].segment[0] >= currentTime) {
+ videoElement.currentTime = sponsorBlock.segments[i].segment[1];
+ notificationsElement.innerHTML += ``;
}
- // if(currentTime >= sponsorBlock[i].segment[1] && currentTime <= sponsorBlock[i].segment[1] + 0.2) {
- // if(sponsorBlock[i].locked != 1) {
- // sponsorBlockElement.innerHTML += `
- // `;
- // }
- // }
- if(currentTime > sponsorBlock[i].segment[1] + 10) {
- var notificationsElementUUID = document.getElementById("notification-" + sponsorBlock[i].UUID);
+ if(currentTime > sponsorBlock.segments[i].segment[1] + 10) {
+ var notificationsElementUUID = document.getElementById("notification-" + sponsorBlock.segments[i].UUID);
if(notificationsElementUUID) {
notificationsElementUUID.outerHTML = '';
}
@@ -602,6 +543,12 @@ function onVideoEnded() {
if (!getVideoPlayerWatchStatus()) { // Check if video is already marked as watched
updateVideoWatchStatus(videoId, "unwatched");
}
+ for(let i in sponsorBlock.segments) {
+ var notificationsElementUUID = document.getElementById("notification-" + sponsorBlock.segments[i].UUID);
+ if(notificationsElementUUID) {
+ notificationsElementUUID.outerHTML = '';
+ }
+ }
}
function watchedThreshold(currentTime, duration) {