def add_songs(self, artist_list): """ Method to find and add new songs to the songs table. """ "Terms that identify songs that aren't really songs" conn = self.conn conn.text_factory = str c = conn.cursor() if artist_list is None: return "You must provide a list of artists for whom to find songs." else: for artist in artist_list: print("Finding songs for " + artist) all_songs_by_artist = pygenius_songs.findAllSongs(artist) already_scraped = list() for song in all_songs_by_artist: url = song[0] title = song[1] print(title) c.execute("SELECT count(*) FROM songs WHERE title = (?) AND artist = (?)", (title, artist)) check_in_db = c.fetchall() if check_in_db[0][0] == 0: if title not in already_scraped: if not [i for i, x in enumerate(self.bad_terms) if x in title]: already_scraped.append(title) c.execute('INSERT INTO songs(title, artist, url) values (?,?,?)', (title, artist, url)) conn.commit()
note = "No annotation" print lyric + ': \n' + note + '\n' ###grabbing album metadata### metadata = artists.getAlbumData('kanye west', 'yeezus') l = len(metadata) for i in range(0, l): print metadata[i] ###grabbing artist bio### bio = artists.getArtistBio('ol dirty bastard') print bio ###grabbing list of popular songs### songList = artists.getPopularSongs('lil kim') for song in songList: print song ###listing all songs by an artist### tracks = songs.findAllSongs('2 chainz', 'titles') for track in tracks: print track
note = "No annotation" print lyric + ': \n' + note + '\n' ###grabbing album metadata### metadata = artists.getAlbumData('kanye west', 'yeezus') l = len(metadata) for i in range(0, l): print metadata[i] ###grabbing artist bio### bio = artists.getArtistBio('ol dirty bastard') print bio ###grabbing list of popular songs### songs = artists.getPopularSongs('lil kim') for song in songs: print song ###listing all songs by an artist### songs = songs.findAllSongs('Kid Cudi') for song in songs: print song
if link != "Not annotated": note = songs.searchAnnotations(link) print lyric + ': ' + note else: note = "No annotation" print lyric + ': \n' + note + '\n' ###grabbing album metadata### metadata = artists.getAlbumData('kanye west', 'yeezus') l = len(metadata) for i in range(0, l): print metadata[i] ###grabbing artist bio### bio = artists.getArtistBio('ol dirty bastard') print bio ###grabbing list of popular songs### songList = artists.getPopularSongs('lil kim') for song in songList: print song ###listing all songs by an artist### tracks = songs.findAllSongs('2 chainz', 'titles') for track in tracks: print track