Cypher: A Quick Way to Retrieve Music Lyrics
[Cypher](https://github.com/tmthyjames/cypher) is a new `pip`-installable library that retrieves music lyrics without having to scrape the site yourself. If you want an artist's lyrics, just do the following:
Cypher is a new pip
-installable library that retrieves music lyrics without having to scrape the site yourself. If you want an artist's lyrics, just do the following:
thecypher as cy
coasts = cy.get_lyrics('coasts')
coasts[0]
That's it. You now have all of the lyrics for [Coasts](http://www.coastsband.com/) available on [LyricWiki](http://lyrics.wikia.com/). If you want to convert this to a pandas `DataFrame` then just do the following:
pandas as pd
coasts_df = pd.DataFrame(coasts)
coasts_df.head()
By default, the data is delivered with one lyric per row. The following code will convert it to one song per row:
By default, the data is delivered with one lyric per row. The following code will convert it to one song per row:
'song', 'year', 'album', 'genre', 'artist'] = [
coasts_by_song = coasts_df.sort_values( )\
.groupby( ).lyric\
.apply(' '.join)\
.reset_index(name='lyric')
coasts_by_song.head(2)
Keep in mind that these lyrics are community generated and are not perfect (or complete in some instances), but I think LyricWiki is one of the best lyrics sites there is.
I plan to convert this to a RESTful API and add more flexibility eventually. But for now, what you see is what you get. Enjoy!
To install with `pip`:
Keep in mind that these lyrics are community generated and are not perfect (or complete in some instances), but I think LyricWiki is one of the best lyrics sites there is.
I plan to convert this to a RESTful API and add more flexibility eventually. But for now, what you see is what you get. Enjoy!
To install with pip
:
pip install thecypher