Author: dmeyer
Date: Sun Oct 15 18:30:30 2006
New Revision: 8384

Added:
   trunk/ui/src/audio/plugins/artist.py
Modified:
   trunk/ui/share/freevo_config.py

Log:
Add simple plugin to browse the beacon database for audio files
based on artist and album.


Modified: trunk/ui/share/freevo_config.py
==============================================================================
--- trunk/ui/share/freevo_config.py     (original)
+++ trunk/ui/share/freevo_config.py     Sun Oct 15 18:30:30 2006
@@ -519,6 +519,8 @@
 #
 AUDIO_SHOW_VIDEOFILES = False
 
+plugin.activate('audio.artist')
+
 # ======================================================================
 # Freevo image viewer settings:
 # ======================================================================

Added: trunk/ui/src/audio/plugins/artist.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/audio/plugins/artist.py        Sun Oct 15 18:30:30 2006
@@ -0,0 +1,136 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# artist.py - browse collection based on artist tag
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# This plugin adds an item 'Browse by Artists' to the audio menu. The user
+# can select an artist and after that an album of that artist (or all).
+#
+# This plugin is also a simple example how to write plugins and how to use
+# kaa.beacon in freevo.
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2006 Krister Lagerstrom, Dirk Meyer, et al.
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[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
+#
+# -----------------------------------------------------------------------------
+
+# Kaa imports
+import kaa.beacon
+from kaa.strutils import str_to_unicode
+
+# Freevo imports
+from plugin import MainMenuPlugin
+from menu import Item, ActionItem, Menu, Action
+from audio import AudioItem
+
+class AlbumItem(Item):
+    """
+    Item for on Album (or all) for an artist.
+    """
+    def __init__(self, artist, album, parent):
+        Item.__init__(self, parent)
+        self.artist = artist
+        self.album = album
+        self.name = _('[ All Songs ]')
+        if album:
+            self.name = album
+
+
+    def browse(self):
+        """
+        Show all items from that artist.
+        """
+        title = str_to_unicode(self.artist)
+        if self.album:
+            query = kaa.beacon.query(artist=self.artist, album=self.album)
+            title = '%s - %s' % (title, str_to_unicode(self.album))
+        else:
+            query = kaa.beacon.query(artist=self.artist)
+        # FIXME: monitor query for live update
+        self.pushmenu(Menu(title, [ AudioItem(item, self) for item in query ]))
+
+
+    def actions(self):
+        """
+        Actions for this item.
+        """
+        return [ Action(_('Browse Songs'), self.browse) ]
+
+
+
+class ArtistItem(Item):
+    """
+    Item for an artist.
+    """
+    def __init__(self, artist, parent):
+        Item.__init__(self, parent)
+        self.artist = artist
+
+        # Work around a beacon bug
+        for part in artist.split(' '):
+            self.name += ' ' + str_to_unicode(part.capitalize())
+        self.name = self.name.strip()
+
+
+    def browse(self):
+        """
+        Show all albums from the artist.
+        """
+        # FIXME: monitor query for live update
+        query = kaa.beacon.query(attr='album', artist=self.artist, 
type='audio')
+
+        items = [ AlbumItem(self.artist, None, self) ]
+        for album in query:
+            items.append(AlbumItem(self.artist, album, self))
+        self.pushmenu(Menu(_('Album'), items))
+
+
+    def actions(self):
+        """
+        Actions for this item.
+        """
+        return [ Action(_('Browse Album from %s') % self.name, self.browse) ]
+
+
+
+class PluginInterface(MainMenuPlugin):
+    """
+    Add 'Browse by Artist' to the audio menu.
+    """
+
+    def artists(self, parent):
+        """
+        Show all artists.
+        """
+        items = []
+        for artist in kaa.beacon.query(attr='artist', type='audio'):
+            items.append(ArtistItem(artist, parent))
+        parent.pushmenu(Menu(_('Artists'), items))
+
+
+    def items(self, parent):
+        """
+        Return the main menu item.
+        """
+        return [ ActionItem(_('Browse by Artists'), parent, self.artists) ]

-------------------------------------------------------------------------
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