From 38e44dd60b2d9d1214373bba9721a7c15e50f263 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sat, 30 Jul 2022 19:56:55 +0300
Subject: [PATCH] New sync-podcasts script.

Use wget over WebDAV instead of unison over SSH. Should be faster and
more portable.
---
 .bashrc                     |  5 -----
 .unison/podcasts.prf        |  7 -------
 Documents/bin/sync-podcasts | 18 ++++++++++++++++++
 3 files changed, 18 insertions(+), 12 deletions(-)
 delete mode 100644 .unison/podcasts.prf
 create mode 100755 Documents/bin/sync-podcasts

diff --git a/.bashrc b/.bashrc
index df3cd47..f01fcbb 100644
--- a/.bashrc
+++ b/.bashrc
@@ -306,11 +306,6 @@ sync_comics () {
     find "$HOME/Downloads/Comics/" -name "$(date --date '2 month ago' +'0-Day\ Week\ of\ %Y.%m.*')" -exec rm -r {} +
 }
 
-sync_podcasts () (
-    cd || exit 1
-    unison podcasts
-)
-
 temp_venv () {
     cdtemp
     venv .
diff --git a/.unison/podcasts.prf b/.unison/podcasts.prf
deleted file mode 100644
index b3c6ca2..0000000
--- a/.unison/podcasts.prf
+++ /dev/null
@@ -1,7 +0,0 @@
-root = Downloads/Podcasts/
-root = ssh://kodi.shore.co.il//srv/library/nimrod/Podcasts
-path = .
-batch = true
-
-#nocreation
-#nodeletion
diff --git a/Documents/bin/sync-podcasts b/Documents/bin/sync-podcasts
new file mode 100755
index 0000000..5799f01
--- /dev/null
+++ b/Documents/bin/sync-podcasts
@@ -0,0 +1,18 @@
+#!/bin/sh
+set -eu
+
+XDG_DOWNLOAD_DIR="${XDG_DOWNLOAD_DIR:-$HOME/Downloads}"
+mkdir -p "$XDG_DOWNLOAD_DIR/Podcasts"
+
+exec wget \
+    --continue \
+    --cut-dirs=3 \
+    --directory-prefix "$XDG_DOWNLOAD_DIR/Podcasts" \
+    --mirror \
+    --no-host-directories \
+    --no-parent \
+    --recursive \
+    --reject '*.htm,*.html,index.htm*,robots.txt' \
+    --show-progress \
+    --user-agent sync-podcasts \
+    https://library.shore.co.il/webdav/nimrod/Podcasts/
-- 
GitLab