from attr import attrib, attrs @attrs class Album: album_type = attrib() artists = attrib() available_markets = attrib() external_urls = attrib() href = attrib() id = attrib() # is_playable = attrib() images = attrib() name = attrib() release_date = attrib() release_date_precision = attrib() total_tracks = attrib() type = attrib() uri = attrib() @attrs class Albums: items = attrib() href = attrib(type=str) limit = attrib(type=int) next = attrib(type=str) # url offset = attrib(type=int) previous = attrib() total = attrib(type=int) @attrs class Artists: items = attrib() limit = attrib() next = attrib() offset = attrib() previous = attrib() total = attrib() href = attrib() @attrs class Track: href = attrib() # url id = attrib(type=str) is_local = attrib(type=bool) name = attrib(type=str) popularity = attrib(type=int) preview_url = attrib() track_number = attrib(type=int) type = attrib() uri = attrib() external_urls = attrib() external_ids = attrib() explicit = attrib() duration_ms = attrib() disc_number = attrib() available_markets = attrib() artists = attrib() album = attrib(converter=lambda kv: Album(**kv)) @attrs class Tracks: items = attrib(converter=lambda items: [Track(**item) for item in items]) # list of Track limit = attrib() next = attrib() offset = attrib() previous = attrib() total = attrib() href = attrib() @attrs() class PortalSearchResponse: albums = attrib(default=None, converter=lambda kv: Albums(**kv) if kv else kv) artists = attrib(default=None, converter=lambda kv: Artists(**kv) if kv else kv) tracks = attrib(default=None, converter=lambda kv: Tracks(**kv) if kv else kv) @attrs class User: name = attrib() countryCode = attrib() imageUrl = attrib() uri = attrib(default=None) subscribers = attrib(default=None) curatorId = attrib(default=None) @attrs class Playlist: name = attrib() image = attrib() countryCode = attrib() accountName = attrib() subscribers = attrib(default=None) uri = attrib(default=None) playlistId = attrib(default=None) @attrs() class PortalPlaylistsSearch: playlists = attrib(converter=lambda items: [Playlist(**item) for item in items]) users = attrib(converter=lambda items: [User(**item) for item in items])