summaryrefslogtreecommitdiffstats
path: root/bin/comics/erzaehlmirnix
blob: 229c2d8d4b946574c6a77586540ee41a4d39d914 (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
29
30
31
#!/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}"

webaddress="https://erzaehlmirnix.wordpress.com/$(date -d"$daysago days ago" +%Y/%m/%d)"
grepurl="https://erzaehlmirnix.files.wordpress.com/$(date -d"$daysago days ago" +%Y/%m)"
newn="${day}.png"

echo "Search $webaddress"
STRIP=$(curl -L "$webaddress" | grep -oE ${grepurl}'/[^"]+' | head -n1)
echo "Strip URL $STRIP"

if [ -n "$STRIP" ]; then
	wget ${wget_args} "$STRIP" -O erzaehlmirnix.png
	mv "erzaehlmirnix.png" "${image_dir}/$newn"
	rm -f "${comic_dir}/latest.png"
	ln -s "${image_offset}/$newn" "${comic_dir}/latest.png"
fi

cd ..
rm -rf "${tmp}"