1 from HTMLComponent import *
2 from GUIComponent import *
3 from Tools.FuzzyDate import FuzzyTime
4 from ServiceReference import ServiceReference
5 from Components.MultiContent import MultiContentEntryText, RT_HALIGN_LEFT, RT_HALIGN_RIGHT
7 from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation
9 from enigma import eServiceReference, eServiceCenter, \
10 eServiceCenterPtr, iListableServicePtr, \
11 iStaticServiceInformationPtr
16 def MovieListEntry(serviceref, serviceHandler):
17 if serviceref.flags & eServiceReference.mustDescent:
20 info = serviceHandler.info(serviceref)
23 # ignore service which refuse to info
26 len = info.getLength(serviceref)
28 len = "%d:%02d" % (len / 60, len % 60)
32 begin = info.getInfo(serviceref, iServiceInformation.sTimeCreate)
33 res = [ (serviceref, begin) ]
35 res.append(MultiContentEntryText(pos=(0, 0), size=(560, 30), font = 0, flags = RT_HALIGN_LEFT, text = info.getName(serviceref)))
37 description = info.getInfoString(serviceref, iServiceInformation.sDescription)
42 begin_string = t[0] + ", " + t[1]
44 res.append(MultiContentEntryText(pos=(0, 30), size=(560, 20), font=1, flags=RT_HALIGN_LEFT, text=description))
45 res.append(MultiContentEntryText(pos=(0, 50), size=(270, 20), font=1, flags=RT_HALIGN_LEFT, text=begin_string))
46 res.append(MultiContentEntryText(pos=(290, 50), size=(270, 20), font=1, flags=RT_HALIGN_RIGHT, text=len))
50 class MovieList(HTMLComponent, GUIComponent):
51 def __init__(self, root):
52 GUIComponent.__init__(self)
53 self.l = eListboxPythonMultiContent()
56 self.l.setFont(0, gFont("Regular", 30))
57 self.l.setFont(1, gFont("Regular", 18))
59 def moveToIndex(self, index):
60 self.instance.moveSelectionTo(index)
62 def getCurrentIndex(self):
63 return self.instance.getCurrentIndex()
66 l = self.l.getCurrentSelection()
69 def GUIcreate(self, parent):
70 self.instance = eListbox(parent)
71 self.instance.setContent(self.l)
72 self.instance.setItemHeight(75)
75 self.instance.setContent(None)
78 def reload(self, root = None):
83 self.l.setList(self.list)
85 def removeService(self, service):
86 for l in self.list[:]:
87 if l[0][0] == service:
89 self.l.setList(self.list)
92 # this lists our root service, then building a
98 serviceHandler = eServiceCenter.getInstance()
99 list = serviceHandler.list(root)
102 raise "listing of movies failed"
112 # now process them...
113 for ref in movieList:
114 a = MovieListEntry(ref, serviceHandler)
118 self.list.sort(key=lambda x: -x[0][1])
120 def moveTo(self, serviceref):
124 if str(ServiceReference(x[0][0])) == str(ServiceReference(serviceref)):
127 self.instance.moveSelectionTo(found)
130 self.instance.moveSelection(self.instance.moveDown)