diff --git a/.gitignore b/.gitignore index 36fd3b1..6ca34ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# OSX +# macOS *.DS_Store # API credentials @@ -21,4 +21,5 @@ # Python cache stuff *.egg-info __pycache__ -dist \ No newline at end of file +dist +README.rst \ No newline at end of file diff --git a/lyricsgenius/api.py b/lyricsgenius/api.py index 188808e..236a7ff 100644 --- a/lyricsgenius/api.py +++ b/lyricsgenius/api.py @@ -104,7 +104,7 @@ def _scrape_song_lyrics_from_url(self, URL): return lyrics.strip('\n') def _clean(self, s): - return s.translate(str.maketrans('','',punctuation)).replace('\u200b', " ").strip() + return s.translate(str.maketrans('','',punctuation)).replace('\u200b', " ").strip().lower() class Genius(_API): """User-level interface with the Genius.com API. User can search for songs (getting lyrics) and artists (getting songs)""" @@ -252,12 +252,12 @@ def save_artists(self, artists, filename="artist_lyrics", overwrite=False): # Extract each artist's lyrics in json format all_lyrics = {'artists': []} - for n, art in enumerate(artists): - if isinstance(art, Artist): + for n, artist in enumerate(artists): + if isinstance(artist, Artist): all_lyrics['artists'].append({}) - tmp_file = "./{dir}/tmp_{num}_{name}".format(dir=tmp_dir, num=n, name=art.name.replace(" ","")) + tmp_file = "./{dir}/tmp_{num}_{name}".format(dir=tmp_dir, num=n, name=artist.name.replace(" ","")) print(tmp_file) - all_lyrics['artists'][-1] = art.save_lyrics(filename=tmp_file, overwrite=True) + all_lyrics['artists'][-1] = artist.save_lyrics(filename=tmp_file, overwrite=True) else: warn("Item #{} was not of type Artist. Skipping.".format(n)) diff --git a/lyricsgenius/artist.py b/lyricsgenius/artist.py index 741a357..c6f256f 100644 --- a/lyricsgenius/artist.py +++ b/lyricsgenius/artist.py @@ -115,7 +115,7 @@ def songInArtist(new_song): lyrics_to_write['songs'][-1]['lyrics'] = song.lyrics lyrics_to_write['songs'][-1]['image'] = song.song_art_image_url lyrics_to_write['songs'][-1]['artist'] = self.name - lyrics_to_write['songs'][-1]['json'] = song._body + lyrics_to_write['songs'][-1]['raw'] = song._body else: print("SKIPPING \"{}\" -- already found in artist collection.".format(song.title)) else: diff --git a/setup.py b/setup.py index 0665667..641c7cf 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='lyricsgenius', - version='0.4', + version='0.4.1', description='Download lyrics and metadata from Genius.com', long_description=README, classifiers=[ diff --git a/tests/test_genius.py b/tests/test_genius.py index adb4361..9111d52 100644 --- a/tests/test_genius.py +++ b/tests/test_genius.py @@ -89,7 +89,7 @@ class TestSong(unittest.TestCase): def setUpClass(cls): print("\n---------------------\nSetting up Song tests...\n") cls.artist_name = 'Andy Shauf' - cls.song_title = 'Begin Again' + cls.song_title = 'begin again' # Lowercase is intentional cls.album = 'The Party' cls.year = '2016-05-20' cls.song = api.search_song(cls.song_title,cls.artist_name) @@ -100,7 +100,7 @@ def test_song(self): def test_title(self): msg = "The returned song title does not match the title of the requested song." - self.assertEqual(self.song.title, self.song_title, msg) + self.assertEqual(api._clean(self.song.title), api._clean(self.song_title), msg) def test_artist(self): msg = "The returned artist name does not match the artist of the requested song."