Download mp3 from a website automatically using Python

Hi Friends,

Today I have some other simple and useful script. Couple of days back my brother asked me to download Christian songs. And I went to Google for help and got a link which has the Christian songs in form of YouTube videos. Yeah cool. But I need those as mp3 format. I just thought to use Python for this task since I am so lazy to sit for copy paste and download using fastest YouTube video download plug-in.

So, what I finally did was the below script in Python.

Code:

 

What it will do? Script will fetch the response of the website and find all the href links in the website and at the same time the href value should have “&video=”. That’s just a embedded video link. After collecting all the links I just stripped off all the chunk in the url and got only YouTube links. I have installed youtube-dl which has the ability to download and convert the YouTube videos into mp3. Just triggered the os.system() method with the youtube-dl command to get my job done. That’s it. Python made my job easy..

See you in the next post with some other script… Take care folks…

Sharing is caring!

Arockia Arulnathan

Constant Learner |Blog writer | Tech enthusiast

You may also like...

Leave a Reply