[vdrpylib-cvslog] vdrpylib/vdr vdr.py,1.5,1.6
Status: Alpha
Brought to you by:
rshortt
From: Rob S. <rs...@us...> - 2004-11-25 17:30:47
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15884 Modified Files: vdr.py Log Message: Changes from Thomas Weber for different channel types and other misc changes. Index: vdr.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/vdr.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** vdr.py 24 Nov 2004 17:21:08 -0000 1.5 --- vdr.py 25 Nov 2004 17:30:35 -0000 1.6 *************** *** 22,28 **** import os.path import re - import string ! from channel import Channel import event import recording --- 22,27 ---- import os.path import re ! import channel import event import recording *************** *** 94,98 **** setupfile = 'setup.conf', svdrpfile = 'svdrphosts.conf', ! timerfile = 'timers.conf'): self.svdrp = None --- 93,98 ---- setupfile = 'setup.conf', svdrpfile = 'svdrphosts.conf', ! timerfile = 'timers.conf', ! close_connection=1): self.svdrp = None *************** *** 100,103 **** --- 100,107 ---- self.recordings = [] self.timers = [] + self.ordered_channels = [] + self.radio_channels = [] + self.tv_channels = [] + self.close_connection=close_connection self.host = host *************** *** 124,142 **** recordings in the system. """ ! # XXX: this is so f#$#! broken, disabling ! return [path] - pat = re.compile('([^0-9]*)([0-9]+)') - result = pat.match(self.videopath) - if result is None: - return [path] - else: - paths = [] - #basepath = result.groups(1) - basepath = result.group(1) - print 'RLS: basepath is %s' % basepath - print 'RLS: result is %s' % result.group(2) - #curnr = int(result.groups(2)) - curnr = int(result.group(2)) if basepath == None: basepath = '' --- 128,147 ---- recordings in the system. """ ! # XXX: this is so f#$#! broken, disabling ! return [path] ! ! pat = re.compile('([^0-9]*)([0-9]+)') ! result = pat.match(self.videopath) ! if result is None: ! return [path] ! else: ! paths = [] ! #basepath = result.groups(1) ! basepath = result.group(1) ! print 'RLS: basepath is %s' % basepath ! print 'RLS: result is %s' % result.group(2) ! #curnr = int(result.groups(2)) ! curnr = int(result.group(2)) if basepath == None: basepath = '' *************** *** 176,180 **** """ if self.svdrp is None and self.host and self.port: ! self.svdrp = svdrp.SVDRP(self.host, self.port) return self.svdrp --- 181,186 ---- """ if self.svdrp is None and self.host and self.port: ! self.svdrp = svdrp.SVDRP(self.host, ! self.port,close_connection=self.close_connection) return self.svdrp *************** *** 241,245 **** if self.getsvdrp() is None: return None ! chans = self.svdrp.lstc() if chans is not None: --- 247,262 ---- if self.getsvdrp() is None: return None ! chans={} ! self.radio_channels=[] ! self.tv_channels=[] ! self.ordered_channels = self.svdrp.lstc() ! if self.ordered_channels is None: ! return chans ! for c in self.ordered_channels: ! chans[c.id]=c ! if c.vpid=="0": ! self.radio_channels.append(c) ! else: ! self.tv_channels.append(c) if chans is not None: *************** *** 289,293 **** events parsed. """ ! channel = None ev = None counter = 0 --- 306,310 ---- events parsed. """ ! ch = None ev = None counter = 0 *************** *** 296,303 **** --- 313,327 ---- while line: line = line.strip() + if line=='': + continue + #print line # special handling of data coming in via SVDRP if line[0:4] == '215-': line = line[4:] + if line[0:4] == '215 ': + # EPG End + break; + if line[0:4] == '250 ': line = fh.readline() *************** *** 306,319 **** if line[0] == 'C': # channel start ! tokens = string.split(line, '-') ! ch_sid = int(tokens[3]) ! print 'RLS: ch_sid="%s"' % ch_sid ! if self.channels.has_key(ch_sid): ! channel = self.channels[ch_sid] else: ! channel = Channel() ! channel.sid = ch_sid ! channel.name = string.split(tokens[4])[1] elif line[0] == 'E': # event start --- 330,342 ---- if line[0] == 'C': # channel start ! tokens = line.split(None, 2) ! ch_id = tokens[1] ! if self.channels.has_key(ch_id): ! ch= self.channels[ch_id] else: ! ch= channel.Channel() ! ch.id = ch_id ! ch.name = tokens[2] elif line[0] == 'E': # event start *************** *** 321,325 **** ev.parseheader(line[2:]) ev.source = 'vdr' ! ev.channel = channel elif line[0] == 'T': # title --- 344,348 ---- ev.parseheader(line[2:]) ev.source = 'vdr' ! ev.channel = ch elif line[0] == 'T': # title *************** *** 331,346 **** # description ev.desc = line[2:] elif line[0] == 'e': # event end ! channel.addevent(ev) ev = None counter = counter + 1 elif line[0] == 'c': # channel end ! self.channels[channel.sid] = channel ! channel = None else: # unknown line identifier ! print 'Unable to parse line ' + line break line = fh.readline() --- 354,371 ---- # description ev.desc = line[2:] + elif line[0] == 'V': + # description + ev.vps = line[2:] elif line[0] == 'e': # event end ! ch.addevent(ev) ev = None counter = counter + 1 elif line[0] == 'c': # channel end ! ch= None else: # unknown line identifier ! #print 'Unable to parse line ' + line break line = fh.readline() *************** *** 349,353 **** ! def retrieveepg(self): """Retrieves EPG data via SVDRP from VDR and adds it to this VDR object. --- 374,378 ---- ! def retrieveepg(self,channelid = None,classifier=None): """Retrieves EPG data via SVDRP from VDR and adds it to this VDR object. *************** *** 363,369 **** if self.getsvdrp() is None: return None ! result = self.svdrp.write_cmd('lste') ! fh = cstringio.cStringIO(result) ! return parseepg(fh) --- 388,408 ---- if self.getsvdrp() is None: return None ! if self.channels is None: ! retrievechannels() ! cmd='lste' ! if channelid: ! cmd=cmd+' '+channelid ! else: ! for ch in self.ordered_channels: ! print ch.name ! self.retrieveepg(ch.id,classifier) ! return ! ! if classifier: ! cmd=cmd+' '+classifier ! result = self.svdrp.write_cmd(cmd) ! #print result ! fh = cStringIO.StringIO(result) ! return self.parseepg(fh) |