def retrieve_info(self, force=True): if self.document is None or force is True: self.document = Client.get("artists/%d" % self.id) self.user = self.document["response"]["artist"]["user"] self.name = self.document["response"]["artist"]["name"] self.url = self.document["response"]["artist"]["url"] self.image_url = self.document["response"]["artist"]["image_url"] self.description = ''.join(map(Client.parse_description, self.document["response"]["artist"]["description"]["dom"]["children"])) return self
def retrieve_info(self, force=False): if self.document is None or force is True: self.document = Client.get("songs/%d" % self.id) self.primary_artist = Artist(artist_id=self.primary_artist_id) # pp.pprint(self.document) # parsed_lyrics = Song.parse_lines(self.document['response']['song']['lyrics']['dom']['children']) # print(parsed_lyrics) # self.user = self.document["response"]["artist"]["user"] # self.name = self.document["response"]["artist"]["name"] # self.url = self.document["response"]["artist"]["url"] # self.image_url = self.document["response"]["artist"]["image_url"] return self
def songs(self, page=1): songs_url = "/artists/%d/songs/?page=%d" % (self.id, page) response_songs = Client.get(songs_url)["response"]["songs"] all_songs = [] for response in response_songs: # if response["primary_artist"]["id"] == self.id: # print("Using current artist") # song_artist = self # else: # print("Artist doesn't match, retrieving info") # song_artist = Artist(response["primary_artist"]["id"]) # print(u"[{}] ({})".format(song_artist.name, song_artist.id)) song = Song(song_id=response["id"], artist_id=response["primary_artist"]["id"], title=response["title"], retrieve_info=False ) all_songs.append(song) return all_songs