Fix video duration precision and use submitted one when possible

This commit is contained in:
Ajay Ramachandran
2021-03-26 18:35:25 -04:00
parent 27c2562a7f
commit c7eb5fed35
2 changed files with 34 additions and 1 deletions

View File

@@ -423,7 +423,11 @@ export async function postSkipSegments(req: Request, res: Response) {
if (service == Service.YouTube) {
apiVideoInfo = await getYouTubeVideoInfo(videoID);
}
videoDuration = getYouTubeVideoDuration(apiVideoInfo) || videoDuration;
const apiVideoDuration = getYouTubeVideoDuration(apiVideoInfo);
if (!apiVideoDuration || Math.abs(videoDuration - apiVideoDuration) > 2) {
// If api duration is far off, take that one instead (it is only precise to seconds, not millis)
videoDuration = apiVideoDuration;
}
// Auto moderator check
if (!isVIP && service == Service.YouTube) {