32
loading...
This website collects cookies to deliver better user experience
Python 3.7
PyTube extension (achieved by pip3 install pytube
)
The CLDownloader gist (not needed if you want to explore around the code)
pip3 install pytube
Traceback (most recent call last):
File "downloader.py", line 1, in <module>
from pytube import YouTube
ModuleNotFoundError: No module named 'pytube'
from pytube import YouTube
download.py
. In the contents of download.py
, import the PyTube we have did before. We will start with this loop.while True:
link = input('Link: ')
yt = YouTube(link)
print('Title: ', yt.title)
print('Views: ', yt.views)
print('Length: ', yt.length)
print('Rating: ', yt.rating)
ys = yt.streams.get_highest_resolution()
ys.download()
download()
only method, it will save on anywhere it wants (idk where it is basically). But if you want to specify a custom directory, place the dir in the brackets of the download. I am using the OSes default profile dir, so we have to enter it as this.ys.download(os.path.join(os.path.expandvars("%userprofile%"),"CLDownloader"))
retry = input('Do you want to download more videos?')
if retry == 'y':
continue
else:
print('See you next time!!!!!!!')
time.sleep(2)
quit()
continue
syntax here is used to loop again from the beginning of the while
command. Our full program should look like this.from pytube import YouTube
import time
import os
while True:
link = input('Link: ')
yt = YouTube(link)
print('Title: ', yt.title)
print('Views: ', yt.views)
print('Length: ', yt.length)
print('Rating: ', yt.rating)
ys = yt.streams.get_highest_resolution()
ys.download(os.path.join(os.path.expandvars("%userprofile%"),"CLDownloader"))
retry = input('Do you want to download more videos?')
if retry == 'y':
continue
else:
print('See you next time!!!!!!!')
time.sleep(2)
quit()