本文整理汇总了Python中track.Track.set_album方法的典型用法代码示例。如果您正苦于以下问题:Python Track.set_album方法的具体用法?Python Track.set_album怎么用?Python Track.set_album使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类track.Track
的用法示例。
在下文中一共展示了Track.set_album方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_response
# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import set_album [as 别名]
def parse_response(self, response_json):
playlist = []
# used to get rid of duplicate tracks in same album
album_set = Set()
parsed_json = json.loads(response_json)
# first check if the json can be correctly parsed
if not 'tracks' in parsed_json:
return all_tracks
json_tracks = parsed_json['tracks']
for json_track in json_tracks:
track = Track()
curTrackMap = {}
album = json_track['album']['name'].lower()
if album in album_set:
continue
album_set.add(album)
track.set_album(album)
track.set_name(json_track['name'].lower())
artists = json_track['artists']
artists_name = []
for artist in artists:
artists_name.append(artist['name'].lower())
track.set_artists(artists_name)
track.set_length(json_track['length'])
playlist.append(track)
return playlist