mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-16 16:37:18 +03:00
Add importing chapters for cases with unsubmitted segments
This commit is contained in:
@@ -812,17 +812,7 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
|
|||||||
updatePreviewBar();
|
updatePreviewBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add existing chapters if we can
|
importExistingChapters(true);
|
||||||
if (Config.config.renderAsChapters) {
|
|
||||||
GenericUtils.wait(() => getExistingChapters(sponsorVideoID, video.duration),
|
|
||||||
5000, 100, (c) => c?.length > 0).then((chapters) => {
|
|
||||||
if (!existingChaptersImported && chapters?.length > 0) {
|
|
||||||
sponsorTimes = sponsorTimes.concat(...chapters);
|
|
||||||
existingChaptersImported = true;
|
|
||||||
updatePreviewBar();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (response?.status === 404) {
|
} else if (response?.status === 404) {
|
||||||
retryFetch();
|
retryFetch();
|
||||||
}
|
}
|
||||||
@@ -830,6 +820,20 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
|
|||||||
lookupVipInformation(id);
|
lookupVipInformation(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function importExistingChapters(wait: boolean) {
|
||||||
|
if (Config.config.renderAsChapters && !existingChaptersImported
|
||||||
|
&& (sponsorTimes?.length > 0 || sponsorTimesSubmitting.length > 0)) {
|
||||||
|
GenericUtils.wait(() => video && getExistingChapters(sponsorVideoID, video.duration),
|
||||||
|
wait ? 5000 : 0, 100, (c) => c?.length > 0).then((chapters) => {
|
||||||
|
if (!existingChaptersImported && chapters?.length > 0) {
|
||||||
|
sponsorTimes = (sponsorTimes ?? []).concat(...chapters);
|
||||||
|
existingChaptersImported = true;
|
||||||
|
updatePreviewBar();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getEnabledActionTypes(): ActionType[] {
|
function getEnabledActionTypes(): ActionType[] {
|
||||||
const actionTypes = [ActionType.Skip, ActionType.Poi, ActionType.Chapter];
|
const actionTypes = [ActionType.Skip, ActionType.Poi, ActionType.Chapter];
|
||||||
if (Config.config.muteSegments) {
|
if (Config.config.muteSegments) {
|
||||||
@@ -1586,6 +1590,8 @@ function startOrEndTimingNewSegment() {
|
|||||||
|
|
||||||
updateEditButtonsOnPlayer();
|
updateEditButtonsOnPlayer();
|
||||||
updateSponsorTimesSubmitting(false);
|
updateSponsorTimesSubmitting(false);
|
||||||
|
|
||||||
|
importExistingChapters(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIncompleteSegment(): SponsorTime {
|
function getIncompleteSegment(): SponsorTime {
|
||||||
@@ -1628,6 +1634,10 @@ function updateSponsorTimesSubmitting(getFromConfig = true) {
|
|||||||
source: segmentTime.source
|
source: segmentTime.source
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sponsorTimesSubmitting.length > 0) {
|
||||||
|
importExistingChapters(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePreviewBar();
|
updatePreviewBar();
|
||||||
|
|||||||
Reference in New Issue
Block a user