From e38940da43801c22f7ece69a3a00aae709610327 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 23 Jan 2022 20:22:29 +0100 Subject: add almanac / ical feed syncing --- home/scripts/sync.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 home/scripts/sync.scm (limited to 'home/scripts/sync.scm') 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) -- cgit v1.2.3