Skip to content

Commit dd2a6c9

Browse files
authored
Merge pull request #36 from atulsingh0/issue-34
added Time Jitter
2 parents 1e6b748 + 2bdf11f commit dd2a6c9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/script.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,13 @@ const downloadCourse = async (courseJSON, startingVideoId) => {
528528
let maxDuration = await readMaxDuration()
529529
// Sleep for minimum duration btw the time with percent and the max duration time
530530
if (maxDuration != 0) {
531-
CURRENT_INTERVAL = updateWaitStats(Math.min(duration * 10 * speed, maxDuration * 1000))
532-
CURRENT_SLEEP = sleep(Math.min(duration * 10 * speed, maxDuration * 1000))
531+
log(`maxDuration: ${maxDuration} duration: ${duration} speed: ${speed}`, "INFO")
532+
maxDuration = Math.floor(Math.random() * (maxDuration - Number(speed)) + Number(speed))
533+
CURRENT_INTERVAL = updateWaitStats(maxDuration * 1000)
534+
CURRENT_SLEEP = sleep(maxDuration * 1000)
535+
// CURRENT_INTERVAL = updateWaitStats(Math.min(duration * 10 * speed, maxDuration * 1000))
536+
// CURRENT_SLEEP = sleep(Math.min(duration * 10 * speed, maxDuration * 1000))
537+
log(`Sleeping for ${maxDuration} seconds...`, "INFO")
533538
await CURRENT_SLEEP
534539
CURRENT_INTERVAL.abort()
535540
}

0 commit comments

Comments
 (0)