[mythtv-users] A tv_grab_uk_bleb grabber

Chris Moore zmower at ntlworld.com
Mon Feb 2 17:23:57 EST 2004


Hello,

After several late nights, I've produced "something that works".  It 
isn't pretty.  It's barely tested.  But..

Dependencies: Needs xsltproc and wget.  Both are available with Debian 
natch.

Installation: I put tv_grab_uk_bleb in /usr/bin or /usr/local/bin.  
Create /usr/share/xmltv/tv_grab_uk_bleb and put bleb2xmltv.xsl in it.  
Cos I'm lazy I rm'ed tv_grab_uk and made it a symlink to the bleb version.

Configuration: See the top of the script.

TODO: process the parameters instead of just outputing to $6 (ahem).  
Including getting more than one days worth of data which needs to be 
cached somewhere (under /var?).  Put *all* the URLs in.

I've tested it with mythfilldatabase but only bbc1/2 and itv1/2.  They 
don't appear on the program guide but I can search for stuff and it 
finds them.  Hey, every journey starts with a single step.   License: 
whatever XMLTV uses!   Thanks for this great software btw (both sets of 
developers).

(sleepy) Chris Moore

-- 
Sig pending!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bleb2xmltv.xsl
Type: text/xml
Size: 5121 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-users/attachments/20040202/044c5e3a/bleb2xmltv.xsl
-------------- next part --------------
#!/bin/bash

# Configure this!  Choose from channels in ALL_CHANNELS.
MY_CHANNELS="bbc1 bbc2 itv1 itv2"

declare -a -r ALL_CHANNELS=(bbc1 bbc2 bbc3 bbc4 bbc7 bbc_6music bbc_news24 bbc_radio1 bbc_radio1_xtra bbc_radio2 bbc_radio3 bbc_radio4 bbc_radio5_live bbc_radio5_live_sports_extra boomerang bravo british_eurosport cartoon_network cbbc cbeebies ch4 challenge discovery e4 film_four five ftn itv1 itv2 nickelodeon paramount scifi sky_cinema sky_movies1 sky_movies2 sky_movies3 sky_movies4 sky_movies5 sky_movies6 sky_movies7 sky_movies8 sky_one sky_one_mix sky_sports1 sky_sports3 uk_bright_ideas uk_drama uk_gold uk_gold2 uk_history uk_horizons uk_style)

declare -a -r CHANNEL_URLS=(bbc1.bbc.co.uk bbc2.bbc.co.uk bbc3.bbc.co.uk bbc4.bbc.co.uk bbc7.bbc.co.uk bbc_6music news-24.bbc.co.uk radio-1.bbc.co.uk bbc_radio1_xtra radio-2.bbc.co.uk radio-3.bbc.co.uk radio-4.bbc.co.uk radio-5.bbc.co.uk bbc_radio5_live_sports_extra boomerang.cartoonnetwork.com bravo.co.uk british.eurosport.com uk.cartoonnetwork.com cbbc.bbc.co.uk cbeebies.bbc.co.uk channel4.com challengetv.co.uk discoveryeurope.com e4.channel4.com filmfour.channel4.com channel5.co.uk ftn itv1.itv.co.uk itv2.itv.co.uk nickelodeon.co.uk paramountcomedy.com uk.scifi.com 1.cinema.sky.com 1.movies.sky.com 2.movies.sky.com 3.movies.sky.com 4.movies.sky.com 5.movies.sky.com 6.movies.sky.com 7.movies.sky.com 8.movies.sky.com sky-one.sky.com sky_one_mix 1.sports.sky.com 3.sports.sky.com uk_bright_ideas uk-drama.flextech.telewest.co.uk uk-gold.flextech.telewest.co.uk uk-gold-2.flextech.telewest.co.uk uk_history uk-horizons.flextech.telewest.co.uk uk-style.flextech.telewest.co.uk)

TEMP_FILE=`tempfile -s .xml`

function findURL() {
  local CHAN=$1
  local -i i=0
  # Assumes CHAN is in ALL_CHANNELS
  while [[ ! ${ALL_CHANNELS[i]} = $CHAN ]]; do
    let i++
  done
  # URL occupies corresponding position in the other array.
  echo "http://${CHANNEL_URLS[i]}/"
}

# Form the XML file with the channel to URL mappings
# and the program data.
DATE=`date`
cat > $TEMP_FILE << EOF1
<?xml version="1.0" encoding="UTF-8"?>
<!-- produced for the bleb.org TV system at $DATE -->
<root>
EOF1

for CHANNEL in $MY_CHANNELS; do

  URL=`findURL $CHANNEL`
  cat >> $TEMP_FILE << EOF2
<xmltvid blebid="$CHANNEL">$URL</xmltvid>
EOF2

done

# Get the XML files from bleb, delete the first two lines
# and append them to the tempfile.
for CHANNEL in $MY_CHANNELS; do
  wget --user-agent="bleb2xmltv (zmower at ntlworld.com)" --output-document=- http://www.bleb.org/tv/data/listings/0/$CHANNEL.xml | sed -e '1,2d' >> $TEMP_FILE
#  cat $CHANNEL.xml | sed -e '1,2d' >> $TEMP_FILE
  sleep 2
done

cat >> $TEMP_FILE << EOF3
</root>
EOF3

# Do the transform.
xsltproc -o $6 /usr/share/xmltv/tv_grab_uk_bleb/bleb2xmltv.xsl $TEMP_FILE


More information about the mythtv-users mailing list