[vdrpylib-cvslog] vdrpylib/vdr channel.py,1.3,1.4 vdr.py,1.6,1.7
Status: Alpha
Brought to you by:
rshortt
From: Rob S. <rs...@us...> - 2004-11-25 18:11:37
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24428 Modified Files: channel.py vdr.py Log Message: Enhancements, misc changes, and fixes. Index: vdr.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/vdr.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** vdr.py 25 Nov 2004 17:30:35 -0000 1.6 --- vdr.py 25 Nov 2004 18:11:25 -0000 1.7 *************** *** 284,292 **** if len(line) > 0 and line[0] != ':': counter = counter + 1 ! c = channel.Channel(line, counter) ! if chans.has_key(c.sid): ! chans[c.sid].indexes.append(counter) ! else: ! chans[c.sid] = c line = fh.readline() --- 284,288 ---- if len(line) > 0 and line[0] != ':': counter = counter + 1 ! self.addchannel(channel.Channel(line, counter)) line = fh.readline() *************** *** 295,298 **** --- 291,301 ---- + def addchannel(self, channel): + key = '%s-%s-%s-%s-%s' % (channel.source, channel.nid, + channel.tid, channel.sid, channel.rid) + print 'DEBUG: key is %s' % key + self.channels[key] = channel + + def parseepg(self, fh): """Parses EPG data in the format of VDR's epg.data file and *************** *** 315,319 **** if line=='': continue ! #print line # special handling of data coming in via SVDRP --- 318,322 ---- if line=='': continue ! # print 'EPG line: %s' % line # special handling of data coming in via SVDRP *************** *** 330,344 **** 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 ev = event.Event() ev.parseheader(line[2:]) --- 333,349 ---- if line[0] == 'C': # channel start ! print 'EPG channel: %s' % line ! tokens = line.split() ch_id = tokens[1] if self.channels.has_key(ch_id): ! ch = self.channels[ch_id] else: ! ch = channel.Channel(key=ch_id) ch.id = ch_id ch.name = tokens[2] elif line[0] == 'E': # event start + # print 'event start' ev = event.Event() ev.parseheader(line[2:]) *************** *** 359,362 **** --- 364,368 ---- elif line[0] == 'e': # event end + # print 'event end' ch.addevent(ev) ev = None *************** *** 364,371 **** elif line[0] == 'c': # channel end ! ch= None else: # unknown line identifier ! #print 'Unable to parse line ' + line break line = fh.readline() --- 370,379 ---- elif line[0] == 'c': # channel end ! print 'EPG adding: %s' % ch.__str__() ! self.addchannel(ch) ! ch = None else: # unknown line identifier ! print 'Unable to parse line: ' + line break line = fh.readline() Index: channel.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/channel.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** channel.py 25 Nov 2004 17:01:47 -0000 1.3 --- channel.py 25 Nov 2004 18:11:24 -0000 1.4 *************** *** 73,77 **** through the XXXevent() functions of this class. """ ! def __init__(self, line = None, index = None): self.id = None self.indexes = [] --- 73,77 ---- through the XXXevent() functions of this class. """ ! def __init__(self, line = None, index = None, key = None, name = None): self.id = None self.indexes = [] *************** *** 92,98 **** self.rid = None self.events = [] ! if line is not None: ! self.parse(line) ! if index is not None: self.indexes.append(index) --- 92,100 ---- self.rid = None self.events = [] ! if line: ! self.parse_line(line) ! if key: ! self.parse_key(key) ! if index: self.indexes.append(index) *************** *** 105,109 **** ! def parse(self, definition): """Parses a standard channel specification as can be found in VDR's channels.conf file. --- 107,127 ---- ! def dump(self): ! print 'name: %s' % self.name ! print 'transponder: %s' % self.transponder ! print 'freq: %s' % self.freq ! print 'pars: %s' % self.pars ! print 'source: %s' % self.source ! print 'srate: %s' % self.srate ! print 'vpid: %s' % self.vpid ! print 'tpid: %s' % self.tpid ! print 'ca: %s' % self.ca ! print 'sid: %s' % self.sid ! print 'nid: %s' % self.nid ! print 'tid: %s' % self.tid ! print 'rid: %s' % self.rid ! ! ! def parse_line(self, definition): """Parses a standard channel specification as can be found in VDR's channels.conf file. *************** *** 135,142 **** self.dpids = map(str, tokens[1].split(',')) #print "source=%s, nid=%s,tid=%s, sid=%s,rid=%s" % (self.source,self.nid,self.tid,self.sid,self.rid) ! self.id=self.source+"-"+self.nid+"-"+self.tid+"-"+self.sid if int(self.rid)>0: self.id+="-"+self.rid ! def addevent(self, ev): --- 153,172 ---- self.dpids = map(str, tokens[1].split(',')) #print "source=%s, nid=%s,tid=%s, sid=%s,rid=%s" % (self.source,self.nid,self.tid,self.sid,self.rid) ! self.id = string.join([self.source, self.nid, self.tid, ! self.sid, self.rid], '-') if int(self.rid)>0: self.id+="-"+self.rid ! ! ! def parse_key(self, key): ! tokens = key.split('-') ! ! self.source = tokens[0] ! self.nid = tokens[1] ! self.tid = tokens[2] ! self.sid = tokens[3] ! self.rid = tokens[4] ! self.id = key ! def addevent(self, ev): *************** *** 153,157 **** given restrictions and was added, else None is returned. """ ! if len(self.events) == 0 or self.events[-1].start + self.events[-1].dur <= ev.start: self.events.append(ev) if ev.id is None: --- 183,190 ---- given restrictions and was added, else None is returned. """ ! # print 'adding event: %s' % ev.__str__() ! # print 'events len: %d' % len(self.events) ! if len(self.events) == 0 or \ ! self.events[-1].start + self.events[-1].dur <= ev.start: self.events.append(ev) if ev.id is None: *************** *** 162,165 **** --- 195,199 ---- return ev.id else: + print 'event not later: %s %s %s' % (self.events[-1].start, self.events[-1].dur, ev.start) return None |