How to Download only Audio files from YouTube | Python Script
How to Download only Audio files from YouTube | Python Script
YouTube is the world's largest video sharing platform for 14 years. People from all over the world enjoy watching videos on YouTube. People not only watch the videos on YouTube, but they also share their videos on YouTube as similar in sharing the photos or status on Facebook or Instagram.
These are social media not mean for sharing entertaining contents. YouTube is the pure platform where we enjoy watching funny videos, action movies, blogs, interviews, documentary, tutorial, music videos, movies and many more.
YouTube already has features of downloading the videos, but these last for only 30 days in your phone storage and the downloaded videos is not allowed to share with anyone.
Also, you can't download the audio version of any music videos or movies on YouTube. In mobile devices, you can use third-party Applications such as Vidmate, for downloading the YouTube videos and audio files. But downloading the videos and audio files in PC is somehow different.
So, here in this post, we are describing one method on How to Download only audio files from YouTube with just 10 lines of Python Scripts.
Note: In order to implement this method,
- your computer must be Linux
or
- you must have installed Python in your windows PC
or
- you can install Vs-code(text editor) to run Python scripts.
After installing Vs-code in Windows:
Step 1: Open it.
Step 2: Install extension called Python and Code Runner. (Google it on how to install the extension in Vs-code)
Step 3: After you install these extensions. Copy and paste the code in your text editor. Save your file as "Download_audio.py".
from __future__ import unicode_literals
import youtube_dl
ydl_opts = {
'format':'bestaudio/best',
'postprocessors':[{
'key':'FFmpegExtractAudio',
'preferredcodec':'wav',
'preferredquality':'192'
}],
'postprocessor_args':[
'-ar','16000'
],
'prefer_ffmpeg':True,
'keepvideo':True
}
link = input("Please Enter Video link")
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([link])
Step 4: When you run your program, it will ask you to install youtube_dl, simply install it with a command "pip install youtube_dl". if it asks for more files to install, simply install it and run.
Step 5: It will ask you to paste the URL link of videos, whose audio file you wish to download.
Step 6: Your download begins.
Step 7: that's it, you are done.
Whenever you want to download audio files from YouTube simply run this program again and again. If you have any confusion just comment down.
This is the method of downloading audio files from YouTube, without using third-party Application. Hope these steps on How to download audio files from YouTube works perfectly in your PC.
Post a Comment