summaryrefslogtreecommitdiff
path: root/tw
diff options
context:
space:
mode:
authorTimo Wilken2023-02-19 15:21:21 +0100
committerTimo Wilken2023-02-19 15:21:21 +0100
commit1e9051ac4b608b35b7a47536e03ba677871f7409 (patch)
tree9e8dc070fb8e386e6bc8a471e4e34193c5310689 /tw
parentaeb5227e4ed2468ce497cccd69391a93acf08820 (diff)
Randomise yt-dlp times better
Diffstat (limited to 'tw')
-rw-r--r--tw/services/media.scm16
1 files changed, 9 insertions, 7 deletions
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.