[mythtvnz] hairy to mr geek epg converter
Robin Gilks
mythtvnz@lists.linuxnut.co.nz
Thu, 8 Dec 2005 21:37:06 +1300 (NZDT)
Just a quicky bash script, probably not that different to what loads of
people are using :-)
Enjoy...
#!/bin/bash
# grab xml tv listings from hairy.geek.nz
# and manipulate them so they look like the mr.geek.nz ones
#####################################################################
mkdir -p /mnt/tmp/epg
cd /mnt/tmp/epg
#remove old file
rm -f latest.xml.gz
rm -f latest.xml
# get the file
curl --silent --output latest.xml.gz http://hairy.geek.nz/epg/latest.xml.gz
# comment out above & uncomment below when testing!!
#cp -f backup.xml.gz latest.xml.gz
# keep a copy
cp -f latest.xml.gz backup.xml.gz
# extract
gunzip latest.xml.gz
T1FILE="temp1.$$.tmp"
T2FILE="temp2.$$.tmp"
# clean it up a bit
grep -v Unknown_Please_Report latest.xml > $T2FILE && mv $T2FILE latest.xml
# Remove existing heading
grep -v "channel id=" latest.xml | grep -v "/channel" | grep -v
"display\-name" > $T2FILE && mv $T2FILE latest.xml
# Make a list of the substitutions we'll need and the channel name
# as a table we can maintain easily
cat > $T1FILE <<_EOF
1000.dvb.guide Mosaic.mr.geek.nz Mosaic
1001.dvb.guide SKY1.mr.geek.nz SKY1
1002.dvb.guide SKYMovies1.mr.geek.nz SKYMovies1
1003.dvb.guide UKTV.mr.geek.nz UKTV
1004.dvb.guide MGM.mr.geek.nz MGM
1005.dvb.guide RugbyChannel.mr.geek.nz RugbyChannel
1006.dvb.guide CartoonNetwork.mr.geek.nz CartoonNetwork
1007.dvb.guide JuiceTV.mr.geek.nz JuiceTV
1008.dvb.guide SKYSport1.mr.geek.nz SKYSport1
1009.dvb.guide SKYSport2.mr.geek.nz SKYSport2
1010.dvb.guide ESPN.mr.geek.nz ESPN
1011.dvb.guide Trackside.mr.geek.nz Trackside
1012.dvb.guide NatGeographic.mr.geek.nz NatGeographic
1013.dvb.guide Discovery.mr.geek.nz Discovery
1014.dvb.guide AnimalPlanet.mr.geek.nz AnimalPlanet
1015.dvb.guide CNN.mr.geek.nz CNN
1016.dvb.guide History.mr.geek.nz History
1017.dvb.guide SkyNews.mr.geek.nz SkyNews
1018.dvb.guide Prime.mr.geek.nz Prime
1019.dvb.guide J2.mr.geek.nz J2
1020.dvb.guide Rialto.mr.geek.nz Rialto
1021.dvb.guide E.mr.geek.nz E!
1022.dvb.guide LivingChannel.mr.geek.nz LivingChannel
1023.dvb.guide SKYMovies2.mr.geek.nz SKYMovies2
1024.dvb.guide Nickelodeon.mr.geek.nz Nickelodeon
1025.dvb.guide MaoriTV.mr.geek.nz MaoriTV
1026.dvb.guide BBCWorld.mr.geek.nz BBCWorld
1027.dvb.guide DisneyChannel.mr.geek.nz DisneyChannel
1028.dvb.guide SouthlandTV.mr.geek.nz SouthlandTV
1029.dvb.guide ArtsChannel.mr.geek.nz ArtsChannel
1031.dvb.guide TV1.mr.geek.nz TVOne
1032.dvb.guide TV2.mr.geek.nz TV2
1033.dvb.guide TV3.mr.geek.nz TV3
1034.dvb.guide C4.mr.geek.nz C4
1035.dvb.guide TV1.mr.geek.nz TVOne
1036.dvb.guide TV2.mr.geek.nz TV2
1037.dvb.guide TV1.mr.geek.nz TVone
1038.dvb.guide TV2.mr.geek.nz TV2
1040.dvb.guide SBO1.mr.geek.nz SKYBoxOffice1
1041.dvb.guide SBO2.mr.geek.nz SKYBoxOffice2
1042.dvb.guide Playboy.mr.geek.nz Playboy
1043.dvb.guide SBO3.mr.geek.nz SKYBoxOffice3
1043.dvb.guide Spice.mr.geek.nz Spice
1044.dvb.guide TCM.mr.geek.nz TCM
1046.dvb.guide SBO3.mr.geek.nz SKYBoxOffice3
1047.dvb.guide SBO4.mr.geek.nz SKYBoxOffice4
1048.dvb.guide SKYSport3.mr.geek.nz SKYSport3
1049.dvb.guide Spice2.mr.geek.nz Spice2
1050.dvb.guide Preview2.mr.geek.nz Preview
1052.dvb.guide FoodTV.mr.geek.nz FoodTV
1055.dvb.guide SBO5.mr.geek.nz SKYBoxOffice5
1056.dvb.guide SBO6.mr.geek.nz SKYBoxOffice6
1057.dvb.guide SBO7.mr.geek.nz SKYBoxOffice7
1060.dvb.guide SkyBoxOffice.mr.geek.nz SKYBoxOffice
1080.dvb.guide JTV.mr.geek.nz JTV
1081.dvb.guide KTV.mr.geek.nz KTV
1082.dvb.guide CTV1.mr.geek.nz CTV1
1083.dvb.guide CTV2.mr.geek.nz CTV2
1084.dvb.guide CTV3.mr.geek.nz CTV3
1085.dvb.guide CTV4.mr.geek.nz CTV4
1086.dvb.guide CTV5.mr.geek.nz CTV5
1093.dvb.guide CCTV-9.mr.geek.nz CCTV
1099.dvb.guide Shine.mr.geek.nz Shine
1192.dvb.guide Weather.mr.geek.nz Weather
1193.dvb.guide MindGames.mr.geek.nz MindGames
1194.dvb.guide goauto.mr.geek.nz GoAuto
_EOF
# recreate the Channel IDs in the following format
#<channel id="TV1.mr.geek.nz">
# <display-name>TVOne</display-name>
#</channel>
count=0
cat latest.xml | while read line
do
echo $line >> $T2FILE
count=$((count + 1))
# skip header and then insert channel IDs
if [ $count -eq 3 ]; then
echo >> $T2FILE
cat $T1FILE | while read from to name
do
echo "<channel id = \"$to\">" >> $T2FILE
echo " <display-name>\"$name\"</display-name>" >> $T2FILE
echo "</channel>" >> $T2FILE
done
fi
done
mv $T2FILE latest.xml
# change the channel details
cat $T1FILE | while read from to name
do
#echo "sed 's/$from/$to/g' latest.xml > $T2FILE && mv $T2FILE latest.xml"
sed "s/$from/$to/g" latest.xml > $T2FILE && mv $T2FILE latest.xml
done
rm -f $T1FILE
rm -f $T2FILE
#update mythtv database
/usr/local/bin/mythfilldatabase --update --file 1 -1 /mnt/tmp/epg/latest.xml
/usr/local/bin/mythfilldatabase --update --file 2 -1 /mnt/tmp/epg/latest.xml
#end
--
Robin Gilks