From 1e9051ac4b608b35b7a47536e03ba677871f7409 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Sun, 19 Feb 2023 15:21:21 +0100 Subject: Randomise yt-dlp times better --- tw/services/media.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tw/services/media.scm') diff --git a/tw/services/media.scm b/tw/services/media.scm index 6d82765a..4bff1818 100644 --- a/tw/services/media.scm +++ b/tw/services/media.scm @@ -15,18 +15,20 @@ (define (string-or-gexp? value) (or (string? value) (gexp? value))) -(define random-hour-every-second-night +(define random-time-every-second-night #~(lambda (now) (let* ((even-day (if (even? (tm:yday (localtime now))) now (next-day-from now))) - ;; Between 1 and 6 a.m., randomly, but deterministically for each - ;; day (to avoid runs being skipped in case mcron is restarted). - (hour-of-day - (1+ (random 6 (seed->random-state - (tm:yday (localtime even-day))))))) - (next-hour-from even-day (list hour-of-day))))) + (deterministic-value + (number->string (tm:yday (localtime even-day))))) + ;; Between 1 and 6 a.m., randomly, but deterministically for each + ;; day (to avoid runs being skipped in case mcron is restarted). + ;; (random 6 (seed->random-state yday)) isn't chaotic enough. + (next-minute-from + (next-hour-from even-day (list (1+ (string-hash deterministic-value 6)))) + (list (string-hash deterministic-value 60)))))) (define-configuration/no-serialization yt-dlp-configuration (media-directory string "The directory in which to store downloaded media. -- cgit v1.2.3