def retrieve_lyrics(track): # instantiate song song = Song.from_info(track['artist'], track['title']) # fetch lyrics get_lyrics(song) # read lyrics lyrics = song.lyrics.split('\n') return lyrics
def test_getlyrics_from_info(): """ Check that the main method can actually return a result with lyrics. """ song = Song(artist='Iron maiden', title='Hallowed be thy name') result = get_lyrics(song) assert 'hallowed be thy name' in result.song.lyrics.lower()
def test_getlyrics_from_song(mp3file): """ Check that the main method can find the lyrics for a song and write them as ID3 metadata. """ tag_mp3(mp3file, artist='YOB', title='Our raw heart') song = Song.from_filename(mp3file) result = get_lyrics(song) assert 'my restless ghost' in result.song.lyrics.lower()
def test_getlyrics_dont_overwrite(mp3file): """ Check that we skip a song if the mp3 file already has embedded lyrics. """ placeholder = 'Some lyrics' tag_mp3(mp3file, lyrics=placeholder) song = Song.from_filename(mp3file) CONFIG['overwrite'] = False assert get_lyrics(song) is None assert song.lyrics == placeholder
def test_getlyrics_overwrite(mp3file): """ Check that we can overwrite the lyrics of a song if it already has them. """ placeholder = 'Some lyrics' tag_mp3(mp3file, artist='Baroness', title='Eula', lyrics=placeholder) song = Song.from_filename(mp3file) CONFIG['overwrite'] = True result = get_lyrics(song) assert result.song.lyrics != placeholder assert 'forget the taste of my own tongue' in result.song.lyrics.lower()