summaryrefslogtreecommitdiffstats
path: root/bin/comics/extrafabulous
diff options
context:
space:
mode:
Diffstat (limited to 'bin/comics/extrafabulous')
-rwxr-xr-xbin/comics/extrafabulous44
1 files changed, 44 insertions, 0 deletions
diff --git a/bin/comics/extrafabulous b/bin/comics/extrafabulous
new file mode 100755
index 0000000..9b70f78
--- /dev/null
+++ b/bin/comics/extrafabulous
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+if [ -z "$1" -o ! -d "$1" ]; then
+ echo "Usage: $0 <top-directory> [<days ago>]" 1>&2
+ exit 1
+fi
+
+top="${1}"
+shift
+
+source "${top}/etc/settings.sh"
+tmp="$(mktemp -d)"
+cd "${tmp}"
+
+export LANG=C
+export LC_ALL=C
+
+DATE=$(date -d"$daysago days ago" +"%d %b %Y")
+
+URL=$(wget "http://extrafabulouscomics.com/feed/" -O - | sed -n -re "/pubDate.+$DATE/ { n; n; n; n; s/.+(http:\/\/extrafabulouscomics.com\/comic\/[0-9]+\/).+/\1/p; q }")
+
+if [ -z $URL ]; then
+ echo "Nichts gefunden für $DATE"
+ exit 0
+fi
+echo URL $URL gefunden
+
+URL=$(wget -O - "$URL" | sed -nre 's#.*<img src="(http://extrafabulouscomics.com/wp-content/[^"]+)".+#\1#p')
+
+if [ -z $URL ]; then
+ echo "Comic URL nicht gefunden!!"
+ exit 1
+fi
+echo Comic URL $URL
+
+
+wget -O "${tmp}/${day}.gif" $URL
+
+if [ -s "${tmp}/${day}.gif" ]; then
+ mv "${tmp}/${day}.gif" "${image_dir}/${day}.gif"
+ ln -s "${image_dir}/${day}.gif" "${comic_dir}/latest.gif"
+fi
+
+rm -rf "${tmp}"