1
|
#!/bin/sh
|
2
|
. /etc/profile
|
3
|
xmltv_file_location=/storage/.kodi/userdata/addon_data/service.tvheadend42/epggrab/guide.xml
|
4
|
xmltv_killer_file_location=/storage/.kodi/userdata/addon_data/service.tvheadend42/epggrab/guide_killer.xml
|
5
|
epg_source=http://epg.gravi.hu/guide.xml.gz
|
6
|
dflag=
|
7
|
vflag=
|
8
|
cflag=
|
9
|
qflag=
|
10
|
|
11
|
if [ "$#" -lt "1" ] ; then
|
12
|
|
13
|
# remove existing previously generated guide files
|
14
|
for file in ${xmltv_file_location} ${xmltv_file_location}.gz
|
15
|
do
|
16
|
if [ -f ${file} ];
|
17
|
then
|
18
|
rm -f ${file} 2>/dev/null
|
19
|
fi
|
20
|
done
|
21
|
|
22
|
# download latest compressed guide file from server
|
23
|
wget -qO ${xmltv_file_location}.gz $epg_source
|
24
|
|
25
|
# uncompress the guide file
|
26
|
gzip -d ${xmltv_file_location}.gz
|
27
|
|
28
|
# put the content to the output
|
29
|
#cat $xmltv_file_location
|
30
|
# PUT THE KILLER XML content to the output
|
31
|
cat $xmltv_killer_file_location
|
32
|
|
33
|
# alternatively use the following command line:
|
34
|
# curl -Ls ${epg_source} | gzip -d
|
35
|
|
36
|
exit 0
|
37
|
fi
|
38
|
|
39
|
# special handling if there are several arguments
|
40
|
for arg
|
41
|
do
|
42
|
delim=""
|
43
|
case "$arg" in
|
44
|
#translate --gnu-long-options to -g (short options)
|
45
|
--description) args="${args}-d ";;
|
46
|
--version) args="${args}-v ";;
|
47
|
--capabilities) args="${args}-c ";;
|
48
|
--quiet) args="${args}-q ";;
|
49
|
|
50
|
#pass through anything else
|
51
|
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
|
52
|
args="${args}${delim}${arg}${delim} ";;
|
53
|
esac
|
54
|
done
|
55
|
|
56
|
# reset the positional parameters to the short options
|
57
|
eval set -- $args
|
58
|
|
59
|
while getopts "dvcq" option
|
60
|
do
|
61
|
case $option in
|
62
|
d) dflag=1;;
|
63
|
v) vflag=1;;
|
64
|
c) cflag=1;;
|
65
|
q) qflag=1;;
|
66
|
\?) printf "unknown option: -%s\n" $OPTARG
|
67
|
printf "Usage: %s: [--description] [--version] [--capabilities] \n" $(basename $0)
|
68
|
exit 2
|
69
|
;;
|
70
|
esac >&2
|
71
|
done
|
72
|
|
73
|
if [ "$dflag" ]
|
74
|
then
|
75
|
printf "EPG Grabber for epg.gravi.hu\n"
|
76
|
fi
|
77
|
if [ "$vflag" ]
|
78
|
then
|
79
|
printf "1.0\n"
|
80
|
fi
|
81
|
if [ "$cflag" ]
|
82
|
then
|
83
|
printf "baseline\n"
|
84
|
fi
|
85
|
if [ "$qflag" ]
|
86
|
then
|
87
|
printf ""
|
88
|
fi
|
89
|
|
90
|
exit 0
|