mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-15 07:57:09 +03:00
Import chapters with no segments as well
This commit is contained in:
@@ -27,7 +27,7 @@ utils.wait(() => Config.config !== null, 5000, 10).then(addCSS);
|
|||||||
//was sponsor data found when doing SponsorsLookup
|
//was sponsor data found when doing SponsorsLookup
|
||||||
let sponsorDataFound = false;
|
let sponsorDataFound = false;
|
||||||
//the actual sponsorTimes if loaded and UUIDs associated with them
|
//the actual sponsorTimes if loaded and UUIDs associated with them
|
||||||
let sponsorTimes: SponsorTime[] = null;
|
let sponsorTimes: SponsorTime[] = [];
|
||||||
let existingChaptersImported = false;
|
let existingChaptersImported = false;
|
||||||
//what video id are these sponsors for
|
//what video id are these sponsors for
|
||||||
let sponsorVideoID: VideoID = null;
|
let sponsorVideoID: VideoID = null;
|
||||||
@@ -302,7 +302,7 @@ function resetValues() {
|
|||||||
lastCheckTime = 0;
|
lastCheckTime = 0;
|
||||||
lastCheckVideoTime = -1;
|
lastCheckVideoTime = -1;
|
||||||
|
|
||||||
sponsorTimes = null;
|
sponsorTimes = [];
|
||||||
existingChaptersImported = false;
|
existingChaptersImported = false;
|
||||||
sponsorSkipped = [];
|
sponsorSkipped = [];
|
||||||
|
|
||||||
@@ -958,8 +958,7 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importExistingChapters(wait: boolean) {
|
function importExistingChapters(wait: boolean) {
|
||||||
if (!existingChaptersImported
|
if (!existingChaptersImported) {
|
||||||
&& (sponsorTimes?.length > 0 || sponsorTimesSubmitting.length > 0)) {
|
|
||||||
GenericUtils.wait(() => video && getExistingChapters(sponsorVideoID, video.duration),
|
GenericUtils.wait(() => video && getExistingChapters(sponsorVideoID, video.duration),
|
||||||
wait ? 5000 : 0, 100, (c) => c?.length > 0).then((chapters) => {
|
wait ? 5000 : 0, 100, (c) => c?.length > 0).then((chapters) => {
|
||||||
if (!existingChaptersImported && chapters?.length > 0) {
|
if (!existingChaptersImported && chapters?.length > 0) {
|
||||||
@@ -1003,7 +1002,8 @@ function retryFetch(): void {
|
|||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (sponsorVideoID && sponsorTimes?.length === 0) {
|
if (sponsorVideoID && sponsorTimes?.length === 0
|
||||||
|
|| sponsorTimes.every((segment) => segment.source !== SponsorSourceType.Server)) {
|
||||||
sponsorsLookup();
|
sponsorsLookup();
|
||||||
}
|
}
|
||||||
}, 10000 + Math.random() * 30000);
|
}, 10000 + Math.random() * 30000);
|
||||||
|
|||||||
Reference in New Issue
Block a user