Today, I will share a little snippet I wrote to get scrap or download lyrics of your favorite songs and save on your harddrive as .txt files.
I have used Python 2.7.4 for this and have used the BeautifulSoup python package for web requests.
You can get the code at https://github.com/PsychoCoderHC/Lyrister.
I hope I have taken care of most things that may cause you problems.
In order to successfully run and execute this app, you must have installed BeautifulSoup package, else it won't run. Please read the README on github repository about how to install them.
How to Use?
On the terminal, run the following and follow the instructions that follow:
You have the option of giving command line arguments as the parameters. The following format is to be followed:
python lyrister.py <name-of-song> <path-of-directory> <filename>
It takes three parameters. The first parameter is the name of the song for which you want to download the lyrics. Please note that if you intend to write the song name with spaces, then use double quotes and your directory path must end with separator.
Here we download the song Carnival by Natalie Merchant. Since we have not provided the song name with space, there is no problem.
python lyrister.py carnival /home/psychocoder/ carnivallyric
Here we download the song Carnival Of Rust by "Poets Of Fall". Since we have not provided the song name with space, there is no problem.
python lyrister.py "carnival of rust" /home/psychocoder/ CarnivalOfRust
If a file with the same name exists in the directory, then it won't let you save the song and will ask you to try another name to download the lyric.
If you want to save the file in some directory which doesn't have write permission, then you won't be able to save the lyrics.
These checking have been done already and I hope the rest you can understand by yourself. I have given a good description for every step in the code itself and also how to resolve the errors. I hope you enjoy.