mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 22:47:18 +03:00
Clean segment recieving code
This commit is contained in:
@@ -568,25 +568,15 @@ async function sponsorsLookup(id: string) {
|
|||||||
categories
|
categories
|
||||||
}).then(async (response: FetchResponse) => {
|
}).then(async (response: FetchResponse) => {
|
||||||
if (response?.ok) {
|
if (response?.ok) {
|
||||||
let result = JSON.parse(response.responseText);
|
const recievedSegments: SponsorTime[] = JSON.parse(response.responseText)
|
||||||
result = result.filter((video) => video.videoID === id);
|
?.filter((video) => video.videoID === id)
|
||||||
if (result.length > 0) {
|
?.map((video) => video.segments)[0];
|
||||||
result = result[0].segments;
|
if (!recievedSegments || !recievedSegments.length) {
|
||||||
if (result.length === 0) { // return if no segments found
|
// return if no video found
|
||||||
retryFetch();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else { // return if no video found
|
|
||||||
retryFetch();
|
retryFetch();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const recievedSegments: SponsorTime[] = result;
|
|
||||||
if (!recievedSegments.length) {
|
|
||||||
console.error("[SponsorBlock] Server returned malformed response: " + JSON.stringify(recievedSegments));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sponsorDataFound = true;
|
sponsorDataFound = true;
|
||||||
|
|
||||||
// Check if any old submissions should be kept
|
// Check if any old submissions should be kept
|
||||||
|
|||||||
Reference in New Issue
Block a user