blob: f5cfa8915a341cc37b909431a1d9fde04052c283 (
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
32
33
34
35
36
37
38
39
40
|
#!/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}"
LC_ALL=C
browser="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0"
newn="${day}.jpg"
echo "debug: daysago=$daysago, i.e. day=$(date -d "$daysago days ago" +%m)"
echo "debug: grep for /geekandpoke/`date -d "$daysago days ago" +%Y`/$(echo $[$(date -d "$daysago days ago" +%m)])/$(echo $[$(date -d "$daysago days ago" +%d)])/[^\"]+"
posturl=$(wget -q -O - "http://geek-and-poke.com/" | grep -oE "/geekandpoke/`date -d "$daysago days ago" +%Y`/$(echo $[$(date -d "$daysago days ago" +%m)])/$(echo $[$(date -d "$daysago days ago" +%d)])/[^\"]+" | head -n 1)
echo "posturl: $posturl"
if [ -n "$posturl" ]; then
URL=$(wget -O - "http://geek-and-poke.com/$posturl" | sed -nre 's#.+<noscript><img[ \t]*src="(https?://static.squarespace.com[^"]+)".+#\1#p')
echo "URL: $URL"
wget -O ${tmp}/out.jpg ${wget_args} --header="Referer: http://geek-and-poke.com/" --user-agent="$browser" $URL
if [ -s "${tmp}/out.jpg" ]; then
mv "${tmp}/out.jpg" "${image_dir}/$newn"
echo "${COMIC[0]}" > "${image_dir}/${day}.title"
rm -f "${comic_dir}/latest.jpg"
ln -s "${image_offset}/$newn" "${comic_dir}/latest.jpg"
fi
fi
rm -rf "${tmp}"
|