Hi,

I created a patch for the genre plugin to make use of the category AND the genre info that is in the epgdata.com data.

The plugin checks if there is category data (maybe this can be done in a more clever way?) and creates a menu from this.
Categories would be something like: movie, series, sport, children etc.
Every category has then a submenu for the different genre that where found for this category.
That would be e.g action, love, mystery, comedy etc. for the movie category.
If the data contains just genre data like the xmltv data, then there should be no changes with this patch.

Another solution would be to create a additional genre2 plugin, so that the user can choose which one he/she would like to use.


Regards
Tanja

PS: Of course, kaa.epg must also be patched, to fill the category data to the database.
Index: epg/src/server.py
===================================================================
--- epg/src/server.py	(Revision 2532)
+++ epg/src/server.py	(Arbeitskopie)
@@ -69,7 +69,9 @@
             stop = (int, ATTR_SEARCHABLE),
             episode = (unicode, ATTR_SIMPLE),
             subtitle = (unicode, ATTR_SIMPLE),
-            genre = (unicode, ATTR_SEARCHABLE),
+            genre = (unicode, ATTR_SEARCHABLE), 
+            # use this only if you have category and genre!
+            category = (unicode, ATTR_SEARCHABLE),  
             date = (int, ATTR_SEARCHABLE),
             rating = (dict, ATTR_SIMPLE)
         )
Index: ui/src/tv/plugins/genre.py
===================================================================
--- ui/src/tv/plugins/genre.py	(Revision 9327)
+++ ui/src/tv/plugins/genre.py	(Arbeitskopie)
@@ -47,14 +47,17 @@
 # get logging object
 log = logging.getLogger('tv')
 
+EXCLUDE_GENRES = ('unknown', 'none', '', None)
+ALL = _('All Genre')
 
 class GenreItem(Item):
     """
     Item for the TV genre
     """
-    def __init__(self, parent, name):
+    def __init__(self, parent, name, category=None):
         Item.__init__(self, parent)
         self.name = name
+        self.cat = category
 
 
     def actions(self):
@@ -68,21 +71,70 @@
         """
         items = []
         # query epg in background
-        query_data = kaa.epg.search(genre=self.name)
+        if self.cat:
+            query_data = kaa.epg.search(genre=self.name, category=self.cat)
+        else:
+            query_data = kaa.epg.search(genre=self.name)
         yield query_data
         # fetch epg data from InProgress object
         query_data = query_data()
         for prg in query_data:
             items.append(ProgramItem(prg, self))
-        self.get_menustack().pushmenu(Menu(self.name, items, type='tv program menu'))
+        # create menu for programs    
+        self.get_menustack().pushmenu(Menu(self.name, items, 
+                                           type='tv program menu'))
 
 
+class CategoryItem(Item):
+    """
+    Item for a TV category
+    """
+    def __init__(self, parent, name):
+        Item.__init__(self, parent)
+        self.name = name
+        self.parent = parent
+
+
+    def actions(self):
+        return [ Action(_('Browse list'), self.browse)]
+        
+   
+    @kaa.notifier.yield_execution()
+    def browse(self):
+        """ 
+        Find all genres that are in this category
+        """
+        items = []
+         
+        if self.name==ALL:
+            # query epg in background for all genres
+            query_data = kaa.epg.search(attrs=['genre'], distinct=True)
+        else: 
+            # query epg in background for a specific category
+            query_data = kaa.epg.search(attrs=['genre'], category=self.name, 
+                                        distinct=True)
+        
+        yield query_data
+        # fetch epg data from InProgress object
+        query_data = query_data()
+        query_data.sort()
+        for genre, in query_data:
+            if genre not in EXCLUDE_GENRES:
+                if self.name==ALL:
+                    items.append(GenreItem(self.parent, genre))
+                else:    
+                    items.append(GenreItem(self.parent, genre, self.name))
+       
+        # create menu      
+        self.get_menustack().pushmenu(Menu(self.name, items, 
+                                      type='tv listing'))
+    
+
+
 #
 # the plugin is defined here
 #
 
-EXCLUDE_GENRES = ('unknown', 'none', '', None)
-
 class PluginInterface(MainMenuPlugin):
     """
     Add 'Browse by Genre' to the TV menu.
@@ -94,15 +146,31 @@
         Show all category.
         """
         items = []
-        genres = []
-        # find the available category/genre in background
-        query_data = kaa.epg.search(attrs=['genre'], distinct=True)
+               
+        # look if there is category data in the epg data
+        query_data = kaa.epg.search(attrs=['category'], distinct=True)
         yield query_data
         # fetch epg data from InProgress object
         query_data = query_data()
-        for genre, in query_data:
-            if genre not in EXCLUDE_GENRES:
-                items.append(GenreItem(parent, genre))
+        query_data.sort()
+        if len(query_data)>1:
+            items.append(CategoryItem(parent, ALL))
+            # there is category data in the epg
+            for cat, in query_data:
+                if cat not in EXCLUDE_GENRES:
+                    items.append(CategoryItem(parent, cat))
+        else:
+            # maybe there is only genre data in the epg
+            query_data = kaa.epg.search(attrs=['genre'], distinct=True)
+            yield query_data
+            # fetch epg data from InProgress object
+            query_data = query_data()
+            query_data.sort()
+            for genre, in query_data:
+                if genre not in EXCLUDE_GENRES:
+                    items.append(GenreItem(parent, genre))
+        
+        # create menu
         parent.pushmenu(Menu(_('Genre'), items, type='tv listing'))
 
 
@@ -110,4 +178,4 @@
         """
         Return the main menu item.
         """
-        return [ ActionItem(_('Browse by genre'), parent, self.category) ]
+        return [ ActionItem(_('Browse by Genre'), parent, self.category) ]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to