3 import rtv_programmeinfo
, rtv_utils
5 XMLTV_DATETIME_FORMAT
= "%Y%m%d%H%M%S"
9 def __init__( self
, callback
):
11 self
.callback
= callback
19 def parse_time( self
, xmltv_time
):
20 # TODO: handle XMLTV time zones
21 return rtv_utils
.parse_datetime( xmltv_time
[:14],
22 XMLTV_DATETIME_FORMAT
)
24 def startElement( self
, name
, attrs
):
25 if name
== "programme":
27 self
.startTime
= self
.parse_time( attrs
['start'] )
29 self
.endTime
= self
.parse_time( attrs
['stop'] )
30 if "channel" in attrs
:
31 self
.channel
= attrs
['channel']
33 def endElement( self
, name
):
34 self
.chars
= self
.chars
.strip()
36 self
.title
= self
.chars
37 if name
== "sub-title":
38 self
.sub_title
= self
.chars
40 self
.desc
= self
.chars
41 elif name
== "programme" and self
.title
!= None:
43 pi
= rtv_programmeinfo
.ProgrammeInfo()
45 pi
.sub_title
= self
.sub_title
46 pi
.description
= self
.desc
47 pi
.channel
= self
.channel
48 pi
.startTime
= self
.startTime
49 pi
.endTime
= self
.endTime
61 def characters( self
, data
):