Changeset 28 for mpd-status/trunk/mpd-status.py
- Timestamp:
- Feb 17, 2007, 4:14:34 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mpd-status/trunk/mpd-status.py
r27 r28 18 18 # 02110-1301, USA 19 19 20 from mpdclient2 import connect21 20 from os.path import sep, splitext 22 21 from sre import compile … … 40 39 strip_expr = compile('(%s)/' % r'|'.join(strip_paths)) 41 40 42 songinfo = {} 43 mpc = connect() 44 songinfo['state'] = state_map[mpc.status()['state']] 45 song = mpc.currentsong() 46 songinfo['song'] = \ 47 ' - '.join([song[f] for f in fields if song.has_key(f)]) \ 48 or strip_expr.sub('', splitext(song['file'])[0]).replace(sep, ' - ') 49 print format % songinfo 41 def get_status(connection): 42 songinfo = {} 43 songinfo['state'] = state_map[connection.status()['state']] 44 song = connection.currentsong() 45 songinfo['song'] = \ 46 ' - '.join([song[f] for f in fields if song.has_key(f)]) \ 47 or strip_expr.sub('', splitext(song['file'])[0]).replace(sep, ' - ') 48 return format % songinfo 49 50 if __name__ == '__main__': 51 from mpdclient2 import connect 52 print get_status(connect())
Note: See TracChangeset
for help on using the changeset viewer.