Python YouTube Downloader

python -m pip install git+https://github.com/nficano/pytube
from pytube.cli import on_progress
from pytube import YouTube
from pytube import Playlist
loopstatus = True
while loopstatus:
download_type = input("Download Type Single Or Playlist : ")
video_url = input("Please Enter YouTube URL : ")
Format=input('Audio Or Video :')
try:
if download_type == 'Playlist':
p = Playlist(video_url)
for url in p.video_urls:
video = YouTube(url,on_progress_callback=on_progress)
if Format=='Audio':
Filter = video.streams.filter(only_audio=True).first()
if Format=='Video':
Filter = video.streams.filter(file_extension='mp4').get_highest_resolution()
print('Now downloading:',Filter.title)
sizer=round(Filter.filesize/1000000)
print('Size:',sizer,'MB')
Filter.download()
if download_type == 'Single':
yt = YouTube(video_url,on_progress_callback=on_progress)
if Format=='Audio':
Filter = yt.streams.filter(only_audio=True).first()
if Format=='Video':
Filter = yt.streams.filter(file_extension='mp4').get_highest_resolution()

print('Now downloading:',Filter.title)
sizer=round(Filter.filesize/1000000)
print('Size:',sizer,'MB')
Filter.download()
except EOFError as err:
print(err)
else:
print("Download Complete")
next_video = input("Convert another URL (Y / N): ")
if next_video == 'N':
loopstatus = False
python filename.py

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store