blob: d2f9e5e77676abb5934715cd4a6fda0438bb7648 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/bash
#
# vdr-menuorg - A plugin for the Linux Video Disk Recorder
# Copyright (C) 2007 Thomas Creutz, Tobias Grimm
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#
usage="usage: $0 submenu-file menuorg-file"
if [ a"$1" == a"" ] || ! [ -f $1 ]; then echo $usage && exit 1; fi
if [ a"$2" == a"" ]; then echo $usage && exit 1; fi
declare -a menu
echo -n "read the input file... "
while read line
do
menuLevel=`echo $line|cut -d: -f1`
rootOfItem=`echo $line|cut -d: -f2`
name=`echo $line|cut -d: -f3`
if [ a"$rootOfItem" != a"" ] && [ "$rootOfItem" != "0" ]
then
menu[$menuLevel]="${menu[$menuLevel]} ${rootOfItem};$name"
else
menu[$menuLevel]="${menu[$menuLevel]} $name"
fi
done < $1
echo done
echo -n "write the xml to the output file... "
{
echo "<menus>"
for item in `echo ${menu[0]}`
do
case $item
in
Schedule) echo " <system name=\"${item}\" />";;
Channels) echo " <system name=\"${item}\" />";;
Timers) echo " <system name=\"${item}\" />";;
Recordings) echo " <system name=\"${item}\" />";;
Setup) echo " <system name=\"${item}\" />";;
Commands) echo " <system name=\"${item}\" />";;
[1-9]*)
echo " <menu name=\"$(echo $item|cut -d';' -f2)\">"
index=`echo $item|cut -d';' -f1`
for Subitem in `echo ${menu[$index]}`
do
case $Subitem
in
Schedule) echo " <system name=\"${Subitem}\" />";;
Channels) echo " <system name=\"${Subitem}\" />";;
Timers) echo " <system name=\"${Subitem}\" />";;
Recordings) echo " <system name=\"${Subitem}\" />";;
Setup) echo " <system name=\"${Subitem}\" />";;
Commands) echo " <system name=\"${Subitem}\" />";;
*) echo " <plugin name=\"${Subitem}\" />";;
esac
done
echo " </menu>"
;;
*) echo " <plugin name=\"${item}\" />";;
esac
done
echo "</menus>"
} > $2
echo done
|