vdrpylib-cvslog Mailing List for VDR Python Library
Status: Alpha
Brought to you by:
rshortt
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(12) |
Dec
(5) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(2) |
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Rob S. <rs...@us...> - 2005-04-28 01:32:52
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9020/vdr Modified Files: vdr.py Log Message: -Removed ordered_channels, tv_channels, radio_channels lists. -Cleanup some junk. -Utilize in_conf and in_epg of Channel. Index: vdr.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/vdr.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** vdr.py 7 Jan 2005 12:33:01 -0000 1.10 --- vdr.py 28 Apr 2005 01:32:41 -0000 1.11 *************** *** 101,107 **** self.recordings = [] self.timers = [] - self.ordered_channels = [] - self.radio_channels = [] - self.tv_channels = [] self.close_connection=close_connection --- 101,104 ---- *************** *** 246,268 **** the channel list of this VDR object is not modified. """ 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: ! self.channels = chans ! return chans --- 243,258 ---- the channel list of this VDR object is not modified. """ + counter = 0 + if self.getsvdrp() is None: return None ! ! schans = self.svdrp.lstc() ! ! for c in schans: ! self.addchannel(c) ! counter += 1 ! return counter *************** *** 279,283 **** fh = open(self.channelsfile, 'r') counter = 0 ! chans = {} line = fh.readline() while line: --- 269,273 ---- fh = open(self.channelsfile, 'r') counter = 0 ! line = fh.readline() while line: *************** *** 285,298 **** if len(line) > 0 and line[0] != ':': counter = counter + 1 ! self.addchannel(channel.Channel(line, counter)) line = fh.readline() ! self.channels = chans ! return chans def addchannel(self, channel): ! key = string.join([channel.source, channel.nid, channel.tid, ! channel.sid, channel.rid], '-') if not channel.id: --- 275,289 ---- if len(line) > 0 and line[0] != ':': counter = counter + 1 ! c = channel.Channel(line, counter) ! c.in_conf = True ! self.addchannel(c) line = fh.readline() ! return counter def addchannel(self, channel): ! key = string.join([channel.source, channel.nid, channel.tid, ! channel.sid, channel.rid], '-') if not channel.id: *************** *** 345,348 **** --- 336,340 ---- ch.id = ch_id ch.name = tokens[2] + ch.in_epg = True elif line[0] == 'E': # event start *************** *** 381,385 **** ! def retrieveepg(self,channelid = None,classifier=None): """Retrieves EPG data via SVDRP from VDR and adds it to this VDR object. --- 373,377 ---- ! def retrieveepg(self, channelid=None, classifier=None): """Retrieves EPG data via SVDRP from VDR and adds it to this VDR object. *************** *** 393,411 **** """ counter = 0 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) fh = cStringIO.StringIO(result) --- 385,399 ---- """ counter = 0 + if self.getsvdrp() is None: return None ! ! cmd = 'lste' if channelid: ! cmd = cmd+' '+channelid ! if classifier: ! cmd = cmd+' '+classifier ! result = self.svdrp.write_cmd(cmd) fh = cStringIO.StringIO(result) |
From: Rob S. <rs...@us...> - 2005-04-28 01:24:38
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4644/vdr Modified Files: svdrp.py Log Message: Assume channels found through svdrp are from the conf. Index: svdrp.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/svdrp.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** svdrp.py 12 Dec 2004 22:51:18 -0000 1.7 --- svdrp.py 28 Apr 2005 01:24:29 -0000 1.8 *************** *** 306,309 **** --- 306,310 ---- try: c = channel.Channel(tokens[-1], counter) + c.in_conf = True channels.append(c) counter = counter + 1 |
From: Rob S. <rs...@us...> - 2005-04-28 01:23:39
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3713/vdr Modified Files: channel.py Log Message: -Fix for missing RID. -Add flags for tv/radio channels. -Add flags to show if the channel was found in the EPG and/or channels.conf. Index: channel.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/channel.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** channel.py 7 Jan 2005 12:37:00 -0000 1.8 --- channel.py 28 Apr 2005 01:23:30 -0000 1.9 *************** *** 91,95 **** --- 91,100 ---- self.tid = None self.rid = None + self.tv = False + self.radio = False + self.in_conf = False + self.in_epg = False self.events = [] + if line: self.parse_line(line) *************** *** 98,101 **** --- 103,117 ---- if index: self.indexes.append(index) + + if self.vpid == '0' and len(self.apids): + self.radio = True + self.tv = False + elif self.vpid == '0' and len(self.apids) == 0: + self.radio = False + self.tv = False + else: + self.radio = False + self.tv = True + def __str__(self): *************** *** 131,139 **** """ tokens = definition.strip().split(':') ! name=tokens[0] ! nametokens=name.split(';') self.name = nametokens[0] if len(nametokens)>1: self.provider = nametokens[1] self.freq = int(tokens[1]) self.pol = tokens[2] --- 147,156 ---- """ tokens = definition.strip().split(':') ! name = tokens[0] ! nametokens = name.split(';') self.name = nametokens[0] if len(nametokens)>1: self.provider = nametokens[1] + self.freq = int(tokens[1]) self.pol = tokens[2] *************** *** 148,158 **** self.tid = tokens[11] self.rid = tokens[12] tokens = apids.split(';') self.apids = map(str, tokens[0].split(',')) if len(tokens) == 2: self.dpids = map(str, tokens[1].split(',')) self.id = string.join([self.source, self.nid, self.tid, self.sid, self.rid], '-') ! def parse_key(self, key): --- 165,178 ---- self.tid = tokens[11] self.rid = tokens[12] + tokens = apids.split(';') self.apids = map(str, tokens[0].split(',')) + if len(tokens) == 2: self.dpids = map(str, tokens[1].split(',')) + self.id = string.join([self.source, self.nid, self.tid, self.sid, self.rid], '-') ! def parse_key(self, key): *************** *** 163,167 **** self.tid = tokens[2] self.sid = tokens[3] ! self.rid = tokens[4] self.id = key --- 183,192 ---- self.tid = tokens[2] self.sid = tokens[3] ! try: ! self.rid = tokens[4] ! except: ! print 'WARNING: %s contains no rid, setting to 0' % key ! self.rid = '0' ! self.id = key |
From: Rob S. <rs...@us...> - 2005-01-07 12:37:10
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22276 Modified Files: channel.py event.py Log Message: Change indentation to 4 spaces, no tabs. Index: channel.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/channel.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** channel.py 2 Dec 2004 02:13:06 -0000 1.7 --- channel.py 7 Jan 2005 12:37:00 -0000 1.8 *************** *** 22,110 **** class Channel: ! """This class represents a program channel. ! ! It is intended to a container for the technical channel data as ! as for EPG Event objects. ! ! VDR may place a single physical channel at several locations in ! its global list of channels. This class does not represent a slot ! in the global list of channels but a physical channel. Physical ! channels are assumed to be uniquely identifiable by their SID. ! ! The indexes variable is a list containing the indexes of this ! channel in the global list of channels of a VDR instance. ! ! The name variable is a string containing the name of this ! channel. ! ! The freq variable is an integer containing the frequency of this ! channel in Hz. ! ! The pol variable is a string of length one containing the ! polariazation of this channel. 'h' stands for horizontal, 'v' for ! vertical polarization. ! ! The diseqc variable is an integer containing the DiSEqC code for ! this channel. ! ! The srate variable is an integer containing the symbol rate of ! this channel. ! ! The vpid variable is an integer containing the video PID of this ! channel. ! ! The apids variable is a list of integers containing the audio ! PIDs of this channel. ! ! The dpis variable is a list of integers containing the dolby ! digital (AC3) PIDs of this channel. ! ! The tpid variable is an integer containing the teletext PID of ! this channel. ! ! The ca variable is an integer defining how the channel can be ! accessed over the available DVB cards. ! ! The sid variable is an integer containing the service ID of this ! channel. ! ! The events variable is a list of Event objects sorted by start ! time. The list should not be manipulated directly but only ! through the XXXevent() functions of this class. ! """ ! def __init__(self, line = None, index = None, key = None, name = None): ! self.id = None ! self.indexes = [] ! self.name = name ! self.provider = '' ! self.freq = None ! self.pol = None ! self.source = None ! self.srate = None ! self.vpid = None ! self.apids = [] ! self.dpids = [] ! self.tpid = None ! self.ca = None ! self.sid = None ! self.nid = None ! self.tid = None ! self.rid = None ! self.events = [] ! if line: ! self.parse_line(line) ! if key: ! self.parse_key(key) ! if index: ! self.indexes.append(index) ! ! def __str__(self): ! """Creates a string representation of this channel object ! in the format of VDR's channels.conf file. ! """ ! apids = string.join([string.join(map(str, self.apids), ','), string.join(map(str, self.dpids), ',')], ';') ! return string.join(map(str, [self.name+";"+self.provider, self.freq, self.pol, self.source, self.srate, self.vpid, apids, self.tpid, self.ca, self.sid,self.nid,self.tid,self.rid]), ':') ! def dump(self): print 'name: %s' % self.name --- 22,110 ---- class Channel: ! """This class represents a program channel. ! ! It is intended to a container for the technical channel data as ! as for EPG Event objects. ! ! VDR may place a single physical channel at several locations in ! its global list of channels. This class does not represent a slot ! in the global list of channels but a physical channel. Physical ! channels are assumed to be uniquely identifiable by their SID. ! ! The indexes variable is a list containing the indexes of this ! channel in the global list of channels of a VDR instance. ! ! The name variable is a string containing the name of this ! channel. ! ! The freq variable is an integer containing the frequency of this ! channel in Hz. ! ! The pol variable is a string of length one containing the ! polariazation of this channel. 'h' stands for horizontal, 'v' for ! vertical polarization. ! ! The diseqc variable is an integer containing the DiSEqC code for ! this channel. ! ! The srate variable is an integer containing the symbol rate of ! this channel. ! ! The vpid variable is an integer containing the video PID of this ! channel. ! ! The apids variable is a list of integers containing the audio ! PIDs of this channel. ! ! The dpis variable is a list of integers containing the dolby ! digital (AC3) PIDs of this channel. ! ! The tpid variable is an integer containing the teletext PID of ! this channel. ! ! The ca variable is an integer defining how the channel can be ! accessed over the available DVB cards. ! ! The sid variable is an integer containing the service ID of this ! channel. ! ! The events variable is a list of Event objects sorted by start ! time. The list should not be manipulated directly but only ! through the XXXevent() functions of this class. ! """ ! def __init__(self, line = None, index = None, key = None, name = None): ! self.id = None ! self.indexes = [] ! self.name = name ! self.provider = '' ! self.freq = None ! self.pol = None ! self.source = None ! self.srate = None ! self.vpid = None ! self.apids = [] ! self.dpids = [] ! self.tpid = None ! self.ca = None ! self.sid = None ! self.nid = None ! self.tid = None ! self.rid = None ! self.events = [] ! if line: ! self.parse_line(line) ! if key: ! self.parse_key(key) ! if index: ! self.indexes.append(index) ! ! def __str__(self): ! """Creates a string representation of this channel object ! in the format of VDR's channels.conf file. ! """ ! apids = string.join([string.join(map(str, self.apids), ','), string.join(map(str, self.dpids), ',')], ';') ! return string.join(map(str, [self.name+";"+self.provider, self.freq, self.pol, self.source, self.srate, self.vpid, apids, self.tpid, self.ca, self.sid,self.nid,self.tid,self.rid]), ':') ! def dump(self): print 'name: %s' % self.name *************** *** 123,213 **** ! def parse_line(self, definition): ! """Parses a standard channel specification as can be found in ! VDR's channels.conf file. ! ! All fields of this channel object are set according to the ! specification string given in the first argument. ! """ ! tokens = definition.strip().split(':') ! name=tokens[0] ! nametokens=name.split(';') ! self.name = nametokens[0] ! if len(nametokens)>1: ! self.provider = nametokens[1] ! self.freq = int(tokens[1]) ! self.pol = tokens[2] ! self.source = tokens[3] ! self.srate = int(tokens[4]) ! self.vpid = tokens[5] ! apids = tokens[6] ! self.tpid = int(tokens[7]) ! self.ca = tokens[8] ! self.sid = tokens[9] ! self.nid = tokens[10] ! self.tid = tokens[11] ! self.rid = tokens[12] ! tokens = apids.split(';') ! self.apids = map(str, tokens[0].split(',')) ! if len(tokens) == 2: ! self.dpids = map(str, tokens[1].split(',')) ! self.id = string.join([self.source, self.nid, self.tid, self.sid, 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): ! """Add an EPG event to the list of events for this channel. ! ! If the event has no ID one is assigned. ! ! The first argument shall be an Event object representing ! the event to be added. The start time of the event to add ! must be later than the end of any other event of this ! channel. ! ! The return value is the ID of the event if it satisfied the ! given restrictions and was added, else None is returned. ! """ ! if len(self.events): ! if ev.start <= self.events[-1].start: ! return None ! if self.events[-1].start + self.events[-1].dur > ev.start: ! self.events[-1].dur = ev.start - self.events[-1].start ! if ev.id is None: ! if len(self.events) > 1: ! ev.id = (self.events[-2].id + 1) % 65536 ! else: ! ev.id = 0 ! self.events.append(ev) ! return ev.id ! ! ! def getepgstr(self): ! """Creates a string representation of this channel object ! in the format of VDR's epgdata file including all contained ! EPG events. ! """ ! s = 'C ' + str(self.sid) ! if self.name is not None: ! s = s + ' ' + self.name ! s = s + '\n' ! for ev in self.events: ! s = s + str(ev) ! s = s + 'c\n' ! return s --- 123,214 ---- ! def parse_line(self, definition): ! """Parses a standard channel specification as can be found in ! VDR's channels.conf file. ! ! All fields of this channel object are set according to the ! specification string given in the first argument. ! """ ! tokens = definition.strip().split(':') ! name=tokens[0] ! nametokens=name.split(';') ! self.name = nametokens[0] ! if len(nametokens)>1: ! self.provider = nametokens[1] ! self.freq = int(tokens[1]) ! self.pol = tokens[2] ! self.source = tokens[3] ! self.srate = int(tokens[4]) ! self.vpid = tokens[5] ! apids = tokens[6] ! self.tpid = int(tokens[7]) ! self.ca = tokens[8] ! self.sid = tokens[9] ! self.nid = tokens[10] ! self.tid = tokens[11] ! self.rid = tokens[12] ! tokens = apids.split(';') ! self.apids = map(str, tokens[0].split(',')) ! if len(tokens) == 2: ! self.dpids = map(str, tokens[1].split(',')) ! self.id = string.join([self.source, self.nid, self.tid, self.sid, 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): ! """Add an EPG event to the list of events for this channel. ! ! If the event has no ID one is assigned. ! ! The first argument shall be an Event object representing ! the event to be added. The start time of the event to add ! must be later than the end of any other event of this ! channel. ! ! The return value is the ID of the event if it satisfied the ! given restrictions and was added, else None is returned. ! """ ! if len(self.events): ! if ev.start <= self.events[-1].start: ! print 'Bad event: %s' % ev.title ! return None ! if self.events[-1].start + self.events[-1].dur > ev.start: ! self.events[-1].dur = ev.start - self.events[-1].start ! if ev.id is None: ! if len(self.events) > 1: ! ev.id = (self.events[-2].id + 1) % 65536 ! else: ! ev.id = 0 ! self.events.append(ev) ! return ev.id ! ! ! def getepgstr(self): ! """Creates a string representation of this channel object ! in the format of VDR's epgdata file including all contained ! EPG events. ! """ ! s = 'C ' + str(self.sid) ! if self.name is not None: ! s = s + ' ' + self.name ! s = s + '\n' ! for ev in self.events: ! s = s + str(ev) ! s = s + 'c\n' ! return s Index: event.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/event.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** event.py 25 Nov 2004 17:02:44 -0000 1.3 --- event.py 7 Jan 2005 12:37:00 -0000 1.4 *************** *** 20,81 **** class Event: ! """Represents an event in the EPG data, i.e. a program. ! """ ! def __init__(self): ! """Constructs an Event object with all fields set to None. ! """ ! self.channel = None ! self.id = None ! self.start = None ! self.dur = None ! self.tableID = None ! self.title = None ! self.subtitle = None ! self.desc = None ! self.source = None ! self.vps = None ! ! def __str__(self): ! """Returns a string representation for this event in the ! format of VDR's epg.data file. ! """ ! s = 'E ' + str(self.id) + ' ' + str(self.start) + ' ' + str(self.dur) ! if self.tableID is not None and self.tableID != 0: ! s = s + ' ' + self.tableID ! s = s + '\n' ! if self.title is not None: ! s = s + 'T ' + self.title + '\n' ! if self.subtitle is not None: ! s = s + 'S ' + self.subtitle + '\n' ! if self.desc is not None: ! s = s + 'D ' + self.desc + '\n' ! s = s + 'e\n' ! return s ! ! ! def __cmp__(self, other): ! """Compares this event against another by their start times. ! """ ! return cmp(self.start, other.start) ! ! def parseheader(self, str): ! """Parses a string containing an event specification in the ! format of VDR's epg.data file. ! ! The first argument is the specification string to parse. ! ! Returns true if the specification string could be parsed ! successfully, false else. ! """ ! tokens = str.split() ! if len(tokens) < 3 or len(tokens) > 4: ! return 0 ! self.id = int(tokens[0]) ! self.start = int(tokens[1]) ! self.dur = int(tokens[2]) ! if len(tokens) == 4: ! self.tableID = tokens[3] ! return 1 --- 20,81 ---- class Event: ! """Represents an event in the EPG data, i.e. a program. ! """ ! def __init__(self): ! """Constructs an Event object with all fields set to None. ! """ ! self.channel = None ! self.id = None ! self.start = None ! self.dur = None ! self.tableID = None ! self.title = None ! self.subtitle = None ! self.desc = None ! self.source = None ! self.vps = None ! ! def __str__(self): ! """Returns a string representation for this event in the ! format of VDR's epg.data file. ! """ ! s = 'E ' + str(self.id) + ' ' + str(self.start) + ' ' + str(self.dur) ! if self.tableID is not None and self.tableID != 0: ! s = s + ' ' + self.tableID ! s = s + '\n' ! if self.title is not None: ! s = s + 'T ' + self.title + '\n' ! if self.subtitle is not None: ! s = s + 'S ' + self.subtitle + '\n' ! if self.desc is not None: ! s = s + 'D ' + self.desc + '\n' ! s = s + 'e\n' ! return s ! ! ! def __cmp__(self, other): ! """Compares this event against another by their start times. ! """ ! return cmp(self.start, other.start) ! ! def parseheader(self, str): ! """Parses a string containing an event specification in the ! format of VDR's epg.data file. ! ! The first argument is the specification string to parse. ! ! Returns true if the specification string could be parsed ! successfully, false else. ! """ ! tokens = str.split() ! if len(tokens) < 3 or len(tokens) > 4: ! return 0 ! self.id = int(tokens[0]) ! self.start = int(tokens[1]) ! self.dur = int(tokens[2]) ! if len(tokens) == 4: ! self.tableID = tokens[3] ! return 1 |
From: Rob S. <rs...@us...> - 2005-01-07 12:33:13
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21271 Modified Files: mark.py recording.py timer.py vdr.py Log Message: Change indentation to 4 spaces, no tabs. Index: recording.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/recording.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** recording.py 24 Nov 2004 17:06:58 -0000 1.3 --- recording.py 7 Jan 2005 12:33:01 -0000 1.4 *************** *** 30,300 **** class Recording: ! """This class represents a VDR recording. ! ! Data about a recording can either be obtained via SVDRP or by ! disk access (which gives more accurate information). ! ! Note that when setting an SVDRP object as a recording's source, ! this SVDRP object is implicitely accessed in some of the getXXX() ! functions. Further accesses go to cache but the SVDRP connection ! may not be closed until after the first access to those getXXX() ! functions. ! """ ! def __init__(self, source = None, index = None): ! """Creates a new Recording object. ! ! The optional source argument is expected to be an SVDRP object or a ! string containing a recording description in the format as ! returned by the SVDRP LSTR command or a string containing ! the path to a recording. ! ! The index is expected to be an integer containing the index ! of this recording into the total list of recordings of a VDR ! instance (base 1). If the source argument is a recording ! description the index is derived from that description rather ! than from the index argument which may thus be ommitted. ! ! With SVDRP connections it is more efficient to run the LSTR ! command once and create a Recording object per line than ! creating multiple Recording object with an SVDRP object and ! varying indexes as this requires as many executions of the ! LSTR command. ! """ ! self.source = source ! self.index = index ! self.name = None ! self.summary = None ! self.start = None ! self.prio = None ! self.lifetime = None ! self.marks = None ! self.resume = None ! ! if source is not None: ! self.init(source, index) ! ! ! def init(self, source, index = None): ! """Initialize the data associated with this recording object ! from the given source. ! ! The source argument is expected to be an SVDRP object or a ! string containing a recording description in the format as ! returned by the SVDRP LSTR command or a string containing ! the path to a recording. ! ! The index is expected to be an integer containing the index ! of this recording into the total list of recordings of a VDR ! instance (base 1). If the source argument is a recording ! description the index is derived from that description rather ! than from the index argument which may thus be ommitted. ! ! With SVDRP connections it is more efficient to run the LSTR ! command once and create a Recording object per line than ! creating multiple Recording object with an SVDRP object and ! varying indexes as this requires as many executions of the ! LSTR command. ! """ ! if isinstance(source, svdrp.SVDRP) and index is not None: ! pat = re.compile('250[ -]' + str(index) + ' ') ! result = source.write_cmd('LSTR\n') ! if result[0:3] != '250': ! print 'lstr returned: ' + result ! for line in result.split('\n'): ! line = line.strip() ! if pat.match(line): ! self.init(line) ! ! elif isinstance(source, StringType) and len(source) > 5 and source[:3] == '250': ! tokens = source.strip()[4:].split(None, 3) ! if len(tokens) == 4: ! self.index = int(tokens[0]) ! if len(tokens[1].split('.')) == 2: ! tokens[1] = tokens[1] + '.' + time.strftime('%Y') ! self.start = int(time.mktime(time.strptime(tokens[1] + ' ' + tokens[2].replace('*', ''), '%d.%m.%Y %H:%M'))) ! self.name = tokens[3] ! if tokens[2].find('*'): ! self.resume = 0 ! else: ! self.resume = -1 ! ! elif isinstance(source, StringType) and os.path.isdir(source): ! pat = re.compile('(/video\d*/)?(.*)/(\d{4}-\d\d-\d\d\.\d\d\.\d\d)\.(\d\d)\.(\d\d)\.rec/?') ! result = pat.match(source) ! if result is None: ! raise TypeError, 'path of recording has unknown format' ! self.index = index ! self.name = result.group(2) ! self.start = int(time.mktime(time.strptime(result.group(3), '%Y-%m-%d.%H.%M'))) ! self.prio = int(result.group(4)) ! self.lifetime = int(result.group(5)) ! ! else: ! raise TypeError, 'argument source has invalid type' ! ! ! def getsource(self): ! """Returns the data source of this recording object. ! ! The return value is either a SVDRP object or a string ! containing the path to this recording. ! """ ! return self.source ! ! ! def setsource(self, source): ! """Sets a data source for this recording object. ! ! The source argument is expected to be either a SVDRP object ! or a string containing the path to a recording. ! """ ! if isinstance(source, svdrp.SVDRP) or \ ! (isinstance(source, StringType) and \ ! os.path.isdir(source)): ! self.source = source ! else: ! raise TypeError, 'argument source has invalid type' ! ! ! def getindex(self): ! """Returns the index of this recording. ! ! The return value is an integer representing the index of this ! recording into the complete list of recordings of a VDR ! instance. ! """ ! return self.index ! ! ! def getname(self): ! """Returns the name of this recording. ! ! The return value is a string containing the name of this ! recording. ! """ ! return self.name ! ! ! def getsummary(self): ! """Returns the summary of this recording. ! ! Depending on the source given at construction time, the ! summary for this recording is retrieved via SVDRP or from ! the summary.vdr file. ! ! The return value is a string containing the summary of this ! recording. ! """ ! if self.summary is None: ! if isinstance(self.source, svdrp.SVDRP): ! self.summary = self.source.lstr(self.index) ! elif isinstance(self.source, StringType) and os.path.isdir(self.source): ! fh = open(os.path.join(self.source, 'summary.vdr'), 'r') ! self.summary = fh.read() ! fh.close() ! return self.summary ! ! ! def getstart(self): ! """Returns the start time of this recording. ! ! The return value is an integer containing the time when the ! recording started as seconds since the epoch. ! """ ! return self.start ! ! ! def getprio(self): ! """Return the priority of this recording. ! ! The return value is an integer containing the priority of ! this recording (which is derived from the corresponding ! timer). ! """ ! return self.prio ! ! ! def getlifetime(self): ! """Returns the lifetime of this recording. ! ! The return value is an integer containing the number of days ! since start this recording is guaranteed to not be deleted by ! VDR. ! """ ! return self.lifetime ! ! ! def getmarks(self): ! """Returns the editing marks of this recording. ! ! The return value is a list of Mark objects representing the ! editing marks of this recording. ! """ ! if self.marks is None: ! if isinstance(self.source, StringType) and \ ! os.path.isdir(self.source) and \ ! os.path.isfile(os.path.join(self.source, 'marks.vdr')): ! ! self.marks = [] ! fh = open(os.path.join(self.source, 'marks.vdr'), 'r') ! line = fh.readline() ! while line: ! mk = mark.Mark(line.strip()) ! self.marks.append(mk) ! line = fh.readline() ! fh.close() ! ! return self.marks ! ! ! def getresume(self): ! """Returns the resume offset for this recording. ! ! The return value is an integer containing the resume offset ! of this recording. ! ! If the recording does not have a resume offset, the return ! value is -1. If the recording has an unknown resume offset ! (may occur when retrieving recording data via SVDRP), the ! return value is 0. ! """ ! if self.resume is None: ! dfn = None ! if isinstance(self.source, StringType) and \ ! os.path.isdir(self.source): ! if os.path.isfile(os.path.join(self.source, 'resume.vdr')): ! fh = open(os.path.join(self.source, 'resume.vdr'), 'r') ! nr = fh.read() ! fh.close() ! self.resume = struct.unpack('l', nr)[0] ! else: ! self.resume = -1 ! elif isinstance(self.source, StringType) and len(self.source) > 5 and self.source[:3] == '250': ! dfn = self.source ! elif isinstance(self.source, svdrp.SVDRP): ! dfn = self.source.lstr(self.index) ! ! if dfn is not None: ! tokens = dfn.strip()[4:].split(None, 3) ! if len(tokens) == 4: ! if tokens[2].find('*'): ! self.resume = 0 ! else: ! self.resume = -1 ! return self.resume ! ! ! def isnew(self): ! """Returns whether this recording is unwatched, i.e. whether ! it does not have a resume offset. ! """ ! return self.getresume() == -1 ! def __cmp__(self, other): ! """Compares two Recording objects by their start times. ! """ ! return cmp(self.start, other.start) --- 30,300 ---- class Recording: ! """This class represents a VDR recording. ! ! Data about a recording can either be obtained via SVDRP or by ! disk access (which gives more accurate information). ! ! Note that when setting an SVDRP object as a recording's source, ! this SVDRP object is implicitely accessed in some of the getXXX() ! functions. Further accesses go to cache but the SVDRP connection ! may not be closed until after the first access to those getXXX() ! functions. ! """ ! def __init__(self, source = None, index = None): ! """Creates a new Recording object. ! ! The optional source argument is expected to be an SVDRP object or a ! string containing a recording description in the format as ! returned by the SVDRP LSTR command or a string containing ! the path to a recording. ! ! The index is expected to be an integer containing the index ! of this recording into the total list of recordings of a VDR ! instance (base 1). If the source argument is a recording ! description the index is derived from that description rather ! than from the index argument which may thus be ommitted. ! ! With SVDRP connections it is more efficient to run the LSTR ! command once and create a Recording object per line than ! creating multiple Recording object with an SVDRP object and ! varying indexes as this requires as many executions of the ! LSTR command. ! """ ! self.source = source ! self.index = index ! self.name = None ! self.summary = None ! self.start = None ! self.prio = None ! self.lifetime = None ! self.marks = None ! self.resume = None ! ! if source is not None: ! self.init(source, index) ! ! ! def init(self, source, index = None): ! """Initialize the data associated with this recording object ! from the given source. ! ! The source argument is expected to be an SVDRP object or a ! string containing a recording description in the format as ! returned by the SVDRP LSTR command or a string containing ! the path to a recording. ! ! The index is expected to be an integer containing the index ! of this recording into the total list of recordings of a VDR ! instance (base 1). If the source argument is a recording ! description the index is derived from that description rather ! than from the index argument which may thus be ommitted. ! ! With SVDRP connections it is more efficient to run the LSTR ! command once and create a Recording object per line than ! creating multiple Recording object with an SVDRP object and ! varying indexes as this requires as many executions of the ! LSTR command. ! """ ! if isinstance(source, svdrp.SVDRP) and index is not None: ! pat = re.compile('250[ -]' + str(index) + ' ') ! result = source.write_cmd('LSTR\n') ! if result[0:3] != '250': ! print 'lstr returned: ' + result ! for line in result.split('\n'): ! line = line.strip() ! if pat.match(line): ! self.init(line) ! ! elif isinstance(source, StringType) and len(source) > 5 and source[:3] == '250': ! tokens = source.strip()[4:].split(None, 3) ! if len(tokens) == 4: ! self.index = int(tokens[0]) ! if len(tokens[1].split('.')) == 2: ! tokens[1] = tokens[1] + '.' + time.strftime('%Y') ! self.start = int(time.mktime(time.strptime(tokens[1] + ' ' + tokens[2].replace('*', ''), '%d.%m.%Y %H:%M'))) ! self.name = tokens[3] ! if tokens[2].find('*'): ! self.resume = 0 ! else: ! self.resume = -1 ! ! elif isinstance(source, StringType) and os.path.isdir(source): ! pat = re.compile('(/video\d*/)?(.*)/(\d{4}-\d\d-\d\d\.\d\d\.\d\d)\.(\d\d)\.(\d\d)\.rec/?') ! result = pat.match(source) ! if result is None: ! raise TypeError, 'path of recording has unknown format' ! self.index = index ! self.name = result.group(2) ! self.start = int(time.mktime(time.strptime(result.group(3), '%Y-%m-%d.%H.%M'))) ! self.prio = int(result.group(4)) ! self.lifetime = int(result.group(5)) ! ! else: ! raise TypeError, 'argument source has invalid type' ! ! ! def getsource(self): ! """Returns the data source of this recording object. ! ! The return value is either a SVDRP object or a string ! containing the path to this recording. ! """ ! return self.source ! ! ! def setsource(self, source): ! """Sets a data source for this recording object. ! ! The source argument is expected to be either a SVDRP object ! or a string containing the path to a recording. ! """ ! if isinstance(source, svdrp.SVDRP) or \ ! (isinstance(source, StringType) and \ ! os.path.isdir(source)): ! self.source = source ! else: ! raise TypeError, 'argument source has invalid type' ! ! ! def getindex(self): ! """Returns the index of this recording. ! ! The return value is an integer representing the index of this ! recording into the complete list of recordings of a VDR ! instance. ! """ ! return self.index ! ! ! def getname(self): ! """Returns the name of this recording. ! ! The return value is a string containing the name of this ! recording. ! """ ! return self.name ! ! ! def getsummary(self): ! """Returns the summary of this recording. ! ! Depending on the source given at construction time, the ! summary for this recording is retrieved via SVDRP or from ! the summary.vdr file. ! ! The return value is a string containing the summary of this ! recording. ! """ ! if self.summary is None: ! if isinstance(self.source, svdrp.SVDRP): ! self.summary = self.source.lstr(self.index) ! elif isinstance(self.source, StringType) and os.path.isdir(self.source): ! fh = open(os.path.join(self.source, 'summary.vdr'), 'r') ! self.summary = fh.read() ! fh.close() ! return self.summary ! ! ! def getstart(self): ! """Returns the start time of this recording. ! ! The return value is an integer containing the time when the ! recording started as seconds since the epoch. ! """ ! return self.start ! ! ! def getprio(self): ! """Return the priority of this recording. ! ! The return value is an integer containing the priority of ! this recording (which is derived from the corresponding ! timer). ! """ ! return self.prio ! ! ! def getlifetime(self): ! """Returns the lifetime of this recording. ! ! The return value is an integer containing the number of days ! since start this recording is guaranteed to not be deleted by ! VDR. ! """ ! return self.lifetime ! ! ! def getmarks(self): ! """Returns the editing marks of this recording. ! ! The return value is a list of Mark objects representing the ! editing marks of this recording. ! """ ! if self.marks is None: ! if isinstance(self.source, StringType) and \ ! os.path.isdir(self.source) and \ ! os.path.isfile(os.path.join(self.source, 'marks.vdr')): ! ! self.marks = [] ! fh = open(os.path.join(self.source, 'marks.vdr'), 'r') ! line = fh.readline() ! while line: ! mk = mark.Mark(line.strip()) ! self.marks.append(mk) ! line = fh.readline() ! fh.close() ! ! return self.marks ! ! ! def getresume(self): ! """Returns the resume offset for this recording. ! ! The return value is an integer containing the resume offset ! of this recording. ! ! If the recording does not have a resume offset, the return ! value is -1. If the recording has an unknown resume offset ! (may occur when retrieving recording data via SVDRP), the ! return value is 0. ! """ ! if self.resume is None: ! dfn = None ! if isinstance(self.source, StringType) and \ ! os.path.isdir(self.source): ! if os.path.isfile(os.path.join(self.source, 'resume.vdr')): ! fh = open(os.path.join(self.source, 'resume.vdr'), 'r') ! nr = fh.read() ! fh.close() ! self.resume = struct.unpack('l', nr)[0] ! else: ! self.resume = -1 ! elif isinstance(self.source, StringType) and len(self.source) > 5 and self.source[:3] == '250': ! dfn = self.source ! elif isinstance(self.source, svdrp.SVDRP): ! dfn = self.source.lstr(self.index) ! ! if dfn is not None: ! tokens = dfn.strip()[4:].split(None, 3) ! if len(tokens) == 4: ! if tokens[2].find('*'): ! self.resume = 0 ! else: ! self.resume = -1 ! return self.resume ! ! ! def isnew(self): ! """Returns whether this recording is unwatched, i.e. whether ! it does not have a resume offset. ! """ ! return self.getresume() == -1 ! def __cmp__(self, other): ! """Compares two Recording objects by their start times. ! """ ! return cmp(self.start, other.start) Index: vdr.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/vdr.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** vdr.py 2 Dec 2004 02:13:47 -0000 1.9 --- vdr.py 7 Jan 2005 12:33:01 -0000 1.10 *************** *** 31,544 **** class VDR: ! """This class represents a VDR instance and all its associated ! data. ! ! It is a container for channel objects and runtime-related data. ! It offers functions to retrieve channel and EPG data from the ! VDR files or via SVDRP. ! ! The channels variable is a dictionary containing integer objects [...999 lines suppressed...] ! self.timers = [] ! ! try: ! index = 1 ! fh = open(self.timerfile, 'r') ! line = fh.readline() ! while line: ! t = timer.Timer(line.strip(), index) ! if t.name is None: ! print 'Could not parse line ' + str(index) + ' in file ' + self.timerfile + ': ' + line.strip() ! self.timers.append(t) ! line = fh.readline() ! index = index + 1 ! fh.close() ! except IOError: ! return None ! ! return self.timers Index: timer.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/timer.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** timer.py 24 Nov 2004 17:07:46 -0000 1.3 --- timer.py 7 Jan 2005 12:33:01 -0000 1.4 *************** *** 44,83 **** ##################################################################### def parsetime(t): ! """Converts a string containing a start or stop time in VDR's ! standard format ('hhmm') to the number of seconds since ! midnight. ! """ ! return int(t[0:2]) * 3600 + int(t[2:4]) * 60 def strtime(t): ! """Converts the numeric start and stop time into a string ! with VDR's standard format ('hhmm'). ! """ ! return string.zfill(str(int(t / 3600)), 2) + string.zfill(str(int(t / 60) % 60), 2) def parserecurrence(s): ! """Converts the given string from VDR's representation of ! recurring timers to a list with 7 elements evaluating to true ! or false. ! """ ! recurrence = [ 0 ] * 7 ! for counter in range(0, 7): ! recurrence[counter] = (not (s[counter] == '-')) ! return recurrence def strrecurrence(r): ! """Converts the internal recurrence representation into a string ! with VDR's format. ! """ ! s = '' ! for x in r: ! if x: ! s = s + 'X' ! else: ! s = s + '-' ! return s --- 44,83 ---- ##################################################################### def parsetime(t): ! """Converts a string containing a start or stop time in VDR's ! standard format ('hhmm') to the number of seconds since ! midnight. ! """ ! return int(t[0:2]) * 3600 + int(t[2:4]) * 60 def strtime(t): ! """Converts the numeric start and stop time into a string ! with VDR's standard format ('hhmm'). ! """ ! return string.zfill(str(int(t / 3600)), 2) + string.zfill(str(int(t / 60) % 60), 2) def parserecurrence(s): ! """Converts the given string from VDR's representation of ! recurring timers to a list with 7 elements evaluating to true ! or false. ! """ ! recurrence = [ 0 ] * 7 ! for counter in range(0, 7): ! recurrence[counter] = (not (s[counter] == '-')) ! return recurrence def strrecurrence(r): ! """Converts the internal recurrence representation into a string ! with VDR's format. ! """ ! s = '' ! for x in r: ! if x: ! s = s + 'X' ! else: ! s = s + '-' ! return s *************** *** 86,246 **** ##################################################################### class Timer: ! """This class represents a VDR timer. ! ! The index variable is an integer containing the index of this ! timer into the total list of timers of a VDR instance. ! ! The name variable is a string containing the name of this timer ! also serving as the name for the corresponding recording. ! ! The summary variable is a string containing the name of this ! timer also serving as the name for the corresponding recording. ! ! The channel variable is an instance of class Channel containing ! the channel this timer should record on. ! ! The start variable is an integer containing the number of seconds ! after midnight specifying the start time of the timer. ! ! The stop variable is an integer containing the number of seconds ! after midnight specifying the stop time of the timer. ! ! The day variable is an integer. If the recurrence variable is ! None, it contains the day of month on which the recording is to ! take place. If the recurrence variable is not None, day specifies ! the day of month on which the recurring recording is to take ! place the first time. ! ! The recurrence variable is a 7-element list containing values ! evaluating either to true or false. Each element represents a ! week day, element 0 being Monday through element 6 being Sunday. ! Their values indicate whether the recording shall take place at ! the corresponding week day. If the recurrence variable is not ! None, day specifies the day of month on which the recurring ! recording is to take place the first time. ! If the recurrence variable is None, this is a one-shot timer. ! ! The prio variable is an integer containing the priority of this ! timer. Values may range between 1 and 99. ! The lifetime variable is an integer containing the lifetime of ! this timer in days. Values may range between 1 and 99. ! ! The active variable is an integer evaluating to true if this ! timer is active and evaluating to false otherwise. ! """ ! def __init__(self, s = None, index = None, vdr = None): ! """Creates a new Timer object. ! ! The optional s argument is expected to be a string containing ! a timer specification as can be found in VDR's timers.conf ! file or as returned by the LSTT SVDRP command. ! ! The optional index argument is expected to be an integer ! containing the index of this timer into the global list of ! timers of a VDR instance. The index of a timer can only be ! derived from its specification string (i.e. the s argument) ! when it it's in the SVDRP format. When reading VDR's ! timers.conf file the timer indexes are encoded implicitely in ! the line number and have thus to be passed explicitely to ! this constructor. ! ! The optional vdr argument is expected to an instance of class ! VDR. When specified, this class can offer more advanced ! abstractions than without it in which case it merely serves ! as a data container. ! """ ! self.index = index ! self.name = None ! self.summary = None ! self.channel = None ! self.start = None ! self.stop = None ! self.day = None ! self.recurrence = None ! self.prio = None ! self.lifetime = None ! self.active = None ! self.vdr = vdr ! ! if s is not None: ! self.parse(s) ! ! ! def parse(self, s): ! """Parses a timer definition and updates the data of this ! object accordingly. ! ! The s argument is expected to be a string containing ! a timer specification as can be found in VDR's timers.conf ! file or as returned by the LSTT SVDRP command. Note that only ! the SVDRP version allows to derive the index of a timer from ! the specification string. ! ! The return value evaluates to true if the string s could be ! parsed successfully. ! """ ! if s is not None and isinstance(s, StringType) and len(s) > 5: ! s = s.strip() ! if s[0:3] == '250': ! s = s[4:] ! res = _pat.match(s) ! if res is not None: ! if res.group('index') is not None: ! self.index = int(res.group('index')) ! self.active = int(res.group('id')) ! self.channel = int(res.group('channel')) ! d = res.group('day') ! if len(d) == 7: ! self.day = None ! self.recurrence = parserecurrence(d) ! else: ! self.day = int(d) ! self.recurrence = None ! self.start = parsetime(res.group('start')) ! self.stop = parsetime(res.group('stop')) ! self.prio = int(res.group('prio')) ! self.lifetime = int(res.group('lifetime')) ! self.name = res.group('name') ! if self.name is None: ! self.name = '' ! self.summary = res.group('summary') ! if self.summary is None: ! self.summary = '' ! return 1 ! return 0 ! ! ! def __cmp__(self, other): ! """Compares two Timer objects by their indexes. ! """ ! return cmp(self.index, other.index) ! def __str__(self): ! """Returns a string representation of this object in the ! format of VDR's timers.conf file. ! """ ! day = '' ! if self.recurrence is not None: ! day = strrecurrence(self.recurrence) ! else: ! day = str(self.day) ! return string.join(map(str, [self.active, self.channel, day, strtime(self.start), strtime(self.stop), self.prio, self.lifetime, self.name, self.summary]), ':') ! def getchannel(self): ! """Returns the channel this timer refers to. ! ! In contrast to the numeric channel variable, this function ! returns a channel object if the vdr variable is not None. ! ! The return value is a instance of class Channel or None if ! this timer refers to no or an invalid channel or the vdr ! variable is None. ! """ ! if self.vdr and self.vdr.channels and self.channel: ! return self.vdr.getchannel(self.channel) ! return None ! --- 86,246 ---- ##################################################################### class Timer: ! """This class represents a VDR timer. ! ! The index variable is an integer containing the index of this ! timer into the total list of timers of a VDR instance. ! ! The name variable is a string containing the name of this timer ! also serving as the name for the corresponding recording. ! ! The summary variable is a string containing the name of this ! timer also serving as the name for the corresponding recording. ! ! The channel variable is an instance of class Channel containing ! the channel this timer should record on. ! ! The start variable is an integer containing the number of seconds ! after midnight specifying the start time of the timer. ! ! The stop variable is an integer containing the number of seconds ! after midnight specifying the stop time of the timer. ! ! The day variable is an integer. If the recurrence variable is ! None, it contains the day of month on which the recording is to ! take place. If the recurrence variable is not None, day specifies ! the day of month on which the recurring recording is to take ! place the first time. ! ! The recurrence variable is a 7-element list containing values ! evaluating either to true or false. Each element represents a ! week day, element 0 being Monday through element 6 being Sunday. ! Their values indicate whether the recording shall take place at ! the corresponding week day. If the recurrence variable is not ! None, day specifies the day of month on which the recurring ! recording is to take place the first time. ! If the recurrence variable is None, this is a one-shot timer. ! ! The prio variable is an integer containing the priority of this ! timer. Values may range between 1 and 99. ! The lifetime variable is an integer containing the lifetime of ! this timer in days. Values may range between 1 and 99. ! ! The active variable is an integer evaluating to true if this ! timer is active and evaluating to false otherwise. ! """ ! def __init__(self, s = None, index = None, vdr = None): ! """Creates a new Timer object. ! ! The optional s argument is expected to be a string containing ! a timer specification as can be found in VDR's timers.conf ! file or as returned by the LSTT SVDRP command. ! ! The optional index argument is expected to be an integer ! containing the index of this timer into the global list of ! timers of a VDR instance. The index of a timer can only be ! derived from its specification string (i.e. the s argument) ! when it it's in the SVDRP format. When reading VDR's ! timers.conf file the timer indexes are encoded implicitely in ! the line number and have thus to be passed explicitely to ! this constructor. ! ! The optional vdr argument is expected to an instance of class ! VDR. When specified, this class can offer more advanced ! abstractions than without it in which case it merely serves ! as a data container. ! """ ! self.index = index ! self.name = None ! self.summary = None ! self.channel = None ! self.start = None ! self.stop = None ! self.day = None ! self.recurrence = None ! self.prio = None ! self.lifetime = None ! self.active = None ! self.vdr = vdr ! ! if s is not None: ! self.parse(s) ! ! ! def parse(self, s): ! """Parses a timer definition and updates the data of this ! object accordingly. ! ! The s argument is expected to be a string containing ! a timer specification as can be found in VDR's timers.conf ! file or as returned by the LSTT SVDRP command. Note that only ! the SVDRP version allows to derive the index of a timer from ! the specification string. ! ! The return value evaluates to true if the string s could be ! parsed successfully. ! """ ! if s is not None and isinstance(s, StringType) and len(s) > 5: ! s = s.strip() ! if s[0:3] == '250': ! s = s[4:] ! res = _pat.match(s) ! if res is not None: ! if res.group('index') is not None: ! self.index = int(res.group('index')) ! self.active = int(res.group('id')) ! self.channel = int(res.group('channel')) ! d = res.group('day') ! if len(d) == 7: ! self.day = None ! self.recurrence = parserecurrence(d) ! else: ! self.day = int(d) ! self.recurrence = None ! self.start = parsetime(res.group('start')) ! self.stop = parsetime(res.group('stop')) ! self.prio = int(res.group('prio')) ! self.lifetime = int(res.group('lifetime')) ! self.name = res.group('name') ! if self.name is None: ! self.name = '' ! self.summary = res.group('summary') ! if self.summary is None: ! self.summary = '' ! return 1 ! return 0 ! ! ! def __cmp__(self, other): ! """Compares two Timer objects by their indexes. ! """ ! return cmp(self.index, other.index) ! def __str__(self): ! """Returns a string representation of this object in the ! format of VDR's timers.conf file. ! """ ! day = '' ! if self.recurrence is not None: ! day = strrecurrence(self.recurrence) ! else: ! day = str(self.day) ! return string.join(map(str, [self.active, self.channel, day, strtime(self.start), strtime(self.stop), self.prio, self.lifetime, self.name, self.summary]), ':') ! def getchannel(self): ! """Returns the channel this timer refers to. ! ! In contrast to the numeric channel variable, this function ! returns a channel object if the vdr variable is not None. ! ! The return value is a instance of class Channel or None if ! this timer refers to no or an invalid channel or the vdr ! variable is None. ! """ ! if self.vdr and self.vdr.channels and self.channel: ! return self.vdr.getchannel(self.channel) ! return None ! Index: mark.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/mark.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mark.py 25 Nov 2002 22:05:35 -0000 1.3 --- mark.py 7 Jan 2005 12:33:01 -0000 1.4 *************** *** 22,85 **** class Mark: ! """This class represents an editing mark of a VDR recording. ! The seconds variable is an integer representing the offset of ! this mark into the recording in seconds. ! ! The frames variable is an integer representing the offset of ! this mark into the recording relative to the position ! indicated by the seconds variable. With 25 fps recordings the ! value of this variable ranges between 0 and 24. ! ! The comment variable is a string containing the comment of this ! mark. If there is no comment associated with this mark, this ! variable is None. ! """ ! _pat = re.compile('(\d\d):(\d\d):(\d\d)(\.(\d+))?( (.*))?') ! def __init__(self, str = None): ! """Construct a new Mark object. ! ! The optional str argument is a string containing the ! specification of an editing mark in the format of VDR's ! marks.vdr file. ! """ ! self.seconds = 0 ! self.frames = 0 ! self.comment = None ! ! if str is not None: ! self.parse(str) ! def parse(self, str): ! """Parse a string for editing mark data and update this ! object's data accordingly. ! ! The str argument is a string containing the ! specification of an editing mark in the format of VDR's ! marks.vdr file. ! """ ! res = _pat.match(str) ! self.seconds = int(res.group(1)) * 3600 + int(res.group(2)) * 60 + int(res.group(3)) ! if result.group(4) is None: ! self.frames = 0 ! else: ! self.frames = int(result.group(5)) ! self.comment = result.group(7) ! ! ! def __str__(self): ! """Returns a string representation of this mark in the format ! of VDR's marks.vdr file. ! """ ! s = str(self.seconds / 3600) + ':' + str((self.seconds / 60) % 60) + ':' + str(self.seconds % 60) ! if self.frames != 0: ! s = s + '.' + str(self.frames) ! if self.comment is not None: ! s = s + ' ' + self.comment ! return s ! --- 22,85 ---- class Mark: ! """This class represents an editing mark of a VDR recording. ! The seconds variable is an integer representing the offset of ! this mark into the recording in seconds. ! ! The frames variable is an integer representing the offset of ! this mark into the recording relative to the position ! indicated by the seconds variable. With 25 fps recordings the ! value of this variable ranges between 0 and 24. ! ! The comment variable is a string containing the comment of this ! mark. If there is no comment associated with this mark, this ! variable is None. ! """ ! _pat = re.compile('(\d\d):(\d\d):(\d\d)(\.(\d+))?( (.*))?') ! def __init__(self, str = None): ! """Construct a new Mark object. ! ! The optional str argument is a string containing the ! specification of an editing mark in the format of VDR's ! marks.vdr file. ! """ ! self.seconds = 0 ! self.frames = 0 ! self.comment = None ! ! if str is not None: ! self.parse(str) ! def parse(self, str): ! """Parse a string for editing mark data and update this ! object's data accordingly. ! ! The str argument is a string containing the ! specification of an editing mark in the format of VDR's ! marks.vdr file. ! """ ! res = _pat.match(str) ! self.seconds = int(res.group(1)) * 3600 + int(res.group(2)) * 60 + int(res.group(3)) ! if result.group(4) is None: ! self.frames = 0 ! else: ! self.frames = int(result.group(5)) ! self.comment = result.group(7) ! ! ! def __str__(self): ! """Returns a string representation of this mark in the format ! of VDR's marks.vdr file. ! """ ! s = str(self.seconds / 3600) + ':' + str((self.seconds / 60) % 60) + ':' + str(self.seconds % 60) ! if self.frames != 0: ! s = s + '.' + str(self.frames) ! if self.comment is not None: ! s = s + ' ' + self.comment ! return s ! |
From: Rob S. <rs...@us...> - 2004-12-12 22:51:27
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3308/vdr Modified Files: svdrp.py Log Message: -Make all indents 4 spaces, no tabs. -Add osd_message(). Index: svdrp.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/svdrp.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** svdrp.py 25 Nov 2004 17:24:11 -0000 1.6 --- svdrp.py 12 Dec 2004 22:51:18 -0000 1.7 *************** *** 61,404 **** class SVDRP(telnetlib.Telnet): ! """A wrapper for VDR's SVDRP interface. ! ! An SVDRP object represents a telnet session to a VDR instance. ! SVDRP functionality is wrapped either at a text or at an object ! level where appropriate. ! ! Since the SVDRP class is derived from the telnetlib.Telnet class, ! the plain telnet interface may also be used to drive the ! protocol manually. ! close_connection makes SVDRP close the connection after each command ! because unfortunately the SVDRP interface only supports one open ! connection (HELLO?!?!). ! """ ! def __init__(self, host, port = SVDRP_PORT, close_connection = 1): ! self.host = host ! self.port = port ! self.close_connection = close_connection ! telnetlib.Telnet.__init__(self, self.host, self.port) #print 'RLS: after telnet init' ! if self.close_connection: ! self.close() ! def open(self, host = None, port = SVDRP_PORT): ! """Connect to a host. ! The optional port argument is the port number to connect to. ! It defaults to the standard SVDRP port (2001). ! Don't try to reopen an already connected instance. ! """ ! #print 'RLS: in open 1' ! if not host and not self.host: ! return ! if self.get_socket(): ! return ! if host: ! #print 'RLS: in open 2' ! telnetlib.Telnet.open(self, host, port) ! else: ! #print 'RLS: in open 3' ! telnetlib.Telnet.open(self, self.host, self.port) ! #time.sleep(0.2) ! # consume all output ! result = '' ! while not result: ! #print 'RLS: reading very eager' ! result = self.read_very_eager() ! #print 'RLS: read' ! #print 'RLS: result="%s"' % result ! def close(self): ! try: ! self.write('quit\n') ! except: ! return ! self.read_all() ! telnetlib.Telnet.close(self) ! return ! def read_reply(self): ! """Read a SVDRP-style reply. ! ! Reads input until a reply to an SVDRP command is found. ! ! The function returns a string containing the complete reply. ! ! The reply is expected to be delimited by a line starting with ! a 3-digit number followed by a blank, followed by arbitrary ! text and a terminating newline. ! """ ! pat = re.compile('^\d\d\d ', re.M) ! reply = '' ! try: ! reply = self.read_some() ! except: ! # connection lost ! print "error 1 reading reply, connection lost" ! return reply ! x=reply[:-1].rfind('\n') ! if x==-1: ! x=0 ! while not pat.search(reply[x:]): ! try: ! buffer = self.read_some() ! reply = reply + buffer ! x=reply[:-1].rfind('\n') ! if x==-1: ! x=0 ! except: ! # connection closed ! print "error 2 reading reply, connection lost" ! return reply ! reply+=self.read_very_eager() ! return reply ! def write_cmd(self, cmd, close = -1): ! """Send text to the server and return its reply. ! ! The cmd argument contains the string written to the ! underlying telnet object. It is made sure that the string ! ends in a newline character so that it is recognized as a ! command by VDR. ! ! The function returns a string containing VDR's reply. ! """ ! if len(cmd) == 0: ! return '' ! ! self.open() ! if cmd[-1] != '\n': ! cmd = cmd + '\n' ! #print "cmd: #%s# " %(cmd) ! self.read_eager() ! self.write(cmd) ! #time.sleep(0.2) ! reply = self.read_reply() ! #print "X: "+reply ! if close > 0: ! self.close() ! #print 'RLS: want to close %d' % close ! elif close == -1 and self.close_connection: ! #print 'RLS: want to close %d' % close ! self.close() ! return reply ! ! def hitk(self, key): ! """Hit the given remote control key. ! ! The key argument is expected to be a string containing one ! of the key names understood by VDR. ! ! The return value is 0 if the command failed and 1 otherwise. ! """ ! result = self.write_cmd('hitk ' + str(key) + '\n') ! if result[0:3] == '250': ! return 1 ! else: ! print 'hitk returned: ' + result ! return 0 ! - def chan(self, chan, vdr = None): - """Switch the current channel. - - The channel argument can be a Channel object or a string - containing a channel name or index or being '+' or '-' for - switching to the next or previous channel. - - The vdr argument is a VDR object from which fully qualified - Channel object can be retrieved. - - The return value is a Channel object representing the - current channel if a VDR object was supplied, else it is the - string returned by VDR or None if the command failed. - """ - if isinstance(chan, channel.Channel): - result = self.write_cmd('chan ' + channel.name + '\n') - elif isinstance(chan, StringType) or isinstance(chan, IntType): - result = self.write_cmd('chan %s\n' % chan) - if result[0:3] == '250': - if vdr: - return vdr.getchannel(result.split(None, 2)[1]) - else: - return result[3:] - else: - print 'chan returned: ' + result - return None - ! def current_chan(self): ! """ ! Return the currently tuned channel. ! """ ! result=self.write_cmd('chan\n') ! channel="" ! if result[0:3] == '250': ! try: ! channel=result.split(None, 2)[1] ! except: ! channel="" ! print "Current_chan="+channel ! else: ! print "result='"+result+"'" ! return channel ! def lstc(self, id = None): ! """List channel details. ! ! If the id argument is an integer the channel with that ! index is listed. If the argument is a string all channels ! containing that string as part of their name are listed. ! If the argument is None, all channels are listed. ! ! The return value is a list of Channel objects representing ! the listed channels. If the command failed, None is returned. ! """ ! if id is None: ! result = self.write_cmd('lstc\n') ! else: ! result = self.write_cmd('lstc ' + str(id) + '\n') ! ! # check first line of output ! if result[0:3] != '250': ! print 'lstc returned: ' + result ! return None ! ! # create Channel objects from output ! channels = [] ! counter = 1 ! for line in result.split('\n'): ! if len(line) > 5: ! tokens = line.strip()[4:].split(None, 1) ! if len(tokens) > 1: ! try: ! c = channel.Channel(tokens[-1], counter) ! channels.append(c) ! counter = counter + 1 ! except: ! print "Error parsing channel "+line ! return channels ! def pute(self, channels): ! """Put data into the EPG list. ! ! The channels argument is a list of Channel objects containing ! the Event objects to be the EPG list. ! ! The return value is true if all EPG events were transmitted ! successfully, false else. ! """ ! result = self.write_cmd('pute\n', close = 0) ! if result[0:3] != '354': ! print 'pute returned: ' + result ! return 0 ! for ch in channels: ! self.write(ch.getepgstr()) ! self.write('.\n') ! result = self.read_reply() ! if self.close_connection: ! self.close() ! if result[0:3] != '250': ! print 'pute returned: ' + result ! return 0 ! ! return 1 ! def lstr(self, index = None): ! """List VDR recordings. ! ! The optional index argument is expected to be an integer ! containing an index into the global list of recordings. ! ! If no index argument is given, the return value is a list of ! Recording objects. If an index is given, a string containing ! the summary for that recording is returned. ! If an error occurs, None is returned. ! """ ! result = '' ! if index is None: ! result = self.write_cmd('lstr\n') ! else: ! result = self.write_cmd('lstr ' + str(index) + '\n') ! if result[0:3] == '550': ! return '' ! elif result[0:3] == '250': ! return result.strip()[4:] ! # check first line of output ! if result[0:3] != '250': ! print 'lstr returned: ' + result ! return None ! ! # create Recording objects from output ! recs = [] ! for line in result.split('\n'): ! if len(line) > 5 and line[:3] == '250': ! r = recording.Recording(line) ! r.setsource(self) ! recs.append(r) ! ! return recs ! def lstt(self, index = None): ! """List VDR timers. ! ! The optional index argument is expected to be an integer ! containing an index into the global list of timers. ! ! If no index argument is given, the return value is a list of ! Timer objects. If an index is given, a Timer object ! representing the timer with the specified index is ! returned. If an error occurs, None is returned. ! """ ! result = '' ! if index is None: ! result = self.write_cmd('lstt\n') ! else: ! result = self.write_cmd('lstt ' + str(index) + '\n') ! # check first line of output ! if result[0:3] != '250': ! print 'lstt returned: ' + result ! return None ! ! # create Recording objects from output ! timers = [] ! for line in result.split('\n'): ! if len(line) > 5 and line[:3] == '250': ! t = timer.Timer(line) ! timers.append(t) ! ! return timers ! --- 61,417 ---- class SVDRP(telnetlib.Telnet): ! """A wrapper for VDR's SVDRP interface. ! ! An SVDRP object represents a telnet session to a VDR instance. ! SVDRP functionality is wrapped either at a text or at an object ! level where appropriate. ! ! Since the SVDRP class is derived from the telnetlib.Telnet class, ! the plain telnet interface may also be used to drive the ! protocol manually. ! close_connection makes SVDRP close the connection after each command ! because unfortunately the SVDRP interface only supports one open ! connection (HELLO?!?!). ! """ ! def __init__(self, host, port = SVDRP_PORT, close_connection = 1): ! self.host = host ! self.port = port ! self.close_connection = close_connection ! telnetlib.Telnet.__init__(self, self.host, self.port) #print 'RLS: after telnet init' ! if self.close_connection: ! self.close() ! def open(self, host = None, port = SVDRP_PORT): ! """Connect to a host. ! The optional port argument is the port number to connect to. ! It defaults to the standard SVDRP port (2001). ! Don't try to reopen an already connected instance. ! """ ! #print 'RLS: in open 1' ! if not host and not self.host: ! return ! if self.get_socket(): ! return ! if host: ! #print 'RLS: in open 2' ! telnetlib.Telnet.open(self, host, port) ! else: ! #print 'RLS: in open 3' ! telnetlib.Telnet.open(self, self.host, self.port) ! #time.sleep(0.2) ! # consume all output ! result = '' ! while not result: ! #print 'RLS: reading very eager' ! result = self.read_very_eager() ! #print 'RLS: read' ! #print 'RLS: result="%s"' % result ! def close(self): ! try: ! self.write('quit\n') ! except: ! return ! self.read_all() ! telnetlib.Telnet.close(self) ! return ! def read_reply(self): ! """Read a SVDRP-style reply. ! ! Reads input until a reply to an SVDRP command is found. ! ! The function returns a string containing the complete reply. ! ! The reply is expected to be delimited by a line starting with ! a 3-digit number followed by a blank, followed by arbitrary ! text and a terminating newline. ! """ ! pat = re.compile('^\d\d\d ', re.M) ! reply = '' ! try: ! reply = self.read_some() ! except: ! # connection lost ! print "error 1 reading reply, connection lost" ! return reply ! x=reply[:-1].rfind('\n') ! if x==-1: ! x=0 ! while not pat.search(reply[x:]): ! try: ! buffer = self.read_some() ! reply = reply + buffer ! x=reply[:-1].rfind('\n') ! if x==-1: ! x=0 ! except: ! # connection closed ! print "error 2 reading reply, connection lost" ! return reply ! reply+=self.read_very_eager() ! return reply ! def write_cmd(self, cmd, close = -1): ! """Send text to the server and return its reply. ! ! The cmd argument contains the string written to the ! underlying telnet object. It is made sure that the string ! ends in a newline character so that it is recognized as a ! command by VDR. ! ! The function returns a string containing VDR's reply. ! """ ! if len(cmd) == 0: ! return '' ! ! self.open() ! if cmd[-1] != '\n': ! cmd = cmd + '\n' ! #print "cmd: #%s# " %(cmd) ! self.read_eager() ! self.write(cmd) ! #time.sleep(0.2) ! reply = self.read_reply() ! #print "X: "+reply ! if close > 0: ! self.close() ! #print 'RLS: want to close %d' % close ! elif close == -1 and self.close_connection: ! #print 'RLS: want to close %d' % close ! self.close() ! return reply ! ! def hitk(self, key): ! """Hit the given remote control key. ! ! The key argument is expected to be a string containing one ! of the key names understood by VDR. ! ! The return value is 0 if the command failed and 1 otherwise. ! """ ! result = self.write_cmd('hitk ' + str(key) + '\n') ! if result[0:3] == '250': ! return 1 ! else: ! print 'hitk returned: ' + result ! return 0 ! def osd_message(self, msg): ! """ ! """ ! result = self.write_cmd('%s %s\n' % (SVDRP_CMD_MESG, msg)) ! if result[0:3] == '250': ! return 1 ! else: ! print '%s returned: %s' % (SVDRP_CMD_MESG, result) ! return 0 ! + def chan(self, chan, vdr = None): + """Switch the current channel. + + The channel argument can be a Channel object or a string + containing a channel name or index or being '+' or '-' for + switching to the next or previous channel. + + The vdr argument is a VDR object from which fully qualified + Channel object can be retrieved. + + The return value is a Channel object representing the + current channel if a VDR object was supplied, else it is the + string returned by VDR or None if the command failed. + """ + if isinstance(chan, channel.Channel): + result = self.write_cmd('chan ' + channel.name + '\n') + # elif isinstance(chan, StringType) or isinstance(chan, IntType): + else: + result = self.write_cmd('chan %s\n' % chan) ! if result[0:3] == '250': ! if vdr: ! return vdr.getchannel(result.split(None, 2)[1]) ! else: ! return result[3:] ! else: ! print 'chan returned: ' + result ! return None ! ! def current_chan(self): ! """ ! Return the currently tuned channel. ! """ ! result=self.write_cmd('chan\n') ! channel="" ! if result[0:3] == '250': ! try: ! channel=result.split(None, 2)[1] ! except: ! channel="" ! print "Current_chan="+channel ! else: ! print "result='"+result+"'" ! return channel ! def lstc(self, id = None): ! """List channel details. ! ! If the id argument is an integer the channel with that ! index is listed. If the argument is a string all channels ! containing that string as part of their name are listed. ! If the argument is None, all channels are listed. ! ! The return value is a list of Channel objects representing ! the listed channels. If the command failed, None is returned. ! """ ! if id is None: ! result = self.write_cmd('lstc\n') ! else: ! result = self.write_cmd('lstc ' + str(id) + '\n') ! ! # check first line of output ! if result[0:3] != '250': ! print 'lstc returned: ' + result ! return None ! ! # create Channel objects from output ! channels = [] ! counter = 1 ! for line in result.split('\n'): ! if len(line) > 5: ! tokens = line.strip()[4:].split(None, 1) ! if len(tokens) > 1: ! try: ! c = channel.Channel(tokens[-1], counter) ! channels.append(c) ! counter = counter + 1 ! except: ! print "Error parsing channel "+line ! return channels ! ! def pute(self, channels): ! """Put data into the EPG list. ! ! The channels argument is a list of Channel objects containing ! the Event objects to be the EPG list. ! ! The return value is true if all EPG events were transmitted ! successfully, false else. ! """ ! result = self.write_cmd('pute\n', close = 0) ! if result[0:3] != '354': ! print 'pute returned: ' + result ! return 0 ! ! for ch in channels: ! self.write(ch.getepgstr()) ! self.write('.\n') ! ! result = self.read_reply() ! if self.close_connection: ! self.close() ! if result[0:3] != '250': ! print 'pute returned: ' + result ! return 0 ! ! return 1 ! def lstr(self, index = None): ! """List VDR recordings. ! ! The optional index argument is expected to be an integer ! containing an index into the global list of recordings. ! ! If no index argument is given, the return value is a list of ! Recording objects. If an index is given, a string containing ! the summary for that recording is returned. ! If an error occurs, None is returned. ! """ ! result = '' ! if index is None: ! result = self.write_cmd('lstr\n') ! else: ! result = self.write_cmd('lstr ' + str(index) + '\n') ! if result[0:3] == '550': ! return '' ! elif result[0:3] == '250': ! return result.strip()[4:] ! # check first line of output ! if result[0:3] != '250': ! print 'lstr returned: ' + result ! return None ! ! # create Recording objects from output ! recs = [] ! for line in result.split('\n'): ! if len(line) > 5 and line[:3] == '250': ! r = recording.Recording(line) ! r.setsource(self) ! recs.append(r) ! ! return recs ! def lstt(self, index = None): ! """List VDR timers. ! ! The optional index argument is expected to be an integer ! containing an index into the global list of timers. ! ! If no index argument is given, the return value is a list of ! Timer objects. If an index is given, a Timer object ! representing the timer with the specified index is ! returned. If an error occurs, None is returned. ! """ ! result = '' ! if index is None: ! result = self.write_cmd('lstt\n') ! else: ! result = self.write_cmd('lstt ' + str(index) + '\n') ! # check first line of output ! if result[0:3] != '250': ! print 'lstt returned: ' + result ! return None ! ! # create Recording objects from output ! timers = [] ! for line in result.split('\n'): ! if len(line) > 5 and line[:3] == '250': ! t = timer.Timer(line) ! timers.append(t) ! ! return timers ! |
From: Rob S. <rs...@us...> - 2004-12-02 02:13:57
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8466/vdr Modified Files: vdr.py Log Message: Set channel id if its not there. Index: vdr.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/vdr.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** vdr.py 1 Dec 2004 18:51:23 -0000 1.8 --- vdr.py 2 Dec 2004 02:13:47 -0000 1.9 *************** *** 296,299 **** --- 296,302 ---- channel.sid, channel.rid], '-') + if not channel.id: + channel.id = key + self.channels[key] = channel |
From: Rob S. <rs...@us...> - 2004-12-02 02:13:18
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8305/vdr Modified Files: channel.py Log Message: Clean up how we add events a bit. Index: channel.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/channel.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** channel.py 1 Dec 2004 18:48:46 -0000 1.6 --- channel.py 2 Dec 2004 02:13:06 -0000 1.7 *************** *** 180,197 **** 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: ! if len(self.events) > 1: ! ev.id = (self.events[-2].id + 1) % 65536 ! else: ! ev.id = 0 ! return ev.id ! else: ! print 'event not later: %s %s %s' % (self.events[-1].start, self.events[-1].dur, ev.start) ! return None --- 180,200 ---- given restrictions and was added, else None is returned. """ ! ! if len(self.events): ! if ev.start <= self.events[-1].start: ! return None ! ! if self.events[-1].start + self.events[-1].dur > ev.start: ! self.events[-1].dur = ev.start - self.events[-1].start ! ! if ev.id is None: ! if len(self.events) > 1: ! ev.id = (self.events[-2].id + 1) % 65536 ! else: ! ev.id = 0 ! ! self.events.append(ev) ! ! return ev.id |
From: Rob S. <rs...@us...> - 2004-12-01 18:51:32
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28570 Modified Files: vdr.py Log Message: Remove debug, small cleanup. Index: vdr.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/vdr.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** vdr.py 25 Nov 2004 18:11:25 -0000 1.7 --- vdr.py 1 Dec 2004 18:51:23 -0000 1.8 *************** *** 22,25 **** --- 22,26 ---- import os.path import re + import string import channel *************** *** 292,298 **** 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 --- 293,299 ---- def addchannel(self, channel): ! key = string.join([channel.source, channel.nid, channel.tid, ! channel.sid, channel.rid], '-') ! self.channels[key] = channel *************** *** 318,322 **** if line=='': continue - # print 'EPG line: %s' % line # special handling of data coming in via SVDRP --- 319,322 ---- *************** *** 333,337 **** if line[0] == 'C': # channel start - print 'EPG channel: %s' % line tokens = line.split() ch_id = tokens[1] --- 333,336 ---- *************** *** 345,349 **** elif line[0] == 'E': # event start - # print 'event start' ev = event.Event() ev.parseheader(line[2:]) --- 344,347 ---- *************** *** 364,368 **** elif line[0] == 'e': # event end - # print 'event end' ch.addevent(ev) ev = None --- 362,365 ---- *************** *** 370,374 **** elif line[0] == 'c': # channel end - print 'EPG adding: %s' % ch.__str__() self.addchannel(ch) ch = None --- 367,370 ---- *************** *** 410,414 **** cmd=cmd+' '+classifier result = self.svdrp.write_cmd(cmd) - #print result fh = cStringIO.StringIO(result) return self.parseepg(fh) --- 406,409 ---- |
From: Rob S. <rs...@us...> - 2004-12-01 18:48:55
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27831 Modified Files: channel.py Log Message: Remove debug, also fix bug where extra rid got appended. Index: channel.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/channel.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** channel.py 27 Nov 2004 01:03:13 -0000 1.5 --- channel.py 1 Dec 2004 18:48:46 -0000 1.6 *************** *** 152,160 **** if len(tokens) == 2: 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 --- 152,157 ---- |
From: Rob S. <rs...@us...> - 2004-11-27 01:13:41
|
Update of /cvsroot/vdrpylib/vdrpylib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2263 Modified Files: HISTORY Log Message: Start history for next release. Index: HISTORY =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/HISTORY,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HISTORY 25 Nov 2002 22:07:26 -0000 1.2 --- HISTORY 27 Nov 2004 01:13:11 -0000 1.3 *************** *** 6,9 **** --- 6,15 ---- + 2004-xx-xx: Version 0.3 + + New maintainer. + * Modifications to work with VDR versions 1.3.x. + * Modifications to work with Python versions 2.3.x. + + 2002-11-25: Version 0.2 + The standard Python distutils are now used for distribution and |
From: Rob S. <rs...@us...> - 2004-11-27 01:10:12
|
Update of /cvsroot/vdrpylib/vdrpylib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1686 Modified Files: setup.py Log Message: Update. Index: setup.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/setup.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** setup.py 25 Nov 2002 21:53:37 -0000 1.1 --- setup.py 27 Nov 2004 01:10:02 -0000 1.2 *************** *** 4,11 **** setup (name = "vdrpylib", ! version = "0.2", description = "VDR Python Library", ! author = "Stefan Goetz", ! author_email = "noo...@us...", url = "http://sourceforge.net/projects/vdrpylib/", --- 4,11 ---- setup (name = "vdrpylib", ! version = "0.3", description = "VDR Python Library", ! author = "vdrpylib development team", ! author_email = "vdr...@li...", url = "http://sourceforge.net/projects/vdrpylib/", |
From: Rob S. <rs...@us...> - 2004-11-27 01:03:27
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv424/vdr Modified Files: channel.py Log Message: Bugfix. Index: channel.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/channel.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** channel.py 25 Nov 2004 18:11:24 -0000 1.4 --- channel.py 27 Nov 2004 01:03:13 -0000 1.5 *************** *** 76,81 **** self.id = None self.indexes = [] ! self.name = None ! self.provider = None self.freq = None self.pol = None --- 76,81 ---- self.id = None self.indexes = [] ! self.name = name ! self.provider = '' self.freq = None self.pol = None *************** *** 107,124 **** ! 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 --- 107,124 ---- ! def dump(self): print 'name: %s' % self.name ! print 'provider: %s' % self.provider ! 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 |
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 |
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) |
From: Rob S. <rs...@us...> - 2004-11-25 17:24:20
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14367 Modified Files: svdrp.py Log Message: Changes and improvements from Thomas Weber. Index: svdrp.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/svdrp.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** svdrp.py 24 Nov 2004 17:18:27 -0000 1.5 --- svdrp.py 25 Nov 2004 17:24:11 -0000 1.6 *************** *** 86,90 **** self.close() ! def open(self, host = None, port = SVDRP_PORT): """Connect to a host. --- 86,90 ---- self.close() ! def open(self, host = None, port = SVDRP_PORT): """Connect to a host. *************** *** 96,111 **** """ #print 'RLS: in open 1' ! if not host and not self.host: ! return ! if self.get_socket(): ! return ! if host: ! #print 'RLS: in open 2' ! telnetlib.Telnet.open(self, host, port) ! else: ! #print 'RLS: in open 3' ! telnetlib.Telnet.open(self, self.host, self.port) #time.sleep(0.2) --- 96,111 ---- """ #print 'RLS: in open 1' ! if not host and not self.host: ! return ! if self.get_socket(): ! return ! if host: ! #print 'RLS: in open 2' ! telnetlib.Telnet.open(self, host, port) ! else: ! #print 'RLS: in open 3' ! telnetlib.Telnet.open(self, self.host, self.port) #time.sleep(0.2) *************** *** 121,129 **** def close(self): ! self.write('quit\n') ! reply = self.read_reply() ! #time.sleep(0.2) telnetlib.Telnet.close(self) ! return reply --- 121,132 ---- def close(self): ! try: ! self.write('quit\n') ! except: ! return ! ! self.read_all() telnetlib.Telnet.close(self) ! return *************** *** 139,154 **** text and a terminating newline. """ ! pat = re.compile('^\d\d\d .*\n', re.M) ! #reply = '' ! reply = self.read_very_eager() ! #print 'RLS: initial reply "%s"' % reply ! while not pat.search(reply): ! buffer = self.read_very_eager() ! reply = reply + buffer ! #print 'RLS: reply now "%s"' % reply ! #time.sleep(0.2) ! #buffer = self.read_very_eager() ! #print 'RLS: reading reply got "%s"' % buffer ! #reply = reply + buffer return reply --- 142,168 ---- text and a terminating newline. """ ! pat = re.compile('^\d\d\d ', re.M) ! reply = '' ! try: ! reply = self.read_some() ! except: ! # connection lost ! print "error 1 reading reply, connection lost" ! return reply ! x=reply[:-1].rfind('\n') ! if x==-1: ! x=0 ! while not pat.search(reply[x:]): ! try: ! buffer = self.read_some() ! reply = reply + buffer ! x=reply[:-1].rfind('\n') ! if x==-1: ! x=0 ! except: ! # connection closed ! print "error 2 reading reply, connection lost" ! return reply ! reply+=self.read_very_eager() return reply *************** *** 166,185 **** if len(cmd) == 0: return '' ! ! self.open() if cmd[-1] != '\n': cmd = cmd + '\n' ! self.read_very_eager() self.write(cmd) #time.sleep(0.2) ! reply = self.read_reply() ! if close > 0: ! self.close() #print 'RLS: want to close %d' % close ! elif close == -1 and self.close_connection: #print 'RLS: want to close %d' % close ! self.close() return reply --- 180,201 ---- if len(cmd) == 0: return '' ! ! self.open() if cmd[-1] != '\n': cmd = cmd + '\n' ! #print "cmd: #%s# " %(cmd) ! self.read_eager() self.write(cmd) #time.sleep(0.2) ! reply = self.read_reply() ! #print "X: "+reply ! if close > 0: ! self.close() #print 'RLS: want to close %d' % close ! elif close == -1 and self.close_connection: #print 'RLS: want to close %d' % close ! self.close() return reply *************** *** 234,238 **** Return the currently tuned channel. """ ! return self.write_cmd('chan\n') --- 250,264 ---- Return the currently tuned channel. """ ! result=self.write_cmd('chan\n') ! channel="" ! if result[0:3] == '250': ! try: ! channel=result.split(None, 2)[1] ! except: ! channel="" ! print "Current_chan="+channel ! else: ! print "result='"+result+"'" ! return channel *************** *** 258,277 **** return None ! if id is None: ! # return recording summary ! return result[4:] ! else: ! # create Channel objects from output ! channels = {} ! counter = 1 ! for line in result.split('\n'): ! if len(line) > 5: ! tokens = line.strip()[4:].split(None, 1) ! if len(tokens) > 1: c = channel.Channel(tokens[-1], counter) ! channels[c.sid] = c counter = counter + 1 ! return channels --- 284,302 ---- return None ! # create Channel objects from output ! channels = [] ! counter = 1 ! for line in result.split('\n'): ! if len(line) > 5: ! tokens = line.strip()[4:].split(None, 1) ! if len(tokens) > 1: ! try: c = channel.Channel(tokens[-1], counter) ! channels.append(c) counter = counter + 1 + except: + print "Error parsing channel "+line ! return channels |
From: Rob S. <rs...@us...> - 2004-11-25 17:02:54
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9566 Modified Files: event.py Log Message: Change from Thomas Weber. Index: event.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/event.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** event.py 25 Nov 2002 22:05:35 -0000 1.2 --- event.py 25 Nov 2004 17:02:44 -0000 1.3 *************** *** 35,38 **** --- 35,39 ---- self.desc = None self.source = None + self.vps = None |
From: Rob S. <rs...@us...> - 2004-11-25 17:01:58
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9053 Modified Files: channel.py Log Message: Changes from Thomas Weber and myself. Index: channel.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/channel.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** channel.py 25 Nov 2002 22:03:50 -0000 1.2 --- channel.py 25 Nov 2004 17:01:47 -0000 1.3 *************** *** 74,82 **** """ def __init__(self, line = None, index = None): self.indexes = [] self.name = None self.freq = None self.pol = None ! self.diseqc = None self.srate = None self.vpid = None --- 74,84 ---- """ def __init__(self, line = None, index = None): + self.id = None self.indexes = [] self.name = None + self.provider = None self.freq = None self.pol = None ! self.source = None self.srate = None self.vpid = None *************** *** 86,89 **** --- 88,94 ---- self.ca = None self.sid = None + self.nid = None + self.tid = None + self.rid = None self.events = [] if line is not None: *************** *** 97,104 **** """ apids = string.join([string.join(map(str, self.apids), ','), string.join(map(str, self.dpids), ',')], ';') ! return string.join(map(str, [self.name, self.freq, self.pol, self.diseqc, self.srate, self.vpid, apids, self.tpid, self.ca, self.sid]), ':') ! def parse(self, string): """Parses a standard channel specification as can be found in VDR's channels.conf file. --- 102,109 ---- """ apids = string.join([string.join(map(str, self.apids), ','), string.join(map(str, self.dpids), ',')], ';') ! return string.join(map(str, [self.name+";"+self.provider, self.freq, self.pol, self.source, self.srate, self.vpid, apids, self.tpid, self.ca, self.sid,self.nid,self.tid,self.rid]), ':') ! def parse(self, definition): """Parses a standard channel specification as can be found in VDR's channels.conf file. *************** *** 107,126 **** specification string given in the first argument. """ ! tokens = string.strip().split(':') ! self.name = tokens[0] self.freq = int(tokens[1]) self.pol = tokens[2] ! self.diseqc = int(tokens[3]) self.srate = int(tokens[4]) ! self.vpid = int(tokens[5]) apids = tokens[6] self.tpid = int(tokens[7]) ! self.ca = int(tokens[8]) ! self.sid = int(tokens[9]) tokens = apids.split(';') ! self.apids = map(int, tokens[0].split(',')) if len(tokens) == 2: ! self.dpids = map(int, tokens[1].split(',')) def addevent(self, ev): """Add an EPG event to the list of events for this channel. --- 112,143 ---- specification string given in the first argument. """ ! tokens = definition.strip().split(':') ! name=tokens[0] ! nametokens=name.split(';') ! self.name = nametokens[0] ! if len(nametokens)>1: ! self.provider = nametokens[1] self.freq = int(tokens[1]) self.pol = tokens[2] ! self.source = tokens[3] self.srate = int(tokens[4]) ! self.vpid = tokens[5] apids = tokens[6] self.tpid = int(tokens[7]) ! self.ca = tokens[8] ! self.sid = tokens[9] ! self.nid = tokens[10] ! self.tid = tokens[11] ! self.rid = tokens[12] tokens = apids.split(';') ! self.apids = map(str, tokens[0].split(',')) if len(tokens) == 2: ! 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): """Add an EPG event to the list of events for this channel. |
From: Rob S. <rs...@us...> - 2004-11-24 17:21:21
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31007 Modified Files: vdr.py Log Message: -Update string handling. -Debug and disable getvpaths until its fixed. Index: vdr.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/vdr.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vdr.py 25 Nov 2002 21:59:02 -0000 1.4 --- vdr.py 24 Nov 2004 17:21:08 -0000 1.5 *************** *** 22,27 **** import os.path import re ! import channel import event import recording --- 22,28 ---- import os.path import re + import string ! from channel import Channel import event import recording *************** *** 123,126 **** --- 124,130 ---- 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) *************** *** 129,134 **** else: paths = [] ! basepath = result.groups(1) ! curnr = int(result.groups(2)) if basepath == None: basepath = '' --- 133,142 ---- 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 = '' *************** *** 298,310 **** if line[0] == 'C': # channel start ! tokens = line.split(None, 2) ! ch_sid = int(tokens[1]) if self.channels.has_key(ch_sid): channel = self.channels[ch_sid] else: ! channel = channel.Channel() channel.sid = ch_sid ! channel.name = tokens[2] elif line[0] == 'E': # event start --- 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 |
From: Rob S. <rs...@us...> - 2004-11-24 17:18:41
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29782 Modified Files: svdrp.py Log Message: -Add SVDRP_CMD_* constants. -Add an option (default for now) to close the SVDRP connection after each command because VDR supports only one open connection. -Checks for host and port. -Debug connection handling, see where we can improve. -Add a method to return the current channel. Index: svdrp.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/svdrp.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** svdrp.py 25 Nov 2002 22:03:51 -0000 1.4 --- svdrp.py 24 Nov 2004 17:18:27 -0000 1.5 *************** *** 24,27 **** --- 24,28 ---- import telnetlib import time + from types import * import channel *************** *** 31,34 **** --- 32,62 ---- # SVDRP constants SVDRP_PORT=2001 + SVDRP_CMD_CHAN = 'chan' + SVDRP_CMD_CLRE = 'clre' + SVDRP_CMD_DELC = 'delc' + SVDRP_CMD_DELR = 'delr' + SVDRP_CMD_DELT = 'delt' + SVDRP_CMD_GRAB = 'grab' + SVDRP_CMD_HELP = 'help' + SVDRP_CMD_HITK = 'hitk' + SVDRP_CMD_LSTC = 'lstc' + SVDRP_CMD_LSTE = 'lste' + SVDRP_CMD_LSTR = 'lstr' + SVDRP_CMD_LSTT = 'lstt' + SVDRP_CMD_MESG = 'mesg' + SVDRP_CMD_MODC = 'modc' + SVDRP_CMD_MODT = 'modt' + SVDRP_CMD_MOVC = 'movc' + SVDRP_CMD_MOVT = 'movt' + SVDRP_CMD_NEWC = 'newc' + SVDRP_CMD_NEWT = 'newt' + SVDRP_CMD_NEXT = 'next' + SVDRP_CMD_PUTE = 'pute' + SVDRP_CMD_SCAN = 'scan' + SVDRP_CMD_STAT = 'stat' + SVDRP_CMD_UPDT = 'updt' + SVDRP_CMD_VOLU = 'volu' + SVDRP_CMD_QUIT = 'quit' + class SVDRP(telnetlib.Telnet): *************** *** 42,58 **** the plain telnet interface may also be used to drive the protocol manually. """ ! def __init__(self, host = None, port = SVDRP_PORT): ! if host is None: ! telnetlib.Telnet.__init__(self) ! else: ! telnetlib.Telnet.__init__(self, host, port) ! # consume all output ! result = '' ! while not result: ! result = self.read_very_eager() ! def open(self, host, port = SVDRP_PORT): """Connect to a host. --- 70,91 ---- the plain telnet interface may also be used to drive the protocol manually. + + close_connection makes SVDRP close the connection after each command + because unfortunately the SVDRP interface only supports one open + connection (HELLO?!?!). """ ! def __init__(self, host, port = SVDRP_PORT, close_connection = 1): ! self.host = host ! self.port = port ! self.close_connection = close_connection ! ! telnetlib.Telnet.__init__(self, self.host, self.port) ! #print 'RLS: after telnet init' ! ! if self.close_connection: ! self.close() ! def open(self, host = None, port = SVDRP_PORT): """Connect to a host. *************** *** 62,66 **** Don't try to reopen an already connected instance. """ ! telnetlib.Telnet.open(self, host, port) --- 95,129 ---- Don't try to reopen an already connected instance. """ ! #print 'RLS: in open 1' ! if not host and not self.host: ! return ! ! if self.get_socket(): ! return ! ! if host: ! #print 'RLS: in open 2' ! telnetlib.Telnet.open(self, host, port) ! else: ! #print 'RLS: in open 3' ! telnetlib.Telnet.open(self, self.host, self.port) ! ! #time.sleep(0.2) ! ! # consume all output ! result = '' ! while not result: ! #print 'RLS: reading very eager' ! result = self.read_very_eager() ! #print 'RLS: read' ! #print 'RLS: result="%s"' % result ! ! ! def close(self): ! self.write('quit\n') ! reply = self.read_reply() ! #time.sleep(0.2) ! telnetlib.Telnet.close(self) ! return reply *************** *** 77,91 **** """ pat = re.compile('^\d\d\d .*\n', re.M) ! reply = '' ! buffer = self.read_very_eager() ! while not pat.search(buffer): ! reply = reply + buffer ! time.sleep(0.2) buffer = self.read_very_eager() ! reply = reply + buffer return reply ! def write_cmd(self, cmd): """Send text to the server and return its reply. --- 140,158 ---- """ pat = re.compile('^\d\d\d .*\n', re.M) ! #reply = '' ! reply = self.read_very_eager() ! #print 'RLS: initial reply "%s"' % reply ! while not pat.search(reply): buffer = self.read_very_eager() ! reply = reply + buffer ! #print 'RLS: reply now "%s"' % reply ! #time.sleep(0.2) ! #buffer = self.read_very_eager() ! #print 'RLS: reading reply got "%s"' % buffer ! #reply = reply + buffer return reply ! def write_cmd(self, cmd, close = -1): """Send text to the server and return its reply. *************** *** 99,107 **** if len(cmd) == 0: return '' if cmd[-1] != '\n': cmd = cmd + '\n' self.read_very_eager() self.write(cmd) ! return self.read_reply() --- 166,187 ---- if len(cmd) == 0: return '' + + self.open() + if cmd[-1] != '\n': cmd = cmd + '\n' self.read_very_eager() self.write(cmd) ! #time.sleep(0.2) ! reply = self.read_reply() ! ! if close > 0: ! self.close() ! #print 'RLS: want to close %d' % close ! elif close == -1 and self.close_connection: ! #print 'RLS: want to close %d' % close ! self.close() ! ! return reply *************** *** 122,126 **** ! def chan(self, channel, vdr = None): """Switch the current channel. --- 202,206 ---- ! def chan(self, chan, vdr = None): """Switch the current channel. *************** *** 136,146 **** string returned by VDR or None if the command failed. """ ! if isinstance(channel, channel.Channel): result = self.write_cmd('chan ' + channel.name + '\n') ! elif isinstance(channel, string._StringType): ! result = self.write_cmd('chan ' + channel + '\n') if result[0:3] == '250': ! if data is not None: ! return data.getchannel(result.split(None, 2)[1]) else: return result[3:] --- 216,226 ---- string returned by VDR or None if the command failed. """ ! if isinstance(chan, channel.Channel): result = self.write_cmd('chan ' + channel.name + '\n') ! elif isinstance(chan, StringType) or isinstance(chan, IntType): ! result = self.write_cmd('chan %s\n' % chan) if result[0:3] == '250': ! if vdr: ! return vdr.getchannel(result.split(None, 2)[1]) else: return result[3:] *************** *** 150,153 **** --- 230,240 ---- + def current_chan(self): + """ + Return the currently tuned channel. + """ + return self.write_cmd('chan\n') + + def lstc(self, id = None): """List channel details. *************** *** 198,202 **** successfully, false else. """ ! result = self.write_cmd('pute\n') if result[0:3] != '354': print 'pute returned: ' + result --- 285,289 ---- successfully, false else. """ ! result = self.write_cmd('pute\n', close = 0) if result[0:3] != '354': print 'pute returned: ' + result *************** *** 208,211 **** --- 295,302 ---- result = self.read_reply() + + if self.close_connection: + self.close() + if result[0:3] != '250': print 'pute returned: ' + result |
From: Rob S. <rs...@us...> - 2004-11-24 17:08:00
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27883 Modified Files: timer.py Log Message: Update types support. Index: timer.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/timer.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** timer.py 25 Nov 2002 22:00:16 -0000 1.2 --- timer.py 24 Nov 2004 17:07:46 -0000 1.3 *************** *** 30,33 **** --- 30,34 ---- import re import string + from types import * *************** *** 181,185 **** parsed successfully. """ ! if s is not None and isinstance(s, string._StringType) and len(s) > 5: s = s.strip() if s[0:3] == '250': --- 182,186 ---- parsed successfully. """ ! if s is not None and isinstance(s, StringType) and len(s) > 5: s = s.strip() if s[0:3] == '250': |
From: Rob S. <rs...@us...> - 2004-11-24 17:07:15
|
Update of /cvsroot/vdrpylib/vdrpylib/vdr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27691 Modified Files: recording.py Log Message: Update types support. Index: recording.py =================================================================== RCS file: /cvsroot/vdrpylib/vdrpylib/vdr/recording.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** recording.py 25 Nov 2002 22:05:36 -0000 1.2 --- recording.py 24 Nov 2004 17:06:58 -0000 1.3 *************** *** 24,27 **** --- 24,28 ---- import struct import time + from types import * import svdrp *************** *** 106,110 **** self.init(line) ! elif isinstance(source, string._StringType) and len(source) > 5 and source[:3] == '250': tokens = source.strip()[4:].split(None, 3) if len(tokens) == 4: --- 107,111 ---- self.init(line) ! elif isinstance(source, StringType) and len(source) > 5 and source[:3] == '250': tokens = source.strip()[4:].split(None, 3) if len(tokens) == 4: *************** *** 119,123 **** self.resume = -1 ! elif isinstance(source, string._StringType) and os.path.isdir(source): pat = re.compile('(/video\d*/)?(.*)/(\d{4}-\d\d-\d\d\.\d\d\.\d\d)\.(\d\d)\.(\d\d)\.rec/?') result = pat.match(source) --- 120,124 ---- self.resume = -1 ! elif isinstance(source, StringType) and os.path.isdir(source): pat = re.compile('(/video\d*/)?(.*)/(\d{4}-\d\d-\d\d\.\d\d\.\d\d)\.(\d\d)\.(\d\d)\.rec/?') result = pat.match(source) *************** *** 150,154 **** """ if isinstance(source, svdrp.SVDRP) or \ ! (isinstance(source, string._StringType) and \ os.path.isdir(source)): self.source = source --- 151,155 ---- """ if isinstance(source, svdrp.SVDRP) or \ ! (isinstance(source, StringType) and \ os.path.isdir(source)): self.source = source *************** *** 189,193 **** if isinstance(self.source, svdrp.SVDRP): self.summary = self.source.lstr(self.index) ! elif isinstance(self.source, string._StringType) and os.path.isdir(self.source): fh = open(os.path.join(self.source, 'summary.vdr'), 'r') self.summary = fh.read() --- 190,194 ---- if isinstance(self.source, svdrp.SVDRP): self.summary = self.source.lstr(self.index) ! elif isinstance(self.source, StringType) and os.path.isdir(self.source): fh = open(os.path.join(self.source, 'summary.vdr'), 'r') self.summary = fh.read() *************** *** 232,236 **** """ if self.marks is None: ! if isinstance(self.source, string._StringType) and \ os.path.isdir(self.source) and \ os.path.isfile(os.path.join(self.source, 'marks.vdr')): --- 233,237 ---- """ if self.marks is None: ! if isinstance(self.source, StringType) and \ os.path.isdir(self.source) and \ os.path.isfile(os.path.join(self.source, 'marks.vdr')): *************** *** 261,265 **** if self.resume is None: dfn = None ! if isinstance(self.source, string._StringType) and \ os.path.isdir(self.source): if os.path.isfile(os.path.join(self.source, 'resume.vdr')): --- 262,266 ---- if self.resume is None: dfn = None ! if isinstance(self.source, StringType) and \ os.path.isdir(self.source): if os.path.isfile(os.path.join(self.source, 'resume.vdr')): *************** *** 270,274 **** else: self.resume = -1 ! elif isinstance(self.source, string._StringType) and len(self.source) > 5 and self.source[:3] == '250': dfn = self.source elif isinstance(self.source, svdrp.SVDRP): --- 271,275 ---- else: self.resume = -1 ! elif isinstance(self.source, StringType) and len(self.source) > 5 and self.source[:3] == '250': dfn = self.source elif isinstance(self.source, svdrp.SVDRP): |