def artist_from_genius_json(self, json): return artist.Artist(name=json['name'], alternate_names=json['alternate_names'], genius_id=json['id'], genius_url=json['url'], genius_image_url=json['image_url'], genius_follower_count=json['followers_count'])
def get_all_artists(): """Displays all artists currently in db""" con = sqlite3.connect(db_path) artists_cursor = con.execute('SELECT * FROM artists') artists = [artist.Artist(*row) for row in artists_cursor.fetchall()] con.close() return artists
def read_items(self, buckets=None, results=15, start=0, item_ids=None): """ Returns data from the catalog; also expanded for the requested buckets Args: Kwargs: buckets (list): A list of strings specifying which buckets to retrieve results (int): An integer number of results to return start (int): An integer starting value for the result set Returns: A list of objects in the catalog; list contains additional attributes 'start' and 'total' Example: >>> c <catalog - my_songs> >>> c.read_items(results=1) [<song - Harmonice Mundi II>] >>> """ kwargs = {} kwargs['bucket'] = buckets or [] kwargs['item_id'] = item_ids or [] response = self.get_attribute("read", results=results, start=start, **kwargs) rval = ResultList([]) if item_ids: rval.start = 0 rval.total = len(response['catalog']['items']) else: rval.start = response['catalog']['start'] rval.total = response['catalog']['total'] for item in response['catalog']['items']: new_item = None # song items if 'song_id' in item: item['id'] = item.pop('song_id') item['title'] = item.pop('song_name') request = item['request'] new_item = song.Song(**util.fix(item)) new_item.request = request # artist item elif 'artist_id' in item: item['id'] = item.pop('artist_id') item['name'] = item.pop('artist_name') request = item['request'] new_item = artist.Artist(**util.fix(item)) new_item.request = request # unresolved item else: new_item = item rval.append(new_item) return rval
def as_artist(self): #Increment reference count so it's not stolen from us artist_struct = self.__link_interface.as_artist(self.__link_struct) if artist_struct is not None: ai = _artist.ArtistInterface() ai.add_ref(artist_struct) return artist.Artist(artist_struct)
def artist(self, index): artist_struct = self.__track_interface.artist(self.__track_struct, index) if artist_struct is not None: ai = _artist.ArtistInterface() ai.add_ref(artist_struct) return artist.Artist(artist_struct)
for x in self.songs: songObj, duration = self.songs[x] if songObj.songName == song: counter += 1 if counter > 0: return True else: return False def isContainsArtist(self, artist): if not artist in self.artist: return False else: return True if __name__ == '__main__': abc = songClass.Song("abc", "someArtist", "someAlbum") xyz = songClass.Song("xyz", "someArtist", "someAlbum") someArtist = artistClass.Artist("Some Artist") someAnotherArtist = artistClass.Artist("Some Another Artist") myAlbum = Album("New Album", 2018) myAlbum.addArtist(someArtist) myAlbum.addArtist(someAnotherArtist) myAlbum.addSong(abc, 300) myAlbum.addSong(xyz, 250) myAlbum.printAlbum()
def add_artist(self, name): new_artist = artist.Artist(name) self.artists[name] = new_artist return new_artist
def getAlbum(name): for x in allAlbums: if x.albumName == name: return x if __name__ == "__main__": with open("listOfSongs.txt", "r") as listOfSongs: songObj = songClass.Song() artistObj = artistClass.Artist() albumObj = albumClass.Album() for record in listOfSongs: albumName, publishYr, artistName, songName, duration = tuple(record.strip("\n").split("\t")) # Create / Retrieve Song if songObj.songName != songName: if not songName in allSongs: songObj = songClass.Song(songName, artistName, albumName) allSongs.append(songObj) else: songObj = getSong(songName) # Create / Retrieve Artist
self.P = P self.workf = WorkFactory(self.P) def run(self): while True: wid,path = self.recv() work = self.workf.get_work(wid) work.download(self.P, path) work.record(self.db) if __name__ =='__main__': import artist import time P = User('','').getSession() at = artist.Artist(P, 12949983) at.crawl() sh = shelve.open('pixivDB') r = Runner(P, sh) start = time.perf_counter() r.start(8) ctype = ('illust','manga','ugoira') for ty in ctype: for wid in at.content[ty]: r.send((wid,'C:/Users/JX/Desktop/Pixiv/pp/aa/'+ty+'/')) r.close() r.join() end = time.perf_counter()