def _parse_track(data, albumarg=None): artist = Artist() if 'artists' in data: artist = _parse_artist(data['artists'][0]) elif albumarg and albumarg.artist: artist = albumarg.artist available = True duration = 0 if 'duration_ms' in data: duration = str(int(data['duration_ms']) // 1000) kwargs = { 'id': data['id'], 'name': data['name'], 'duration': duration, 'track_num': data['track_number'], 'disc_num': data['disc_number'], 'artist': artist, 'available': available } if albumarg: kwargs['album'] = albumarg elif 'album' in data: kwargs['album'] = _parse_album(data['album']) return Track(**kwargs)
def _parse_track(json_obj, albumarg=None): if 'performer' in json_obj: artist = _parse_artist(json_obj['performer']) elif 'artist' in json_obj: artist = _parse_artist(json_obj['artist']) elif 'album' in json_obj: album = _parse_album(json_obj['album']) if album.artist: artist = album.artist elif albumarg: artist = albumarg.artist else: artist = Artist() available = json_obj['streamable'] if 'streamable' in json_obj else false #artists = _parse_artists(json_obj['artists']) kwargs = { 'id': json_obj['id'], 'name': json_obj['title'], 'duration': json_obj['duration'], 'track_num': json_obj['track_number'], 'disc_num': json_obj['media_number'], 'artist': artist, 'available': available #'artists': artists, } if 'album' in json_obj: kwargs['album'] = _parse_album(json_obj['album'], artist) elif albumarg: kwargs['album'] = albumarg return Track(**kwargs)
def _parse_track(json_obj, albumarg=None): artist = Artist() if 'performer' in json_obj: artist = _parse_artist(json_obj['performer']) elif 'artist' in json_obj: artist = _parse_artist(json_obj['artist']) elif albumarg and albumarg.artist: artist = albumarg.artist album = None if 'album' in json_obj: album = _parse_album(json_obj['album'], artist) else: album = albumarg available = json_obj['streamable'] if 'streamable' in json_obj else false #if not available: #uplog("Track no not streamable: %s " % json_obj['title']) #artists = _parse_artists(json_obj['artists']) kwargs = { 'id': json_obj['id'], 'name': json_obj['title'], 'duration': json_obj['duration'], 'track_num': json_obj['track_number'], 'disc_num': json_obj['media_number'], 'artist': artist, 'available': available #'artists': artists, } if album: kwargs['album'] = album return Track(**kwargs)
def _parse_track(data, album=None): artist_name = entryOrUnknown(data, 'artist') albartist_name = entryOrUnknown(data, 'albartistAlbum', None) artistid = data["artistId"][0] if "artistId" in data else None artist = Artist(id=artistid, name=artist_name) albartist = Artist(id=artistid, name=albartist_name) if \ albartist_name is not None else artist albid = entryOrUnknown(data, 'albumId', None) if album is None: #alb_artist = data['albumArtist'] if 'albumArtist' in data else "" alb_art = data['albumArtRef'][0]["url"] if 'albumArtRef' in data else "" alb_tt = entryOrUnknown(data, 'album') album = Album(id=albid, name=alb_tt, image=alb_art, artist=artist) kwargs = { 'id': data['id'] if 'id' in data else data['nid'], 'name': data['title'], 'duration': int(data['durationMillis']) / 1000, 'track_num': data['trackNumber'], 'disc_num': data['discNumber'], 'artist': artist, 'album': album, #'artists': artists, } if 'genre' in data: kwargs['genre'] = data['genre'] return Track(**kwargs)
def _parse_track(json_obj, albumarg=None): artist = Artist(name=json_obj["artist"].encode("utf-8")) #if 'performer' in json_obj: # artist = _parse_artist(json_obj['performer']) #elif 'artist' in json_obj: # artist = json_obj["artist"] #_parse_artist(json_obj['artist']) #elif albumarg and albumarg.artist: # artist = albumarg.artist album = None ##if 'album' in json_obj: ##album = _parse_album(json_obj['album'].encode(), artist) ##else: album = albumarg #available = json_obj['streamable'] if 'streamable' in json_obj else false #if not available: #uplog("Track no not streamable: %s " % json_obj['title']) #artists = _parse_artists(json_obj['artists']) kwargs = { 'id': json_obj['playlistAdd'], 'name': json_obj['title'].encode("utf-8"), 'duration': json_obj['playtime'], #'disc_num': json_obj['media_number'], 'artist': artist, 'available': True #'artists': artists, } if "trackNumber" in kwargs: kwargs["track_num"] = json_obj["trackNumber"] else: kwargs["track_num"] = 0 if album: kwargs['album'] = album track = Track(**kwargs) return track