Note: Code is very poor, but functional xD. Don't blame me for anything, I was bored, thus this puked code was produced. Nonetheless, it WORKS! If you can improve the code, don't hesitate to open a pull request.
With a basic usage of regex and some youtube-to-mp3 magic, this script can download any song for you (of course, no magic, it's YouTube).
Note: For popular songs, just the title of song will work. Add artist name to get more precise results for songs that contain common words.
There are two ways to use this script:
song-downloader.pyand then enter your query in the following prompt.
- Or if you are lazy like me, use command line arguments:
song-downloader.py name of any song no need to worry about dashes or spacesExample:
song-downloader.py wherever you go bryan adams
Here's a gif (cause I CAN!)
Sometimes, the completed download may seem corrupted (or be of very small size ~ some kb). This is because our script requests file instantly, whereas the server might still be converting it (I have added a time delay, still it doesn't work sometimes. FACEPALM).
In such cases, just re-run the script, it will overwrite the previous failed download..
Also, if the naming of the file is incorrect, please correct it yourself xD. Just kidding. I have this on my feature list (maybe available on next update).
To be clear, this is just for educational purpose only. The end user is solely responsible for his actions. (Who am I kidding :P). Also, YouTube compresses the audio to 128kbps (=shitty quality audio, for me xD)
To be added features:
- List out all possible videos, in case if two songs are similarly named.
- Add a progress bar while downloading.
- Custom output directory.
- System-wide installation with pip, maybe :P.