def raw_artist_to_artist(self, artist): if artist is None: return None return Artist( name=artist.get("name") or UNKNOWN_ARTIST, uri=uri.get_artist_uri(artist.get("id")), )
def raw_song_to_track(self, song): if song is None: return None return Track( name=song.get("title") or UNKNOWN_SONG, uri=uri.get_song_uri(song.get("id")), bitrate=song.get("bitRate"), track_no=int(song.get("track")) if song.get("track") else None, date=str(song.get("year")) or "none", genre=song.get("genre"), length=int(song.get("duration")) * 1000 if song.get("duration") else None, disc_no=int(song.get("discNumber")) if song.get("discNumber") else None, artists=[ Artist( name=song.get("artist"), uri=uri.get_artist_uri(song.get("artistId")), ) ], album=Album( name=song.get("album"), uri=uri.get_album_uri(song.get("albumId")), ), )
def raw_album_to_album(self, album): if album is None: return None return Album(name=album.get('title') or album.get('name') or UNKNOWN_ALBUM, uri=uri.get_album_uri(album.get('id')), artists=[ Artist(name=album.get('artist'), uri=uri.get_artist_uri(album.get('artistId'))) ])
def raw_album_to_album(self, album): if album is None: return None return Album( name=album.get("title") or album.get("name") or UNKNOWN_ALBUM, num_tracks=album.get("songCount"), uri=uri.get_album_uri(album.get("id")), artists=[ Artist( name=album.get("artist"), uri=uri.get_artist_uri(album.get("artistId")), ) ], )
def raw_song_to_track(self, song): if song is None: return None return Track( name=song.get('title') or UNKNOWN_SONG, uri=uri.get_song_uri(song.get('id')), bitrate=song.get('bitRate'), track_no=int(song.get('track')) if song.get('track') else None, date=str(song.get('year')) or 'none', genre=song.get('genre'), length=int(song.get('duration')) * 1000 if song.get('duration') else None, disc_no=int(song.get('discNumber')) if song.get('discNumber') else None, artists=[Artist( name=song.get('artist'), uri=uri.get_artist_uri(song.get('artistId')))], album=Album( name=song.get('album'), uri=uri.get_album_uri(song.get('albumId'))))
def raw_artist_to_artist(self, artist): if artist is None: return None return Artist(name=artist.get('name') or UNKNOWN_ARTIST, uri=uri.get_artist_uri(artist.get('id')))