2
2
3
3
from plugin import BasePlugin
4
4
from common import shell_split
5
+ from os .path import basename as base
5
6
import tabs
6
7
import mpd
7
8
@@ -19,14 +20,19 @@ def command_mpd(self, args):
19
20
if password :
20
21
c .password (password )
21
22
current = c .currentsong ()
22
- current_time = float (c .status ()['elapsed' ])
23
+ artist = current .get ('artist' , 'Unknown artist' )
24
+ album = current .get ('album' , 'Unknown album' )
25
+ title = current .get ('title' , base (current .get ('file' , 'Unknown title' )))
23
26
24
- s = '%(artist)s - %(title)s (%(album)s)' % current
27
+
28
+ s = '%s - %s (%s)' % (artist , title , album )
25
29
if 'full' in args :
26
- pourcentage = int (current_time / float (current ['time' ]) * 10 )
27
- s += ' \x19 2}[\x19 1}' + '-' * (pourcentage - 1 ) + '\x19 3}+' + '\x19 1}' + '-' * (10 - pourcentage - 1 ) + '\x19 2}]\x19 o'
30
+ if 'elapsed' in current and 'time' in current :
31
+ current_time = float (c .status ()['elapsed' ])
32
+ pourcentage = int (current_time / float (current ['time' ]) * 10 )
33
+ s += ' \x19 2}[\x19 1}' + '-' * (pourcentage - 1 ) + '\x19 3}+' + '\x19 1}' + '-' * (10 - pourcentage - 1 ) + '\x19 2}]\x19 o'
28
34
if not self .core .send_message ('%s' % (s ,)):
29
35
self .core .information ('Cannot send result (%s)' % s , 'Error' )
30
36
31
37
def completion_mpd (self , the_input ):
32
- return the_input .auto_completion (['full' ])
38
+ return the_input .auto_completion (['full' ], quotify = False )
0 commit comments