#!/usr/bin/env python """ Copyright 2008 Michael Moore Licensed under the GNU GPL V. 2 This is a script which (will eventually) import your video metadata from Miro database and into your Mythvideo database WARNING : Since this program does directly accesses the Miro database it could break everything. But I hope it doesn't. It will also very likely stop working when changes are made to the Miro database. Always visit http://stuporglue.org/miromyth.php for information the latest version. """ # Import everything needed to use the Miro objects. import sys import os.path import miro sys.path.insert(0, os.path.abspath(os.path.dirname(miro.__file__))) import gtcache gtcache.init() import app import cPickle import storedatabase # Import the needed database modules for the Miro database and connect try: from pysqlite2 import dbapi2 as sqlite except ImportError: import sqlite3 as sqlite con = sqlite.connect('sqlitedb') cur = con.cursor() res = cur.execute("SELECT * FROM 'dtv_objects'") def collectData() : # Define objects to be used for reassembling info, then do it feeds = {} downloaders = [] vids = [] # Iterate once over the whole database to find all item, remote-downloader and feed objects for row in cur : sd = cPickle.loads(str(row[1])).savedData cs = cPickle.loads(str(row[1])).classString if(cs == 'item' and sd['isVideo'] == True) : try : vids.append ( { 'screenshot' : sd['screenshot'], 'feed' : sd['feed_id'], 'year' : sd['releaseDateObj'], 'title' : sd['entry']['title_detail']['value'], 'summary' : sd['entry']['summary_detail'], 'length' : sd['duration'], 'path' : 'unknown', 'origurl' : sd['entry']['enclosures'][1]['href'], } ) except IndexError : continue else : continue elif(cs == 'remote-downloader') : downloaders.append(sd) elif(cs == 'feed') : feeds[row[0]] = sd # Now that we know where the feed and remote-downloader objects are, grab needed info from them for item in vids : for down in downloaders : if(item['origurl'] == down['origURL']) : item['path'] = down['status']['filename'] item['feed'] = { 'name' : feeds[item['feed']]['actualFeed'].savedData['title'], 'thumb' : feeds[item['feed']]['actualFeed'].savedData['thumbURL'] } return vids # Collect and save the data vids = collectData() # For now we'll just print, soon we'll hook into the Mythvideo database print vids """ Todo : The summary could be text, HTML or who knows what. Clean it up for the Myth DB. Download the feed icon if needed """