Introduction
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.
Note
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:
Code
python lyrister.py
You have the option of giving command line arguments as the parameters. The following format is to be followed:
Code
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.
Example 1
Here we download the song Carnival by Natalie Merchant. Since we have not provided the song name with space, there is no problem.
Code
python lyrister.py carnival /home/psychocoder/ carnivallyric
Example 2
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.
Code
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.