mirror of
https://github.com/vale981/clay
synced 2025-03-05 17:41:42 -05:00
Stuff
This commit is contained in:
parent
8b03f94333
commit
faa2b69e41
3 changed files with 24 additions and 8 deletions
26
clay/gp.py
26
clay/gp.py
|
@ -84,7 +84,8 @@ class Track(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
title, artist, duration, source,
|
title, artist, duration, source,
|
||||||
library_id=None, store_id=None, playlist_item_id=None
|
library_id=None, store_id=None, playlist_item_id=None,
|
||||||
|
album_name=None, album_url=None
|
||||||
):
|
):
|
||||||
self.title = title
|
self.title = title
|
||||||
self.artist = artist
|
self.artist = artist
|
||||||
|
@ -97,6 +98,9 @@ class Track(object):
|
||||||
self.store_id = store_id
|
self.store_id = store_id
|
||||||
self.playlist_item_id = playlist_item_id
|
self.playlist_item_id = playlist_item_id
|
||||||
|
|
||||||
|
self.album_name = album_name
|
||||||
|
self.album_url = album_url
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self): # pylint: disable=invalid-name
|
def id(self): # pylint: disable=invalid-name
|
||||||
"""
|
"""
|
||||||
|
@ -129,7 +133,9 @@ class Track(object):
|
||||||
artist=data['track']['artist'],
|
artist=data['track']['artist'],
|
||||||
duration=int(data['track']['durationMillis']),
|
duration=int(data['track']['durationMillis']),
|
||||||
source=source,
|
source=source,
|
||||||
store_id=data['track']['storeId'] # or data['trackId']
|
store_id=data['track']['storeId'], # or data['trackId']
|
||||||
|
album_name=data['track']['album'],
|
||||||
|
album_url=data['track']['albumArtRef'][0]['url']
|
||||||
)
|
)
|
||||||
elif source == Track.SOURCE_STATION:
|
elif source == Track.SOURCE_STATION:
|
||||||
# Station tracks have all the info in place.
|
# Station tracks have all the info in place.
|
||||||
|
@ -138,7 +144,9 @@ class Track(object):
|
||||||
artist=data['artist'],
|
artist=data['artist'],
|
||||||
duration=int(data['durationMillis']),
|
duration=int(data['durationMillis']),
|
||||||
source=source,
|
source=source,
|
||||||
store_id=data['storeId']
|
store_id=data['storeId'],
|
||||||
|
album_name=data['album'],
|
||||||
|
album_url=data['albumArtRef'][0]['url']
|
||||||
)
|
)
|
||||||
elif source == Track.SOURCE_LIBRARY:
|
elif source == Track.SOURCE_LIBRARY:
|
||||||
# Data contains all info about track
|
# Data contains all info about track
|
||||||
|
@ -150,7 +158,9 @@ class Track(object):
|
||||||
duration=int(data['durationMillis']),
|
duration=int(data['durationMillis']),
|
||||||
source=source,
|
source=source,
|
||||||
store_id=data['storeId'],
|
store_id=data['storeId'],
|
||||||
library_id=data['id']
|
library_id=data['id'],
|
||||||
|
album_name=data['album'],
|
||||||
|
album_url=data['albumArtRef'][0]['url']
|
||||||
)
|
)
|
||||||
elif source == Track.SOURCE_PLAYLIST:
|
elif source == Track.SOURCE_PLAYLIST:
|
||||||
if 'track' in data:
|
if 'track' in data:
|
||||||
|
@ -162,7 +172,9 @@ class Track(object):
|
||||||
duration=int(data['track']['durationMillis']),
|
duration=int(data['track']['durationMillis']),
|
||||||
source=source,
|
source=source,
|
||||||
store_id=data['track']['storeId'], # or data['trackId']
|
store_id=data['track']['storeId'], # or data['trackId']
|
||||||
playlist_item_id=data['id']
|
playlist_item_id=data['id'],
|
||||||
|
album_name=data['track']['album'],
|
||||||
|
album_url=data['track']['albumArtRef'][0]['url']
|
||||||
)
|
)
|
||||||
# We need to find a track in Library by trackId.
|
# We need to find a track in Library by trackId.
|
||||||
UUID(data['trackId'])
|
UUID(data['trackId'])
|
||||||
|
@ -172,7 +184,9 @@ class Track(object):
|
||||||
artist=track.artist,
|
artist=track.artist,
|
||||||
duration=track.duration,
|
duration=track.duration,
|
||||||
source=source,
|
source=source,
|
||||||
store_id=track.store_id
|
store_id=track.store_id,
|
||||||
|
album_name=track.album_name,
|
||||||
|
album_url=track.album_url
|
||||||
)
|
)
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,9 @@ class Player(object):
|
||||||
artist=track.artist,
|
artist=track.artist,
|
||||||
title=track.title,
|
title=track.title,
|
||||||
progress=self.get_play_progress_seconds(),
|
progress=self.get_play_progress_seconds(),
|
||||||
length=self.get_length_seconds()
|
length=self.get_length_seconds(),
|
||||||
|
album_name=track.album_name,
|
||||||
|
album_url=track.album_url
|
||||||
)
|
)
|
||||||
with open('/tmp/clay.json', 'w') as statefile:
|
with open('/tmp/clay.json', 'w') as statefile:
|
||||||
statefile.write(json.dumps(data, indent=4))
|
statefile.write(json.dumps(data, indent=4))
|
||||||
|
|
|
@ -106,7 +106,7 @@ class SongListItem(urwid.Pile):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.line2.set_text(
|
self.line2.set_text(
|
||||||
u' {}'.format(self.track.artist)
|
u' {} ({})'.format(self.track.artist, self.track.album_name)
|
||||||
)
|
)
|
||||||
self.line1_wrap.set_attr(title_attr)
|
self.line1_wrap.set_attr(title_attr)
|
||||||
self.line2_wrap.set_attr(artist_attr)
|
self.line2_wrap.set_attr(artist_attr)
|
||||||
|
|
Loading…
Add table
Reference in a new issue