repl.it
@Kognise/

YouTube Downloader

Python

No description

fork
loading
Files
  • main.py
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from pytube import *

path = input("Where would you like you videos to be saved? ")

while True:
  url = input("Enter the url of the video to download or enter \'exit\' to exit: ")
  if (url == "exit"):
    exit()
  else:
    try: 
      vid = YouTube(url)
      stream = vid.streams.filter(file_extension="mp4").first()
      try:
        stream.download(path)
      except:
        print("An error has occurred. There are two possibilities. Either your path is invalid, in which case you may restart the program and re-enter your path, or the video doesn't come in the mp4 format. If the latter is the case, you're basically fucked.")
    except:
      print("An error has occured. Please verify the validity of the YouTube URL and the path you have entered")
      continue