summaryrefslogtreecommitdiffstats
path: root/bin/comics/calvin
blob: 1cfd0eca948458b22b7aa02b1faf846a1a76ce89 (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
26
27
28
#!/bin/bash

source $(pwd)/$(dirname $0)/../../etc/settings.sh
tmp=$(mktemp -d)
cd "${tmp}"

newn="${day}.gif"
month="$(date -d "$daysago days ago" +%m)"
server="http://www.gocomics.com/calvinandhobbes/$year/$month/$day"

nomen="$(wget ${wget_args} "$server" -O - | grep "class=\"strip\"" | \
    sed 's#.*<img alt="Calvin and Hobbes"[^<]*src="\([^"]*\)".*#\1#')"

echo "Dateiname: $nomen"
echo
echo "Hole calvinandhobbes von $server"
echo "fuer Datum: $(date -d"$daysago days ago" -I)"
echo

wget ${wget_args} "$nomen" -O "$newn"

if [ -s "${tmp}/${newn}" ]; then
    mv "${tmp}/${newn}" "${image_dir}/$newn"
    rm -f "${comic_dir}/latest.gif"
    ln -s "${image_offset}/$newn" "${comic_dir}/latest.gif"
fi

rm -rf "${tmp}"