Changeset 22 for mpd-status/trunk
- Timestamp:
- Mar 11, 2006, 8:06:54 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mpd-status/trunk/mpd-status.py
r21 r22 21 21 from os.path import basename, splitext 22 22 23 fieldnames = [ 24 'artist', 'album', 'track', 'title', 'length', 'filename', 25 'status', 'pnum', 'time', 'percent'26 ]27 delim = '::' 28 format = delim.join([ 29 " [%artist% - ]", "[%album% - ]", "[%track% - ]",30 " [%title%]", "[%time%]", "[%file%]"31 ]) 32 cmd = ['mpc', '--format', format] 33 23 mpc_fmt = ( 24 "{" 25 "'artist': '''[%artist% - ]''', " 26 "'album': '''[%album% - ]''', " 27 "'track': '''[%track% - ]''', " 28 "'title': '''[%title%]''', " 29 "'time': '''[%time%]''', " 30 "'file': '''[%file%]'''" 31 "}" 32 ) 33 cmd = ['mpc', '--format', mpc_fmt] 34 34 lines = Popen(cmd, stdout=PIPE).communicate()[0].split('\n') 35 35 36 36 if len(lines) >= 3: 37 fields = dict(zip( 38 fieldnames, 39 map( 40 lambda s: s.strip('\"'), 41 lines[0].split(delim) + lines[1].split() 42 ) 43 )) 37 fields = eval(lines[0]) 38 line1 = lines[1].split() 39 fields.update(zip(['status', 'pnum', 'length', 'percent'], line1)) 44 40 status = fields['status'].strip('[]').capitalize() + ':' 45 41 if fields['title']:
Note: See TracChangeset
for help on using the changeset viewer.