mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-24 08:28:27 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into switch-axios
This commit is contained in:
@@ -59,7 +59,7 @@ export async function getSkipSegmentsByHash(req: Request, res: Response): Promis
|
||||
return res.status(400).send("Bad parameter: requiredSegments (invalid JSON)");
|
||||
}
|
||||
|
||||
const service = getService(req.query.service, req.body.service);
|
||||
const service: Service = getService(req.query.service, req.body.service);
|
||||
|
||||
// filter out none string elements, only flat array with strings is valid
|
||||
categories = categories.filter((item: any) => typeof item === "string");
|
||||
|
||||
@@ -449,8 +449,8 @@ async function updateDataIfVideoDurationChange(videoID: VideoID, service: string
|
||||
|
||||
let apiVideoInfo: APIVideoInfo = null;
|
||||
if (service == Service.YouTube) {
|
||||
// Don't use cache if we don't know the video duraton, or the client claims that it has changed
|
||||
apiVideoInfo = await getYouTubeVideoInfo(videoID, !videoDurationParam || videoDurationChanged(videoDurationParam));
|
||||
// Don't use cache if we don't know the video duration, or the client claims that it has changed
|
||||
apiVideoInfo = await getYouTubeVideoInfo(videoID, !videoDurationParam || previousSubmissions.length === 0 || videoDurationChanged(videoDurationParam));
|
||||
}
|
||||
const apiVideoDuration = apiVideoInfo?.data?.lengthSeconds as VideoDuration;
|
||||
if (!videoDurationParam || (apiVideoDuration && Math.abs(videoDurationParam - apiVideoDuration) > 2)) {
|
||||
|
||||
@@ -35,12 +35,12 @@ export class YouTubeAPI {
|
||||
Logger.warn(`NewLeaf API Error for ${videoID}: ${data.error}`);
|
||||
return { err: data.error, data: null };
|
||||
}
|
||||
|
||||
DiskCache.set(cacheKey, JSON.stringify(data))
|
||||
const apiResult = data as APIVideoData;
|
||||
DiskCache.set(cacheKey, JSON.stringify(apiResult))
|
||||
.catch((err: any) => Logger.warn(err))
|
||||
.then(() => Logger.debug(`YouTube API: video information cache set for: ${videoID}`));
|
||||
|
||||
return { err: false, data };
|
||||
return { err: false, data: apiResult };
|
||||
} else {
|
||||
return { err: result.statusText, data: null };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user