blob: da8ca8c990543e4583d81862bc80691b7cc91ac6 (
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
41
42
43
44
45
46
47
48
|
#!/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}"
date="$(date -d "$daysago days ago" +"%a, %d %b %Y")"
newn="${day}.jpg"
# get post link
rss="http://www.timesfreepress.com/rss/headlines/opinion/cartoons/"
rss_regex="<pubDate>${date}[^<]*</pubDate><guid>[^<]*</guid>"
url_regex=".*<guid>\([^<]*\)</guid>.*"
post=$(wget ${wget_args} -O - "${rss}" | grep "${rss_regex}" | sed "s#${url_regex}#\1#")
if [ -n "${post}" ]; then
# get img url from post
img=$(wget ${wget_args} -O - "${post}" | grep '<div class="story_lead_photo">' -A 3 | \
sed -n 's#.*<img.*src="\([^"]*\)".*#\1#p')
fi
if [ -n "${img}" ]; then
echo "Hole claybennett von $server"
echo "fuer Datum: $(date -d"$daysago days ago" -I)"
echo "URL: $img"
echo
wget ${wget_args} "${img}" -O "${newn}"
echo ${image_dir}
if [ -s "${tmp}/${newn}" ]; then
mv "${tmp}/${newn}" "${image_dir}/$newn"
rm -f "${comic_dir}/latest.jpg"
ln -s "${image_offset}/$newn" "${comic_dir}/latest.jpg"
fi
fi
rm -rf "${tmp}"
|