Author: duncan
Date: Thu Feb 21 15:49:04 2008
New Revision: 10409
Log:
Consolidating differencies between rel-1 and rel-1-7
Modified:
branches/rel-1-7/freevo/src/audio/__init__.py
branches/rel-1-7/freevo/src/audio/plugins/album_tree.py
branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py
branches/rel-1-7/freevo/src/audio/plugins/mplayer.py
branches/rel-1-7/freevo/src/audio/plugins/radio.py
branches/rel-1-7/freevo/src/audio/plugins/radioplayer.py
branches/rel-1-7/freevo/src/audio/plugins/xine.py
branches/rel-1/freevo/src/audio/plugins/album_tree.py
Modified: branches/rel-1-7/freevo/src/audio/__init__.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/__init__.py (original)
+++ branches/rel-1-7/freevo/src/audio/__init__.py Thu Feb 21 15:49:04 2008
@@ -132,31 +132,28 @@
def fxdhandler(self, fxd, node):
"""
- parse audio specific stuff from fxd files
+ parse audio specific stuff from fxd files::
- <?xml version="1.0" ?>
- <freevo>
- <audio title="Smoothjazz">
- <cover-img>foo.jpg</cover-img>
- <mplayer_options></mplayer_options>
- <player>xine</player>
- <playlist/>
- <reconnect/>
- <url>http://64.236.34.141:80/stream/1005</url>
-
- <info>
- <genre>JAZZ</genre>
- <description>A nice description</description>
- </info>
-
- </audio>
- </freevo>
-
- Everything except title and url is optional. If <player> is set,
- this player will be used (possible xine or mplayer). The tag
- <playlist/> signals that this url is a playlist (mplayer needs that).
- <reconnect/> sihnals that the player should reconnect when the
- connection stopps.
+ <?xml version="1.0" ?>
+ <freevo>
+ <audio title="Smoothjazz">
+ <cover-img>foo.jpg</cover-img>
+ <mplayer_options></mplayer_options>
+ <player>xine</player>
+ <playlist/>
+ <reconnect/>
+ <url>http://64.236.34.141:80/stream/1005</url>
+ <info>
+ <genre>JAZZ</genre>
+ <description>A nice description</description>
+ </info>
+ </audio>
+ </freevo>
+
+ Everything except title and url is optional. If <player> is set, this
player
+ will be used (possible xine or mplayer). The tag <playlist/> signals
that this
+ url is a playlist (mplayer needs that). <reconnect/> sihnals that the
player
+ should reconnect when the connection stopps.
"""
a = AudioItem('', fxd.getattr(None, 'parent', None), scan=False)
Modified: branches/rel-1-7/freevo/src/audio/plugins/album_tree.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/album_tree.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/album_tree.py Thu Feb 21
15:49:04 2008
@@ -49,25 +49,25 @@
Inspired by foobar2000 albumlist (NOT playlist tree)
(http://www.hydrogenaudio.org/forums/index.php?showforum=28)
This is a tree/not a playlist generator.
- generates ugly sql(only as ugly as the spec),but sqlite is fast enough.
+ generates ugly sql(only as ugly as the spec), but sqlite is fast enough.
operates directly on a sqlite cursor.
see http://www.sqlite.org/lang_expr.html for "scripting" functions
"""
- def __init__(self,name='unnamed',cursor=None,spec=None,alt_grouping=None):
+ def __init__(self, name='unnamed', cursor=None, spec=None,
alt_grouping=None):
self.spec = spec
self.name = name
self.alt_grouping = alt_grouping
self.cursor = cursor
- def get_query(self,data):
+ def get_query(self, data):
"""
builds query
"""
where = []
- for i,item in enumerate(self.spec):
+ for i, item in enumerate(self.spec):
if i < len(data):
- where.append('%s="%s"' % (item,data[i]))
+ where.append('%s="%s"' % (item, data[i]))
else:
break
if where:
@@ -80,21 +80,21 @@
if self.alt_grouping and self.alt_grouping[i]:
grouping = self.alt_grouping[i]
- #last level in tree-->,no-count ; use path,filename + order by instead
of group by
+ #last level in tree-->, no-count ; use path, filename + order by
instead of group by
if len(self.spec) -1 == len(data):
- query = 'select %s,path,filename from music'% (self.spec[i],)
+ query = 'select %s, path, filename from music'% (self.spec[i], )
query += wheresql
query += ' order by ' + grouping
#normal/not last level in tree
else:
- query = 'select %s,count() from music'% (self.spec[i],)
+ query = 'select %s, count() from music'% (self.spec[i], )
query += wheresql
- query += ' group by %s order by %s' % (grouping,grouping)
+ query += ' group by %s order by %s' % (grouping, grouping)
return query
- def execute(self,data):
+ def execute(self, data):
self.cursor.execute(self.get_query(data))
return list(self.cursor)
#should return an iterator/generator instead of a list?
@@ -104,10 +104,9 @@
"""
Plugin to browse songs in a tree-like way.
- Requires:
- * pysqlite.
+ @requires: pysqlite.
- === Pre Installation ===
+ B{Pre-Installation}
The sqlite-meta-database should be available.
@@ -115,14 +114,14 @@
you can skip the rest of the pre-install if those plugins
are already succesfully installed.
- * install pysqlite,sqlite
- * edit your local_config.py
- * Configure AUDIO_ITEMS ('''AudioConfig''', don't leave it at the
default!)
- * run freevo cache
- * wait.....
- * The meta database should be available now.
+ - install pysqlite, sqlite
+ - edit your local_config.py
+ Configure AUDIO_ITEMS ('''AudioConfig''', don't leave it at the
default!)
+ - run freevo cache
+ - wait.....
+ - The meta database should be available now.
- === Configuration ===
+ B{Configuration}
Edit your local_config.py and add this:
@@ -130,44 +129,44 @@
| AUDIO_ALBUM_TREE_SPEC = []
|
| #You could add all trees below:, but probably you only want 1 or 2 of
them:
- | AUDIO_ALBUM_TREE_SPEC.append({'name':'Artist/Album/Track'
- |,'spec':["artist","album","track||'-'||title"]
- |,'alt_grouping':[None,None,'track']
+ | AUDIO_ALBUM_TREE_SPEC.append({'name':'Artist/Album/Track',
+ | 'spec':["artist", "album", "track||'-'||title"],
+ | 'alt_grouping':[None, None, 'track']
| })
|
| #A case sensitive tree like above...
| #Is easy to convert to a convert to a case insensitive tree like below:
- | AUDIO_ALBUM_TREE_SPEC.append({'name':'nocase:artist/album/Track'
- |,'spec':["lower(artist)","lower(album)","track||'-'||title"]
- |,'alt_grouping':[None,None,'track']
+ | AUDIO_ALBUM_TREE_SPEC.append({'name':'nocase:artist/album/Track',
+ | 'spec':["lower(artist)", "lower(album)", "track||'-'||title"],
+ | 'alt_grouping':[None, None, 'track']
| })
|
| #my favorite layout:
- | AUDIO_ALBUM_TREE_SPEC.append({'name':'(A-Z)/Artist/Album-Year/Track'
- |,'spec':["upper(substr(artist,0,1))"
- |,"artist","album||'-'||year"
- |,"track||'-'||title"]
- |,'alt_grouping':[None,None,'year||album','track']
+ | AUDIO_ALBUM_TREE_SPEC.append({'name':'(A-Z)/Artist/Album-Year/Track',
+ | 'spec':["upper(substr(artist, 0, 1))",
+ | "artist", "album||'-'||year",
+ | "track||'-'||title"],
+ | 'alt_grouping':[None, None, 'year||album', 'track']
| })
|
| #you can comment out a tree definition like this:
- | #AUDIO_ALBUM_TREE_SPEC.append({'name':'Artist-Album/Track'
- | #,'spec':["artist||'-'||album","track||'-'||title"]
- | #,'alt_grouping':[None,'track']
+ | #AUDIO_ALBUM_TREE_SPEC.append({'name':'Artist-Album/Track',
+ | # 'spec':["artist||'-'||album", "track||'-'||title"],
+ | # 'alt_grouping':[None, 'track']
| #})
|
| #More Examples:
- | AUDIO_ALBUM_TREE_SPEC.append({'name':'Year/Artist-Album/Track'
- |,'spec':["year","artist||'-'||album","track||'-'||title"]
- |,'alt_grouping':[None,None,None,'track']
+ | AUDIO_ALBUM_TREE_SPEC.append({'name':'Year/Artist-Album/Track',
+ | 'spec':["year", "artist||'-'||album", "track||'-'||title"],
+ | 'alt_grouping':[None, None, None, 'track']
| })
|
- | AUDIO_ALBUM_TREE_SPEC.append({'name':'Dirtitle/Artist/Album/Track'
- |,'spec':["dirtitle","artist","album","track||'-'||title"]
- |,'alt_grouping':[None,None,None,'track']
+ | AUDIO_ALBUM_TREE_SPEC.append({'name':'Dirtitle/Artist/Album/Track',
+ | 'spec':["dirtitle", "artist", "album", "track||'-'||title"],
+ | 'alt_grouping':[None, None, None, 'track']
| })
- === Post Installation ===
+ B{Post Installation}
New plugins are not immediately visible on the freevo webserver.
@@ -179,9 +178,9 @@
def __init__(self):
plugin.MainMenuPlugin.__init__(self)
#config.EVENTS['audio']['DISPLAY'] = Event(FUNCTION_CALL,
arg=self.detach)
- self.show_item = menu.MenuItem(_('Album
Tree'),action=self.onchoose_main)
+ self.show_item = menu.MenuItem(_('Album Tree'),
action=self.onchoose_main)
self.show_item.type = 'audio'
- plugin.register(self,'audio.album_tree')
+ plugin.register(self, 'audio.album_tree')
if (not config.__dict__.has_key('AUDIO_ALBUM_TREE_SPEC') ) or (not
config.AUDIO_ALBUM_TREE_SPEC):
print '*ALBUM_TREE:"config.AUDIO_ALBUM_TREE_SPEC" is
empty:DEMO-MODE:USING PREDEFINED TREES'
@@ -196,14 +195,14 @@
_debug_('shutdown', 2)
db.close()
- def load_spec(self,spec_list):
+ def load_spec(self, spec_list):
"""
load definitions from config
"""
curs = db.cursor
self.album_tree_list = []
for specdef in spec_list:
- tree = treeSpec(specdef['name'],curs,specdef['spec'])
+ tree = treeSpec(specdef['name'], curs, specdef['spec'])
if specdef.has_key('alt_grouping'):
tree.alt_grouping = specdef['alt_grouping']
self.album_tree_list.append(tree)
@@ -214,41 +213,29 @@
"""
curs = db.cursor
self.album_tree_list = [
- treeSpec('Artist/Album/Track',curs
-,["artist","album","track||'-'||title"],[None,None,'track'])
-
-,treeSpec('(A-Z)/Artist/Year-Album/Track',curs
-,["upper(substr(artist,0,1))",
- "artist","album||'-'||year"
-,"track||'-'||title"],[None,None,'year||album','track'])
-
-
-,treeSpec('Artist-Album/Track',curs
-,["artist||'-'||album","track||'-'||title"],[None,'track'])
-
-,treeSpec('a-z/artist/title-album-track',curs
-,["lower(substr(artist,0,1))"
-,"lower(artist)","title||'-'||album||'-'||track"])
-
-,treeSpec('Year/Artist-Album/Track',curs,
- ["year","artist||'-'||album","track||'-'||title"]
-,[None,None,None,'track'])
+ treeSpec('Artist/Album/Track', curs, ["artist", "album",
"track||'-'||title"], [None, None, 'track']),
+ treeSpec('(A-Z)/Artist/Year-Album/Track', curs,
+ ["upper(substr(artist, 0, 1))", "artist", "album||'-'||year",
"track||'-'||title"],
+ [None, None, 'year||album', 'track']),
+ treeSpec('Artist-Album/Track', curs, ["artist||'-'||album",
"track||'-'||title"], [None, 'track']),
+ treeSpec('a-z/artist/title-album-track', curs,
+ ["lower(substr(artist, 0, 1))", "lower(artist)",
"title||'-'||album||'-'||track"]),
+ treeSpec('Year/Artist-Album/Track', curs,
+ ["year", "artist||'-'||album", "track||'-'||title"], [None, None,
None, 'track']),
#demo:
-,treeSpec('Dirtitle/Artist/Album/Track',curs
-,["dirtitle","artist","album","track||'-'||title"]
-,[None,None,None,'track'])
-
+ treeSpec('Dirtitle/Artist/Album/Track', curs,
+ ["dirtitle", "artist", "album", "track||'-'||title"], [None, None,
None, 'track'])
]
#treespec below:
- #INSANE,but this is what i like about foobar2000.
+ #INSANE, but this is what i like about foobar2000.
#NOT YET POSSIBLE, "album_artist" tag is not in sql database.
#Surprisingly:sqlite can handle it pretty fast.
- #treeSpec('a-z/album_artist/album/track-(artist)-title',curs
- #,["lower(substr(ifnull(album_artist,artist),0,1))",
- # "ifnull(album_artist,artist)"
-
#,"album","track||'-'||nullif(artist,ifnull(album_artist,artist))||'-'||title"]
- #,[None,None,None,None,'track'])
+ #treeSpec('a-z/album_artist/album/track-(artist)-title', curs,
+ # ["lower(substr(ifnull(album_artist, artist), 0, 1))",
+ # "ifnull(album_artist, artist)", "album",
+ # "track||'-'||nullif(artist, ifnull(album_artist,
artist))||'-'||title"],
+ # [None, None, None, None, 'track'])
def items(self, parent):
@@ -258,15 +245,14 @@
#todo: add random 10 etc..
return []
- def onchoose_main(self,arg=None, menuw=None):
+ def onchoose_main(self, arg=None, menuw=None):
"""
main menu
"""
#
items = []
for tree in self.album_tree_list:
- items.append(menu.MenuItem(tree.name
-,action=self.onchoose_node,arg=[tree,[]]) )
+ items.append(menu.MenuItem(tree.name, action=self.onchoose_node,
arg=[tree, []]))
#myobjectmenu = menu.Menu(_('Album Tree'), items,
reload_func=menuw.back_one_menu )
myobjectmenu = menu.Menu(_('Album Tree'), items)
@@ -274,7 +260,7 @@
menuw.pushmenu(myobjectmenu)
menuw.refresh()
- def onchoose_node(self,arg=None, menuw=None):
+ def onchoose_node(self, arg=None, menuw=None):
"""
browse through a tree specification
"""
@@ -285,12 +271,12 @@
mylistofitems = []
if len(tree.spec) -1 <> len(data): #non-tracks
- for tree_item,count in tree.execute(data):
+ for tree_item, count in tree.execute(data):
mylistofitems.append(
- menu.MenuItem("%s(%i)" % (tree_item,count)
-,action=self.onchoose_node,arg=[tree,data + [tree_item]]))
+ menu.MenuItem("%s(%i)" % \
+ (tree_item, count), action=self.onchoose_node,
arg=[tree, data + [tree_item]]))
else: #tracks
- self.onchoose_last_node(tree,data,menuw)
+ self.onchoose_last_node(tree, data, menuw)
return
#should be impossible?
@@ -304,28 +290,24 @@
menuw.pushmenu(myobjectmenu)
menuw.refresh()
- def onchoose_last_node(self,tree,data,menuw):
+ def onchoose_last_node(self, tree, data, menuw):
"""
last node in tree generates a playlist.
"""
title = '-'.join(data)
#creating of audio items is slow.
#need a progress-bar.
- pl = playlist.Playlist(
- name='-'.join(data)
-,playlist=[]
-,display_type='audiocd')
-
- tracks = tree.execute(data) #returns list of (desc,path,filename)
+ pl = playlist.Playlist(name='-'.join(data), playlist=[],
display_type='audiocd')
+ tracks = tree.execute(data) #returns list of (desc, path, filename)
pop = ProgressBox(text=_('Generating playlist...'), full=len(tracks))
pop.show()
items = []
i = 0
- for desc,path,filename in tracks:
- filepath = os.path.join(path,filename)
- item = audioitem.AudioItem(filepath,parent=pl)
+ for desc, path, filename in tracks:
+ filepath = os.path.join(path, filename)
+ item = audioitem.AudioItem(filepath, parent=pl)
item.name = desc
item.track = i
items.append( item)
@@ -338,9 +320,9 @@
#note/question for core developers:
#command below causes strange errors?
#plugin.__plugin_type_list__ is empty??? but it's Not?
- #pl.browse(arg=None,menuw=menuw)
- #print 'LIST=',plugin.__plugin_type_list__['mimetype']
+ #pl.browse(arg=None, menuw=menuw)
+ #print 'LIST=', plugin.__plugin_type_list__['mimetype']
#workaround: not all features of a real playlist :(
- mymenu = menu.Menu(title, pl.playlist,item_types="audio")
+ mymenu = menu.Menu(title, pl.playlist, item_types="audio")
menuw.pushmenu(mymenu)
Modified: branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py Thu Feb 21
15:49:04 2008
@@ -43,11 +43,8 @@
return self.current_line
def putline(self, line):
- try:
- self.file.write("%s\n" % line)
- self.file.flush()
- except socket.error, why:
- pass
+ self.file.write("%s\n" % line)
+ self.file.flush()
self.done = False
def get_pair(self):
Modified: branches/rel-1-7/freevo/src/audio/plugins/mplayer.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/mplayer.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/mplayer.py Thu Feb 21
15:49:04 2008
@@ -78,7 +78,7 @@
_debug_('mode=%r' % (item.mode), 2)
_debug_('mimetype=%r' % (item.mimetype), 2)
except Exception, e:
- print e
+ pass
if item.url.startswith('radio://'):
_debug_('%r unplayable' % (item.url))
return 0
Modified: branches/rel-1-7/freevo/src/audio/plugins/radio.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/radio.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/radio.py Thu Feb 21 15:49:04 2008
@@ -65,6 +65,7 @@
def checktv(self):
+ """ Check if something is recording """
self.tvlockfile = config.FREEVO_CACHEDIR + '/record.*'
if len(glob.glob(self.tvlockfile)) > 0:
return True
@@ -72,7 +73,7 @@
def play(self, arg=None, menuw=None):
- print self.station+" "+str(self.station_index)+" "+self.name
+ _debug_('station=%r station_index=%r name=%r' % (self.station,
self.station_index, self.name))
# self.parent.current_item = self
self.elapsed = 0
@@ -80,7 +81,6 @@
self.menuw = menuw
if self.checktv():
- #AlertBox(text=_('Cannot play - recording in progress')).show()
AlertBox(text=_('Cannot play - recording in progress'),
handler=self.confirm).show()
return 'Cannot play with RadioPlayer - recording in progress'
@@ -103,7 +103,7 @@
"""
Stop the current playing
"""
- print 'RadioItem stop'
+ _debug_('stop')
self.player.stop()
Modified: branches/rel-1-7/freevo/src/audio/plugins/radioplayer.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/radioplayer.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/radioplayer.py Thu Feb 21
15:49:04 2008
@@ -73,10 +73,9 @@
"""
try:
_debug_('url=%r' % (item.url), 2)
- _debug_('mode=%r' % (item.mode), 2)
- _debug_('mimetype=%r' % (item.mimetype), 2)
+ _debug_('item.__dict__=%r' % (item.__dict__))
except Exception, e:
- print e
+ _debug_('%s' % e)
if item.url.startswith('radio://'):
_debug_('%r good' % (item.url))
return 2
@@ -94,7 +93,7 @@
self.starttime = time.time()
try:
- print 'RadioPlayer.play() %s' % self.item.station
+ _debug_('play() %s' % self.item.station)
except AttributeError:
return 'Cannot play with RadioPlayer - no station'
@@ -110,11 +109,11 @@
if config.RADIO_CMD.find('ivtv-radio') >= 0:
# IVTV cards
- print '%s -f %s &' % (config.RADIO_CMD, self.item.station)
+ _debug_('%s -f %s &' % (config.RADIO_CMD, self.item.station))
os.system('%s -f %s &' % (config.RADIO_CMD, self.item.station))
else:
# BTTV cards
-
+ _debug_('%s' % (config.RADIO_CMD_START % self.item.station))
os.system('%s' % (config.RADIO_CMD_START % self.item.station))
thread.start_new_thread(self.__update_thread, ())
@@ -141,6 +140,7 @@
os.system('killall -9 aplay')
else:
# BTTV cards
+ _debug_('%s' % (config.RADIO_CMD_STOP))
os.system('%s' % config.RADIO_CMD_STOP)
rc.post_event(PLAY_END)
@@ -157,6 +157,7 @@
self.item.elapsed = int(time.time() - self.starttime)
self.playerGUI.refresh()
+
def eventhandler(self, event, menuw=None):
"""
eventhandler for mplayer control. If an event is not bound in this
@@ -170,6 +171,7 @@
# everything else: give event to the items eventhandler
return self.item.eventhandler(event)
+
def __update_thread(self):
"""
OSD update thread
Modified: branches/rel-1-7/freevo/src/audio/plugins/xine.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/xine.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/xine.py Thu Feb 21 15:49:04 2008
@@ -88,7 +88,7 @@
_debug_('mode=%r' % (item.mode), 2)
_debug_('mimetype=%r' % (item.mimetype), 2)
except Exception, e:
- print e
+ pass
if item.url.startswith('radio://'):
_debug_('%r unplayable' % (item.url))
return 0
Modified: branches/rel-1/freevo/src/audio/plugins/album_tree.py
==============================================================================
--- branches/rel-1/freevo/src/audio/plugins/album_tree.py (original)
+++ branches/rel-1/freevo/src/audio/plugins/album_tree.py Thu Feb 21
15:49:04 2008
@@ -1,6 +1,6 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
-# album_tree.py 0.5.1 plugin for the audio player
+# plugin for the audio player
# -----------------------------------------------------------------------
# $Id$
# Author: Martijn Voncken(2005)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog