Changeset 26
- Timestamp:
- Jun 5, 2006, 1:00:32 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mpd-status/trunk/mpd-status.py
r24 r26 21 21 from os.path import basename, splitext 22 22 23 mpc_fmt = ( 24 "{" 25 "'artist': '''[%artist% - ]''', " 26 "'album': '''[%album% - ]''', " 27 "'track': '''[%track% - ]''', " 28 "'title': '''[%title%]''', " 29 "'length': '''[%time%]''', " 30 "'file': '''[%file%]'''" 31 "}" 32 ) 23 mpc_fmt = '[[%artist% - ][%album% - ][%track% - ]%title%]\n[%file%]' 33 24 cmd = ['mpc', '--format', mpc_fmt] 34 25 lines = Popen(cmd, stdout=PIPE).communicate()[0].split('\n') 26 outstr = lines[0] or splitext(basename(lines[1]))[0] 35 27 36 if len(lines) >= 3: 37 fields = eval(lines[0]) 38 line1 = lines[1].split() 39 fields.update(zip(['status', 'pnum', 'time', 'percent'], line1)) 40 status = fields['status'].strip('[]').capitalize() + ':' 41 if fields['title']: 42 title = '%(artist)s%(album)s%(track)s%(title)s' % fields 43 else: 44 title = splitext(basename(fields['file']))[0] 45 time = '%(time)s/%(length)s %(percent)s' % fields 46 outstr = '%s %s [%s]' % (status, title, time) 47 else: 48 outstr = '--Not playing--' 28 if len(lines) >= 4: 29 (status, pnum, time, percent) = lines[2].split() 30 outstr = status + ' ' + outstr 49 31 50 32 print outstr
Note: See TracChangeset
for help on using the changeset viewer.