- Multiple minor fixes

- Addition of TV DB controller to perform TV related database lookups
- Added check for ~/.mythtv/mysql.txt
This commit is contained in:
noisymime 2008-02-11 21:33:45 +00:00
parent 0e5a7eb3c7
commit d9cafafcdf
4 changed files with 109 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import clutter
from clutter import cluttergst
from modules.myth_tv_player.MythBackendConn import MythBackendConnection
from modules.myth_tv_player.tv_db_controller import tv_db_controller
#from Menu import Menu
from VideoController import VideoController
@ -15,10 +16,14 @@ class Module:
def __init__(self, glossMgr, dbMgr):
self.stage = glossMgr.get_stage()
self.glossMgr = glossMgr
self.dbMgr = dbMgr
self.setup_ui()
self.videoController = VideoController(glossMgr)
self.dbMgr = dbMgr
self.dbController = tv_db_controller(dbMgr)
self.dbController.get_current_show(1033)
channels = self.dbController.get_channels()
self.isRunning = False
def setup_ui(self):

View File

@ -0,0 +1,100 @@
import time
import datetime
class tv_db_controller:
title = "TV"
def __init__(self, dbMgr):
self.dbMgr = dbMgr
def get_channels(self):
sql = "SELECT * FROM channel WHERE channum <> ''"
results = self.dbMgr.run_sql(sql)
channels = []
for entry in results:
tmpChannel = channel()
tmpChannel.import_from_mythObject(entry)
channels.append(tmpChannel)
def get_current_show(self, chanID):
timeString = time.strftime( "%Y-%m-%d %H:%M:%S" )
tim = time.strptime(time.ctime())
myDateTime = datetime.datetime(*tim[0:6])
sql = "SELECT * FROM program WHERE chanid = %s AND starttime < '%s' AND endtime > '%s'" % (str(chanID), myDateTime, myDateTime)
#print sql
result = self.dbMgr.run_sql(sql)
tmpShow = show()
if len(result) > 0:
tmpShow.import_from_mythObject(result[0])
return tmpShow
class channel:
def __init__(self):
pass
def import_from_mythObject(self, mythObject):
self.chanID = mythObject[0]
self.channum = mythObject[1]
self.freqid = mythObject[2]
self.sourceid = mythObject[3]
self.callsign = mythObject[4]
self.name = mythObject[5]
self.icon = mythObject[6]
self.finetune = mythObject[7]
self.videofilters = mythObject[8]
self.xmltvid = mythObject[9]
self.recpriority = mythObject[10]
self.contrast = mythObject[11]
self.brightness = mythObject[12]
self.colour = mythObject[13]
self.hue = mythObject[14]
self.tvformat = mythObject[15]
self.commfree = mythObject[16]
self.visible = mythObject[17]
self.outputfilters = mythObject[18]
self.useonairguide = mythObject[19]
self.mplexid = mythObject[20]
self.serviceid = mythObject[21]
self.atscsrcid = mythObject[22]
self.tmoffset = mythObject[23]
self.atsc_major_chan = mythObject[24]
self.atsc_minor_chan = mythObject[25]
self.last_record = mythObject[26]
class show:
def __init__(self):
pass
def import_from_mythObject(self, mythObject):
self.chanID = mythObject[0]
self.channum = mythObject[1]
self.freqid = mythObject[2]
self.sourceid = mythObject[3]
self.callsign = mythObject[4]
self.name = mythObject[5]
self.icon = mythObject[6]
self.finetune = mythObject[7]
self.videofilters = mythObject[8]
self.xmltvid = mythObject[9]
self.recpriority = mythObject[10]
self.contrast = mythObject[11]
self.brightness = mythObject[12]
self.colour = mythObject[13]
self.hue = mythObject[14]
self.tvformat = mythObject[15]
self.commfree = mythObject[16]
self.visible = mythObject[17]
self.outputfilters = mythObject[18]
self.useonairguide = mythObject[19]
self.mplexid = mythObject[20]
self.serviceid = mythObject[21]
self.atscsrcid = mythObject[22]
self.tmoffset = mythObject[23]
self.atsc_major_chan = mythObject[24]
self.atsc_minor_chan = mythObject[25]
self.last_record = mythObject[26]

View File

@ -30,6 +30,9 @@ class mythDB():
def read_config(self):
conf_file = os.path.expanduser("~/.mythtv/mysql.txt")
if not os.path.exists(conf_file):
print "ERROR: No config file found at ~.mythtv/mysql.txt!"
print "No connection to MythTV Database can be made. Quitting"
clutter.main_quit()
return False
f=open(conf_file, 'r')

Binary file not shown.