mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
Update now_playing methods to use common formatting methods
This commit is contained in:
parent
e8ebb07662
commit
def7a1e82e
@ -321,8 +321,8 @@ class NowPlayingSegment(object):
|
|||||||
'album': now_playing.get('album'),
|
'album': now_playing.get('album'),
|
||||||
'artist': now_playing.get('artist'),
|
'artist': now_playing.get('artist'),
|
||||||
'title': now_playing.get('title'),
|
'title': now_playing.get('title'),
|
||||||
'elapsed': '{0:.0f}:{1:02.0f}'.format(*divmod(float(status.get('elapsed', 0)), 60)),
|
'elapsed': self._convert_seconds(now_playing.get('elapsed', 0)),
|
||||||
'total': '{0:.0f}:{1:02.0f}'.format(*divmod(float(now_playing['time']), 60)),
|
'total': self._convert_seconds(now_playing.get('time', 0)),
|
||||||
}
|
}
|
||||||
except ImportError:
|
except ImportError:
|
||||||
now_playing = self._run_cmd(['mpc', 'current', '-f', '%album%\n%artist%\n%title%\n%time%', '-h', str(host), '-p', str(port)])
|
now_playing = self._run_cmd(['mpc', 'current', '-f', '%album%\n%artist%\n%title%\n%time%', '-h', str(host), '-p', str(port)])
|
||||||
@ -349,17 +349,17 @@ class NowPlayingSegment(object):
|
|||||||
player = bus.get_object('com.spotify.qt', '/')
|
player = bus.get_object('com.spotify.qt', '/')
|
||||||
iface = dbus.Interface(player, DBUS_IFACE_PROPERTIES)
|
iface = dbus.Interface(player, DBUS_IFACE_PROPERTIES)
|
||||||
info = iface.Get(DBUS_IFACE_PLAYER, 'Metadata')
|
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:
|
except dbus.exceptions.DBusException:
|
||||||
return
|
return
|
||||||
state = {'Playing': 'play', 'Paused': 'pause'}.get(state, None)
|
state = self._convert_state(status)
|
||||||
return {
|
return {
|
||||||
'state': state,
|
'state': state,
|
||||||
'state_symbol': self.STATE_SYMBOLS.get(state),
|
'state_symbol': self.STATE_SYMBOLS.get(state),
|
||||||
'album': str(info['xesam:album']),
|
'album': info['xesam:album'],
|
||||||
'artist': str(info['xesam:artist'][0]),
|
'artist': info['xesam:artist'][0],
|
||||||
'title': str(info['xesam:title']),
|
'title': info['xesam:title'],
|
||||||
'total': '{0:.0f}:{1:02.0f}'.format(*divmod(float(info['mpris:length'] / 1e6), 60)),
|
'total': self._convert_seconds(info['mpris:length'] / 1e6),
|
||||||
}
|
}
|
||||||
|
|
||||||
def player_rhythmbox(self):
|
def player_rhythmbox(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user