I wanted to build a directory of symlinks that pointed to my MythTV recordings, so I wrote a little python script to do it for me. I figure someone else might find this useful too... #!/usr/bin/python # Copyright (C) Michael Still (mikal@stillhq.com) 2007 # Released under the terms of the GNU GPL import MySQLdb import os import re from socket import gethostname # Connect to the MythTV database based on the MythTV config config_values = {} home = os.environ.get('HOME') config = open(home + '/.mythtv/mysql.txt') for line in config.readlines(): if not line.startswith('#') and len(line) > 5: (key, value) = line.rstrip('\n').split('=') config_values[key] = value db_connection = MySQLdb.connect(host = config_values['DBHostName'], user = config_values['DBUserName'], passwd = config_values['DBPassword'], db = config_values['DBName']) cursor = db_connection.cursor(MySQLdb.cursors.DictCursor) # Regexp for what is allowed in the symlink name unsafe = re.compile('[^a-zA-Z0-9\-\:_]+') # Find the recordings directory -- this assumes you haven't used an # identifier string for this machine... cursor.execute('select * from settings where value="RecordFilePrefix" and ' 'hostname="%s";' % gethostname()) row = cursor.fetchone() basedir = row['data'] # Now find all the recordings we have at the moment cursor.execute('select title, subtitle, starttime, basename from recorded;') for i in range(cursor.rowcount): row = cursor.fetchone() title = row['title'] subtitle = row['subtitle'] if subtitle…