Create Youtube Video Downloader Using Python

Create Youtube Video Downloader Using Python:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) In order to create a Youtube Video Downloader in Python we need to install the package pytube.

(2) Open the PyCharm code editor and type import pytube. It displays an error and a red bulb appears below it. Click on the red bulb and select the option Install package pytube as shown below.

install package pytube

(3) Now pytube package is installed. After that remove the line import pytube and write from pytube import YouTube.

(4) In order to get a youtube video title and thumbnail URL write the following code as shown below.

you tube video title and thumbnail url in python

Source Code: Do proper Code Indentation otherwise, the Source Code does not work and gives an error.

from pytube import YouTube

link=”https://youtu.be/Gp9MD5l4gvw”
you_tube=YouTube(link)

print(you_tube.title)
print(you_tube.thumbnail_url)

(5) For youtube video download write the following code as shown below. When you run the code, it displays in the output window all resolutions format of the video and even the audio formats of the video. You have to enter the number which is shown in the output window, and your video is getting downloaded in that resolution and even in audio format.

youtube video downloader python

Source Code: Do proper Code Indentation otherwise, the Source Code does not work and gives an error.

from pytube import YouTube

link="https://youtu.be/Gp9MD5l4gvw"
you_tube=YouTube(link)

video_stream=you_tube.streams.all()
vid=list(enumerate(video_stream))

for x in vid:
    print(x)

strm=int(input("enter:  "))
video_stream[strm].download()
print("Video Download Successfully.....")

(6) Now the video is saved in the path where you have created the Python Project as shown below.

python youtube video downloader

(7) For youtube video playlist download write the following code as shown below.

youtube playlist download python

Source Code: Do proper Code Indentation otherwise, the Source Code does not work and gives an error.

(8) Now the playlist videos are saved in the path where you have created the Python Project as shown below.

playlist videos python download

(9) For downloading playlist videos in high resolution and also creating a specified path where you have to download them, write the following code as shown below.

playlist high resolution python code

Source Code: Do proper Code Indentation otherwise, the Source Code does not work and gives an error.

from pytube import Playlist

play_list_url=input("Enter YouTube Playlist URL:--")

yt_playlist=Playlist(play_list_url)

for video in yt_playlist.videos:
    video.streams.get_highest_resolution().download("E:\playlist")
    print("Video Downloaded ", video.title)

print("\nAll Videos are Downloaded Successfully")

(10) Now the playlist videos are saved in the E drive which you have specified in the above code.

playlist video downloaded in specified path python

Tutorial MySQL
Tutorial Python
Linux- Features, and Benefits
Careers in Information Technology (IT)
Information Security in E-Commerce
FTP (File Transfer Protocol)
Email (Electronic Mail)
Internet and Its Uses
Malicious Software (Malware)
Python (programming language)– Wikipedia

Comments (No)

Leave a Reply