Skip to content

Instantly share code, notes, and snippets.

Created September 16, 2019 18:04
What would you like to do?
For downloading one or multiple youtube video's
Author : Theo van der Sluijs
License: MIT
Version: 1.0
V-Date: 16 sept 2019
create a folder called : youtube
install pytube: pip install pytube
run: python downtube.puy
just add one or multiple youtube id's
(multiple comma separated)
Have fun!
from pytube import YouTube
import sys
import os
class DownTube:
def __init__(self, folder: str = None):
self.folder = folder
def youtube_list(self, youtube_ids):
return youtube_ids.split(',')
def what_folder(self):
if self.folder is not None:
cp = os.getcwd()
folder = os.path.join(cp, self.folder)
os.makedirs(folder, exist_ok=True)
return True
while True:
self.folder = input("Where should I download : ")
if self.folder is not None and self.folder != "":
def download(self):
yes_now = ['y', 'n']
while True:
you_tube = input("Give me the youtube id('s)): ")
if you_tube is not None and you_tube != "":
list = self.youtube_list(you_tube)
for l in list:
more = ""
while more not in yes_now:
more = input("Download another one [y/n] ")
if more == 'n':
print('all done')
def do_download(self, id: str = None):
yt = YouTube(f"{id}")
yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(self.folder)
except Exception as e:
if __name__ == '__main__':
dt = DownTube('youtube')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment