Sort CCC list entries
authorChristian Weiske <cweiske@cweiske.de>
Sat, 30 Dec 2017 23:30:22 +0000 (00:30 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Sat, 30 Dec 2017 23:30:22 +0000 (00:30 +0100)
usr/lib/enigma2/python/Plugins/Extensions/MediaPortal/additions/mediatheken/ccc.py

index f0423a7..7521aa5 100644 (file)
@@ -52,15 +52,21 @@ class CccOverviewScreen(MPScreen):
                                        title = conference.get('title').encode('utf-8')
                                        url = conference.get('url').encode('utf-8')
                                        image_url = conference.get('logo_url').encode('utf-8')
-                                       self.filmliste.append((title, url, image_url));
+                                       updated = conference.get('updated_at').encode('utf-8')
+                                       self.filmliste.append((title, url, image_url, updated));
                except:
                        pass
 
-               #FIXME: sort by updated_at
                if len(self.filmliste) == 0:
                        self.filmliste.append((_('No conferences found!'), '',''))
 
-               self.ml.setList(map(self._defaultlistcenter, self.filmliste))
+               ##sort by title
+               self.filmliste.sort(key=lambda t : t[0].lower())
+               ##sort by updated_at
+               ##makes no sense, updated_at is no release date and changes
+               #self.filmliste.sort(key=lambda t : t[3])
+
+               self.ml.setList(map(self._defaultlistleft, self.filmliste))
                self.keyLocked = False
                # show initial info
                self.showInfos()
@@ -117,7 +123,7 @@ class CccConferenceScreen(MPScreen):
        def loadEvents(self):
                getPage(self.url, agent=std_headers, headers={'Content-Type': 'application/json'}).addCallback(self.parseEvents).addErrback(self.dataError)
 
-        def parseEvents(self, data):
+       def parseEvents(self, data):
                try:
                        events = json.loads(data)
                        if events.has_key('events'):
@@ -133,14 +139,17 @@ class CccConferenceScreen(MPScreen):
                                        description += ", " + str(event.get('view_count')) + " Abrufe\n"
                                        if event.get('description') != None:
                                                description += event.get('description').encode('utf-8')
-                                       self.filmliste.append((title, url, image_url, description));
+                                       # the two False are for the marked list
+                                       self.filmliste.append((title, url, False, False, image_url, description));
                except:
                        pass
 
                if len(self.filmliste) == 0:
                        self.filmliste.append((_('No events found!'), '',''))
 
-               self.ml.setList(map(self._defaultlistcenter, self.filmliste))
+               self.filmliste.sort(key=lambda t : t[0].lower())
+
+               self.ml.setList(map(self._defaultlistleftmarked, self.filmliste))
                self.keyLocked = False
                # show initial info
                self.showInfos()
@@ -151,8 +160,8 @@ class CccConferenceScreen(MPScreen):
                        return
 
                title       = self['liste'].getCurrent()[0][0]
-               imageUrl    = self['liste'].getCurrent()[0][2]
-               description = self['liste'].getCurrent()[0][3]
+               imageUrl    = self['liste'].getCurrent()[0][4]
+               description = self['liste'].getCurrent()[0][5]
 
                self['name'].setText(title)
                self['handlung'].setText(description)