diff options
author | stuebinm | 2022-01-23 20:22:29 +0100 |
---|---|---|
committer | stuebinm | 2022-01-24 00:05:38 +0100 |
commit | e38940da43801c22f7ece69a3a00aae709610327 (patch) | |
tree | 3b38d779923c7c50980bc1f3b0c37b39bfd3dbc4 /home/scripts | |
parent | 5f532cabbfc02dcab366e5b83b261b386d128b96 (diff) |
add almanac / ical feed syncing
Diffstat (limited to '')
-rwxr-xr-x | home/scripts/sync.scm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/home/scripts/sync.scm b/home/scripts/sync.scm new file mode 100755 index 0000000..a51b557 --- /dev/null +++ b/home/scripts/sync.scm @@ -0,0 +1,28 @@ +#!/usr/bin/env gosh + +;; download the given files to ~/.cache/feedsync under hashed filenames +;; if the versions there are older than two hours + +(use util.match) +(use gauche.process) + + +(define targets + (cdr (command-line))) + +(define cachedir + (string-append (sys-getenv "HOME") "/.cache/feedsync")) + +(do-process `("mkdir" "-p" ,cachedir)) + +(map (lambda (target) + (let ([cachefile (format "~a/~a.ics" cachedir (portable-hash target 0))]) + (cond + [(not (file-exists? cachefile)) + (do-process `("curl" ,target "-o" ,cachefile))] + [(< 7200 (- (sys-time) (sys-stat->mtime (sys-stat cachefile)))) + (print (format "fetching ~a" target)) + (do-process `("curl" ,target "-o" ,cachefile))] + [else + (display "time limit not yet exceeded")]))) + targets) |