mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-30 19:38:28 +03:00
Add fallback video duration when finding random timestamp
This commit is contained in:
@@ -221,7 +221,7 @@ export function findRandomTime(videoID: VideoID, segments: BrandingSegmentDBResu
|
|||||||
const randomTime = SeedRandom.alea(videoID)();
|
const randomTime = SeedRandom.alea(videoID)();
|
||||||
if (segments.length === 0) return randomTime;
|
if (segments.length === 0) return randomTime;
|
||||||
|
|
||||||
const videoDuration = segments[0].videoDuration;
|
const videoDuration = segments[0].videoDuration || Math.max(...segments.map((s) => s.endTime));
|
||||||
|
|
||||||
// There are segments, treat this as a relative time in the chopped up video
|
// There are segments, treat this as a relative time in the chopped up video
|
||||||
const sorted = segments.sort((a, b) => a.startTime - b.startTime);
|
const sorted = segments.sort((a, b) => a.startTime - b.startTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user