Hi all,
My tv_grab_au, like many, does not provide guide data for 'HD' content
in Australia. I've written a small python script to populate the guide
data for these channels.

It works like this:
- you tell it which SD channel id's are related to which HD channel id's
- you give it a list of HD program titles
- the script will search for all these titles is the program table,
and if found, will add them again to the program table with the new HD
channel id and the field "hdtv" set to true(1).

The dogiest bit is that you have to maintain a list of HD titles. I
use the website at: http://www.widescreentv.com.au/ to do this.
Unfortunately the title names on that website are rarely the same as
the grabber ("C.S.I. Miami" vs "CSI: Miami") and the HTML is difficult
to parse anyway. I basically did it by hand which isnt ideal.

Run this script after you do a mythfilldatabase. It operates directly
on the database which is easier that messing with xmltv inside the
grabber, though it might break if the schema ever changes. Does anyone
know if I should somehow tell mythtv that the db has been updated??

How does everyone else deal with HD guide data on OZ?

Dave

PS. If there is any interest, I could convert this to a PHP page for
mythweb, store titles in a database table, and have a nice gui to add
and remove HD titles. That would probably be more maintainable.
#!/usr/bin/env python
# Script to populate HD channel guide data in mythtv for Australia.
# HD channels carry a subset of the programming from the SD channel
# of the same broadcaster.
# David Collett, 8 May 2005

# database vars
db = 'mythconverg'
dbuser = 'mythtv'
dbpass = 'mythtv'

# Associate SD -> HD chanid's
# use the channels table to find these
hdmap = { 1001:1013, # SBS
          1005:1018, # ABC
          1009:1025, # TEN
          1010:1022, # WIN (NINE)
          1012:1016, # PRIME (SEVEN)
          }

# list of HD programs
# A list is available here: http://www.widescreentv.com.au/program.html
# NOTE: The names are very often not exaclty the same and the HTML sucks
# eg. "CSI: Miami" vs "C.S.I Miami", making it impossible to automatically
# parse, hence this hardcoded list
hdprogs = {
    # SBS
    1013:[],
    # ABC
    1018:[],
    # TEN
    1025:['Totally Wild',
          'GMA with Bert Newton',
          'Becker',
          'Summerland',
          'Law and Order',
          'Law and Order: Special Victims Unit',
          'Everybody Loves Raymond',
          'Scooter: Secret Agent',
          'One Tree Hill',
          'Mass for You at Home',
          'NCIS'],
    # WIN
    1022:['Today',
          'Mornings With Kerri-Anne',
          "Fresh: Cooking with the Australian Women's Weekly",
          'The Young and the Restless',
          'A Current Affair',
          'Cold Case',
          'The Agency',
          'The Job',
          'CSI: Crime Scene Investigation',
          'CSI: NY',
          'CSI: Miami',
          'Star Trek: Enterprise',
          "McLeod's Daughters",
          'Without A Trace',
          'The Drew Carey Show',
          'The District',
          'ER',
          'The Footy Show',
          'Our Place',
          'The Bernie Mac Show',
          'Everwood',
          "Australia's Funniest Home Video Show",
          'Business Sunday',
          'Sunday',
          'Sunday Roast',
          'The Sunday Footy Show'],
    # PRIME
    1016:['Sunrise',
          'Seven Morning News',
          'Seven News',
          'Home and Away',
          'The Great Outdoors',
          'Desperate Housewives',
          'Crossing Jordan',
          'Las Vegas',
          'All Saints',
          'LAX',
          'My Wife and Kids',
          'Blue Heelers',
          'Lost',
          'Saturday Disney',
          "Disney's Fillmore!",
          'Disney Adventures',
          'Weekend Sunrise',
          'Sportsworld',
          'Sunday Home Theatre']
    }

def deletehd(dbh):
    """ helper to delete all HD program guide.
    I used this during testing to flush any of my inserts """
    for chan in hdmap.values():
        dbh.execute("delete from program where chanid=%s", chan)
        
# grab DB handle
import MySQLdb
dbc = MySQLdb.Connect(user=dbuser, passwd=dbpass, db=db)
dbh = dbc.cursor()

# flush HD guide first?
#deletehd(dbh)
#import sys
#sys.exit(0)

for sdchan in hdmap.keys():
    hdchan = hdmap[sdchan]
    
    for show in hdprogs[hdchan]:
        count = dbh.execute('select * from program where chanid=%s and hdtv=0 and title=%s', (sdchan, show))
        if count == 0:
            print "Did not find %r, maby it's not on anymore or the spelling is wrong?" % show
            continue

        for row in dbh:
            # escape strings
            rowstr = ["%s" % s for s in row[1:]]
            rowstr = ["%r" % s for s in rowstr]

            #set 'hdtv' true (we're stuffed if the schema changes...)
            rowstr[13] = '1'

            query = "insert into program values (%s, %s)"% (hdchan, ','.join(rowstr))

            try:
                dbh.execute(query)
            except MySQLdb.IntegrityError:
                # this is a dupe, should I delete the old one and try again??
                pass
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

Reply via email to