Author: dmeyer
Date: Sat Feb  3 18:17:58 2007
New Revision: 9145

Added:
   trunk/ui/src/tv/plugins/genre.py
Modified:
   trunk/ui/share/freevo_config.py

Log:
add genre plugin by Jose Taza

Modified: trunk/ui/share/freevo_config.py
==============================================================================
--- trunk/ui/share/freevo_config.py     (original)
+++ trunk/ui/share/freevo_config.py     Sat Feb  3 18:17:58 2007
@@ -420,3 +420,5 @@
 
 TV_DATEFORMAT = '%e-%b' # Day-Month: 11-Jun
 TV_TIMEFORMAT = '%H:%M' # Hour-Minute 14:05
+
+plugin.activate('tv.genre')

Added: trunk/ui/src/tv/plugins/genre.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/tv/plugins/genre.py    Sat Feb  3 18:17:58 2007
@@ -0,0 +1,106 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# genre.py - Browse EPG by Genre
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# This plugin lists all the available genres found in the TV guide. Selecting
+# a genre will show a program list of that genre.
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2007 Dirk Meyer, et al.
+#
+# First Edition: Jose Taza <[EMAIL PROTECTED]>
+# Maintainer:    Jose Taza <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+# python imports
+import logging
+
+# kaa imports
+import kaa.epg
+
+# freevo imports
+from freevo.ui.plugin import MainMenuPlugin
+from freevo.ui.mainmenu import MainMenuItem
+from freevo.ui.menu import Item, Action, ActionItem, Menu
+from freevo.ui.tv.program import ProgramItem
+
+# get logging object
+log = logging.getLogger('tv')
+
+
+class GenreItem(Item):
+    """
+    Item for the TV genre
+    """
+    def __init__(self, parent, name):
+        Item.__init__(self, parent)
+        self.name = name
+
+
+    def actions(self):
+        return [ Action(_('Browse list'), self.browse) ]
+
+
+    def browse(self):
+        """
+        Find all the programs with this genre
+        """
+        items = []
+        for prg in kaa.epg.search():
+            if prg.genre == self.name:
+                items.append(ProgramItem(prg, self))
+        self.get_menustack().pushmenu(Menu(self.name, items, type='tv program 
menu'))
+
+
+#
+# the plugin is defined here
+#
+
+EXCLUDE_GENRES = ('unknown', 'none', '')
+
+class PluginInterface(MainMenuPlugin):
+    """
+    Add 'Browse by Genre' to the TV menu.
+    """
+
+    def category(self, parent):
+        """
+        Show all category.
+        """
+        items = []
+        genres = []
+        # find the available category/genre
+        # find a better way to do this via sqlDB ???... Because this is very 
intensive
+        for prg in kaa.epg.search():
+            genre = str(prg.genre).strip()
+            if prg.genre not in genres and genre.lower() not in EXCLUDE_GENRES:
+                genres.append(prg.genre)
+                items.append(GenreItem(parent, prg.genre))
+        parent.pushmenu(Menu(_('Genre'), items, type='tv listing'))
+
+
+    def items(self, parent):
+        """
+        Return the main menu item.
+        """
+        return [ ActionItem(_('Browse by genre'), parent, self.category) ]

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to