mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Fix random time calculator for starting empty segment
This commit is contained in:
parent
fe185234cf
commit
1cacb2dd69
1 changed files with 3 additions and 5 deletions
|
@ -228,13 +228,11 @@ export function findRandomTime(videoID: VideoID, segments: BrandingSegmentDBResu
|
|||
const emptySegments: [number, number][] = [];
|
||||
let totalTime = 0;
|
||||
|
||||
let nextEndTime = -1;
|
||||
let nextEndTime = 0;
|
||||
for (const segment of sorted) {
|
||||
if (segment.startTime > nextEndTime) {
|
||||
if (nextEndTime !== -1) {
|
||||
emptySegments.push([nextEndTime, segment.startTime]);
|
||||
totalTime += segment.startTime - nextEndTime;
|
||||
}
|
||||
emptySegments.push([nextEndTime, segment.startTime]);
|
||||
totalTime += segment.startTime - nextEndTime;
|
||||
}
|
||||
|
||||
nextEndTime = Math.max(segment.endTime, nextEndTime);
|
||||
|
|
Loading…
Reference in a new issue