summaryrefslogtreecommitdiffstats
path: root/bin/comics/phdcomics
blob: d5fb122c8dff429f05ca7a72bbaf373d2d0bd2ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0"

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