mirror of
https://github.com/powerline/powerline.git
synced 2025-07-30 01:05:42 +02:00
commit
48b575b67b
@ -1221,6 +1221,44 @@ class NowPlayingSegment(Segment):
|
|||||||
'elapsed': now_playing[3],
|
'elapsed': now_playing[3],
|
||||||
'total': now_playing[4],
|
'total': now_playing[4],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def player_rdio(self, pl):
|
||||||
|
status_delimiter = '-~`/='
|
||||||
|
ascript = '''
|
||||||
|
tell application "System Events"
|
||||||
|
set rdio_active to the count(every process whose name is "Rdio")
|
||||||
|
if rdio_active is 0 then
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end tell
|
||||||
|
tell application "Rdio"
|
||||||
|
set rdio_name to the name of the current track
|
||||||
|
set rdio_artist to the artist of the current track
|
||||||
|
set rdio_album to the album of the current track
|
||||||
|
set rdio_duration to the duration of the current track
|
||||||
|
set rdio_state to the player state
|
||||||
|
set rdio_elapsed to the player position
|
||||||
|
return rdio_name & "{0}" & rdio_artist & "{0}" & rdio_album & "{0}" & rdio_elapsed & "{0}" & rdio_duration & "{0}" & rdio_state
|
||||||
|
end tell
|
||||||
|
'''.format(status_delimiter)
|
||||||
|
now_playing = asrun(pl, ascript)
|
||||||
|
if not now_playing:
|
||||||
|
return
|
||||||
|
now_playing = now_playing.split('\n')
|
||||||
|
if len(now_playing) != 6:
|
||||||
|
return
|
||||||
|
state = self._convert_state(now_playing[5])
|
||||||
|
total = self._convert_seconds(now_playing[4])
|
||||||
|
elapsed = self._convert_seconds(float(now_playing[3]) * float(now_playing[4]) / 100)
|
||||||
|
return {
|
||||||
|
'title': now_playing[0],
|
||||||
|
'artist': now_playing[1],
|
||||||
|
'album': now_playing[2],
|
||||||
|
'elapsed': elapsed,
|
||||||
|
'total': total,
|
||||||
|
'state': state,
|
||||||
|
'state_symbol': self.STATE_SYMBOLS.get(state)
|
||||||
|
}
|
||||||
now_playing = NowPlayingSegment()
|
now_playing = NowPlayingSegment()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user