]> Sergey Matveev's repositories - feeder.git/blobdiff - cmd/download-warcs.zsh
Sortable date in filenames
[feeder.git] / cmd / download-warcs.zsh
index ac9e589779d1028214230893ef75fed7477e6e61..30d8202f4d536d6aacf6ac5eb0f25e4095ad3c47 100755 (executable)
@@ -3,6 +3,8 @@ set -e
 fpath=($0:h:a/functions.zsh $fpath)
 dst=$2:a
 cd $1
+[[ -n "$dst" ]] || { dst=warcs ; dst=$dst:a }
+mkdir -p $dst
 autoload url-to-filename
 zmodload -F zsh/datetime b:strftime
 setopt EXTENDED_GLOB
@@ -26,8 +28,8 @@ for new (new/*(N)) {
             trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
             wget_opts=(--output-document=$tmp $wget_opts)
         }
-        fn=$(url-to-filename $url)-$(strftime %Y%m%d-%H%M%S)
-        wget $wget_opts --output-file=warc.log --warc-file=$dst/$fn $url
-        print $fn
+        fn=$(strftime %Y%m%d-%H%M%S)-$(url-to-filename $url)
+        wget $wget_opts --output-file=warcs.log --warc-file=$dst/$fn $url
+        print $dst/$fn.warc
     done < $new
 }