summaryrefslogtreecommitdiff
path: root/.local/bin/web/savesite
diff options
context:
space:
mode:
authorVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:30:52 +0530
committerVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:30:52 +0530
commit5c916d69d457101326803eb076a746060e3618cf (patch)
treed6fce3256eede1c1bf78fb6a1be75b9cc4b84cee /.local/bin/web/savesite
Moved from github
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"