summaryrefslogtreecommitdiff
path: root/plugins/SongStatus.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SongStatus.py')
-rw-r--r--plugins/SongStatus.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/plugins/SongStatus.py b/plugins/SongStatus.py
index 65e1866..a03476e 100644
--- a/plugins/SongStatus.py
+++ b/plugins/SongStatus.py
@@ -4,10 +4,10 @@ from clPlugin import *
from traceback import print_exc
SS_DEFAULT_FORMAT='<font size="4">now $state</font>'\
-'<font size="8" color="blue">$title</font>'\
+'$if($title,<font size="8" color="blue">$title</font>'\
'<br />by <font size="8" color="green">$artist</font>'\
-'<br /><font size="5" color="red">[$album # $track]</font>'\
-'<br /><font size="4">$time/$length</font>'
+'<br /><font size="5" color="red">[$album # $track]</font>)'\
+'$if($length,<br /><font size="4">$time/$length</font>)'
class wgSongStatus(QtGui.QWidget):
"""Displays the status of the current song, if playing."""
@@ -34,21 +34,16 @@ class wgSongStatus(QtGui.QWidget):
status=monty.getStatus()
song=monty.getCurrentSong()
- values={'state':'', 'time':'', 'length':'', 'title':'', 'artist':'', 'album':'', 'track':''}
+ values={'state':''}
try:
values['state']={'play':'playing', 'stop':'stopped', 'pause':'paused'}[status['state']]
- values['time']=sec2min(status['time'])
- values['length']=sec2min(status['length'])
- values['title']=song.getTitle()
- values['artist']=song.getArtist()
- values['album']=song.getAlbum()
- values['track']=song.getTrack()
+ if 'time' in status:
+ values['length']=sec2min(status['length'])
+ values['time']=sec2min(status['time'])
except:
pass
- txt=settings.get('songstatus.format', SS_DEFAULT_FORMAT)
- for key in values:
- txt=txt.replace('$%s'%(key), values[key])
+ txt=format(settings.get('songstatus.format', SS_DEFAULT_FORMAT), song, values)
self.lblInfo.setText(txt)
def text(self):
@@ -58,6 +53,7 @@ class pluginSongStatus(Plugin):
o=None
def __init__(self, winMain):
Plugin.__init__(self, winMain, 'SongStatus')
+ def _load(self):
self.o=wgSongStatus(None)
def getInfo(self):
return "Show information about the current song."