summaryrefslogtreecommitdiff
path: root/.local/bin/web/savesite
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/web/savesite')
-rwxr-xr-x.local/bin/web/savesite35
1 files changed, 35 insertions, 0 deletions
diff --git a/.local/bin/web/savesite b/.local/bin/web/savesite
new file mode 100755
index 0000000..206a633
--- /dev/null
+++ b/.local/bin/web/savesite
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+[ "$#" -lt 1 ] && { echo "savesite - save local copy of a website
+USAGE: savesite <URL> [DEST_DIR]"; exit 1; }
+
+url="$1"
+site="${2:-"$(echo "$url" | sed 's|\(https\?://\)\?\([A-Za-z0-9.-]*\)/.*|\2|')"}"
+WGETLOGS="${3:-.logs/$site.log}"
+started="$(date)"
+
+touch "$WGETLOGS" || exit
+printf ":: Downloading site: %s\n" "$site"
+printf ":: Logging to: %s\n" "$WGETLOGS"
+
+{
+ setsid wget \
+ --continue \
+ --recursive \
+ --no-clobber \
+ --page-requisites \
+ --html-extension \
+ --convert-links \
+ --restrict-file-names=windows \
+ --domains "$site" \
+ --no-parent \
+ --output-file "$WGETLOGS" \
+ "$url"
+
+ [ -n "$DISPLAY" ] && notify-send "savesite: finished downloading" "$site"
+ printf "%s\n" ":: Finished downloading site: $site" \
+ ":: Started at: $started" \
+ ":: Finished at: $(date)" >> "$WGETLOGS"
+} &
+
+tail -f "$WGETLOGS"