예제 #1
0
파일: Artist.py 프로젝트: pferate/genius.py
 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
예제 #2
0
파일: Song.py 프로젝트: pferate/genius.py
 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
예제 #3
0
파일: Artist.py 프로젝트: pferate/genius.py
    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