1 from Components.Converter.Converter import Converter
2 from Components.Element import cached, ElementError
3 from enigma import iServiceInformation
4 from ServiceReference import ServiceReference
6 class MovieInfo(Converter, object):
7 MOVIE_SHORT_DESCRIPTION = 0 # meta description when available.. when not .eit short description
8 MOVIE_META_DESCRIPTION = 1 # just meta description when available
9 MOVIE_REC_SERVICE_NAME = 2 # name of recording service
10 MOVIE_REC_FILESIZE = 3 # filesize of recording
12 def __init__(self, type):
13 if type == "ShortDescription":
14 self.type = self.MOVIE_SHORT_DESCRIPTION
15 elif type == "MetaDescription":
16 self.type = self.MOVIE_META_DESCRIPTION
17 elif type == "RecordServiceName":
18 self.type = self.MOVIE_REC_SERVICE_NAME
19 elif type == "FileSize":
20 self.type = self.MOVIE_REC_FILESIZE
22 raise ElementError("'%s' is not <ShortDescription|MetaDescription|RecordServiceName|FileSize> for MovieInfo converter" % type)
23 Converter.__init__(self, type)
27 service = self.source.service
28 info = self.source.info
30 if self.type == self.MOVIE_SHORT_DESCRIPTION:
31 event = self.source.event
33 descr = info.getInfoString(service, iServiceInformation.sDescription)
35 return event.getShortDescription()
38 elif self.type == self.MOVIE_META_DESCRIPTION:
39 return info.getInfoString(service, iServiceInformation.sDescription)
40 elif self.type == self.MOVIE_REC_SERVICE_NAME:
41 rec_ref_str = info.getInfoString(service, iServiceInformation.sServiceref)
42 return ServiceReference(rec_ref_str).getServiceName()
43 elif self.type == self.MOVIE_REC_FILESIZE:
44 return "%d MB" % (info.getInfo(service, iServiceInformation.sFileSize) / (1024*1024))
47 text = property(getText)