My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
main() {
[ $# -eq 0 ] || exit 1
ME=`basename $0`
local LOG="/tmp/$ME.$USER.log"
{
date "+$ME %Y-%m-%dT%H%M%S"
main_logged "$@"
} 2>&1 |
tee -a "$LOG"
}

main_logged() {
[ $# -eq 0 ] || exit 1
local DIR="/home/shared/xmltv_guide"
mkdir -p "$DIR" || exit 1
local ALL="$DIR/listings.xml"

if [ ! -f "$ALL" ] ; then
echo "need to create from scratch" >&2
update "$DIR" "$ALL" || exit 1
else
date "+%Y %j" |
{
read THISYEAR TODAY
getfileyearday "$ALL" |
{
read SAVEDYEAR SAVEDDAY
[ -n "$SAVEDDAY" ] || exit 1
if [ "$SAVEDYEAR" = "$THISYEAR" ] ; then
AGO=`expr $TODAY - $SAVEDDAY`
if [ "$AGO" -le 1 ] ; then
return
fi
fi
echo "download updated version" >&2
update "$DIR" "$ALL" || exit 1
} || exit 1
} || exit 1
fi
}

update() {
killall `basename "$0"` #minor hack
local DIR="$1"
local ALL="$2"
local TD="/tmp/$ME.$USER.$$"
mkdir "$TD" || exit 1
local TM1="$TD/1.tmp"
local TM2="$TD/2.tmp"
export PATH=/home/shared/xmltv/bin/:$PATH
nice tv_grab_huro --days 5 --output "$TM1" || exit 1
[ `wc -c < "$TM1"` -gt 0 ] || exit 1
echo "tv_sort" >&2
nice tv_sort < "$TM1" > "$TM2" || exit 1
[ `wc -c < "$TM2"` -gt 0 ] || exit 1
rm -v "$TM1"
echo "tv_split" >&2
nice tv_split --output "$TD/day-%Y%m%d.xmltv" < "$TM2" || exit 1
mv -v "$TM2" "$ALL" || exit 1
rm -v $DIR/day-*.xmltv
mv -vt "$DIR" $TD/day-*.xmltv
rmdir "$TD"
}

getfileyearday() {
[ $# -ge 1 ] || exit 1
ls -lgG --time-style='+%Y %j' "$@" |
cut -d ' ' -f 4,5
}

main "$@"

Change log

r113 by bkil.hu on Jan 19, 2012   Diff
tv/update_guide.sh tv grab redirection
changed to output parameter
Go to: 
Project members, sign in to write a code review

Older revisions

r110 by bkil.hu on Jan 12, 2012   Diff
tv/update_guide.sh adjusted command
killall tv_grab to $0
r108 by bkil.hu on Jan 7, 2012   Diff
renamed guide_update.sh to
update_guide.sh
r106 by bkil.hu on Jan 7, 2012   Diff
tv/guide_update.sh added for fetching
a new guide from an online source via
xmltv, a fresh one recompiled under a
specific location is also supported
All revisions of this file

File info

Size: 1536 bytes, 72 lines

File properties

svn:executable
*
Powered by Google Project Hosting