Skip to content

Commit

Permalink
Update now_playing methods to use common formatting methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokaltog committed Feb 1, 2013
1 parent e8ebb07 commit def7a1e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions powerline/segments/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ def player_mpd(self, host='localhost', port=6600):
'album': now_playing.get('album'),
'artist': now_playing.get('artist'),
'title': now_playing.get('title'),
'elapsed': '{0:.0f}:{1:02.0f}'.format(*divmod(float(status.get('elapsed', 0)), 60)),
'total': '{0:.0f}:{1:02.0f}'.format(*divmod(float(now_playing['time']), 60)),
'elapsed': self._convert_seconds(now_playing.get('elapsed', 0)),
'total': self._convert_seconds(now_playing.get('time', 0)),
}
except ImportError:
now_playing = self._run_cmd(['mpc', 'current', '-f', '%album%\n%artist%\n%title%\n%time%', '-h', str(host), '-p', str(port)])
Expand All @@ -349,17 +349,17 @@ def player_spotify(self):
player = bus.get_object('com.spotify.qt', '/')
iface = dbus.Interface(player, DBUS_IFACE_PROPERTIES)
info = iface.Get(DBUS_IFACE_PLAYER, 'Metadata')
state = iface.Get(DBUS_IFACE_PLAYER, 'PlaybackStatus')
status = iface.Get(DBUS_IFACE_PLAYER, 'PlaybackStatus')
except dbus.exceptions.DBusException:
return
state = {'Playing': 'play', 'Paused': 'pause'}.get(state, None)
state = self._convert_state(status)
return {
'state': state,
'state_symbol': self.STATE_SYMBOLS.get(state),
'album': str(info['xesam:album']),
'artist': str(info['xesam:artist'][0]),
'title': str(info['xesam:title']),
'total': '{0:.0f}:{1:02.0f}'.format(*divmod(float(info['mpris:length'] / 1e6), 60)),
'album': info['xesam:album'],
'artist': info['xesam:artist'][0],
'title': info['xesam:title'],
'total': self._convert_seconds(info['mpris:length'] / 1e6),
}

def player_rhythmbox(self):
Expand Down

0 comments on commit def7a1e

Please sign in to comment.