summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhillip Berndt <pberndt@spline.de>2013-09-11 08:51:31 +0200
committerPhillip Berndt <pberndt@spline.de>2015-05-20 09:33:11 +0200
commit87787a99091ef927692138227c4f1d1830a086cf (patch)
treeaa84d96570749e080ae05fdcfb8773688e683a5f
parent4271467f2d05fa36baab6bd6e17316f280a2fc5e (diff)
downloadcomics-87787a99091ef927692138227c4f1d1830a086cf.tar.gz
comics-87787a99091ef927692138227c4f1d1830a086cf.tar.bz2
comics-87787a99091ef927692138227c4f1d1830a086cf.zip
New comics: Cyanide and Happiness, PHD comics
-rwxr-xr-xbin/comics/cyanide49
-rwxr-xr-xbin/comics/phdcomics25
-rwxr-xr-xbin/gen.py10
3 files changed, 84 insertions, 0 deletions
diff --git a/bin/comics/cyanide b/bin/comics/cyanide
new file mode 100755
index 0000000..813d17c
--- /dev/null
+++ b/bin/comics/cyanide
@@ -0,0 +1,49 @@
+#!/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
+export LC_TIME=C
+year=`date -d "$daysago days ago 00:00:00" +%Y`
+month=`date -d "$daysago days ago 00:00:00" +%B`
+day=`date -d "$daysago days ago 00:00:00" +%d`
+
+part=`curl -s "http://explosm.net/comics/archive/$year/" | grep -oE "${month}.+</table>" | sed -nre "s#.+href=\"([^\"]+)\">[^/]+${day}<.+#\1#p"`
+if [ -z "$part" ]; then
+ echo "Cyanide and Happyness: Kein Comic für $year, $month $day"
+ exit
+fi
+
+htmladdress="http://explosm.net/$part"
+echo "Cyanide and happyness: $htmladdress gefunden"
+
+browser="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i586)"
+
+echo "Lese URL von $htmladdress"
+url=$(wget ${wget_args} -O - --user-agent="$browser" "$htmladdress" | grep -oE 'http://www.explosm.net/db/files/Comics/[^"]+')
+
+if [ -n $url ]; then
+ echo "Dateiname: $url"
+ echo "Hole cyanide and happyness für Datum: $(date -d"$daysago days ago" -I)"
+
+ wget ${wget_args} --user-agent="$browser" -O "$day.png" "$url"
+
+ if [ -s "${day}.png" ]; then
+ mv ${day}.png "${image_dir}/$day.png"
+ rm -f "${comic_dir}/latest.png"
+ ln -s "${image_offset}/$day.png" "${comic_dir}/latest.png"
+ fi
+fi
+
+rm -rf "${tmp}"
diff --git a/bin/comics/phdcomics b/bin/comics/phdcomics
new file mode 100755
index 0000000..f05304a
--- /dev/null
+++ b/bin/comics/phdcomics
@@ -0,0 +1,25 @@
+#!/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"
+
+img="http://www.phdcomics.com/comics/archive/phd$(date -d "$daysago days ago" +%m%d%y)s.gif"
+
+browser="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i586)"
+
+echo "Versuche, $img zu laden"
+wget -O "${image_dir}/$day.gif" --user-agent="$browser" "$img"
+
+if [ -s "${image_dir}/$day.gif" ]; then
+ rm -f "${comic_dir}/latest.gif"
+ ln -s "${image_offset}/$day.gif" "${comic_dir}/latest.gif"
+else
+ rm -f "${image_dir}/$day.gif"
+fi
diff --git a/bin/gen.py b/bin/gen.py
index fcd4f65..8565499 100755
--- a/bin/gen.py
+++ b/bin/gen.py
@@ -72,6 +72,16 @@ comics = {
"imageformat": "gif",
"url": "http://www.gocomics.com/peanuts"
},
+ "cyanide": {
+ "name": "Cyanide and Happiness",
+ "imageformat": "png",
+ "url": "http://www.explosm.net/comics/"
+ },
+ "phdcomics": {
+ "name": "PHD comics",
+ "imageformat": "gif",
+ "url": "http://www.phdcomics.com/comics/archive.php"
+ },
}