Last active
December 19, 2022 03:15
-
-
Save mateusjunges/eb91b7f18e42fd7474504934520fb3c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pytube import YouTube | |
import os | |
def Download(link, output): | |
print("Downloading...\n\n") | |
youtubeObject = YouTube(link) | |
video = youtubeObject.streams.get_highest_resolution() | |
try: | |
video.download(output) | |
except Exception as e: | |
print("There was an error while downloading your YT video\n") | |
print(str(e)) | |
exit() | |
print("Download completed!") | |
video_url = input("Please, paste the URL to the video you want to download:\n") | |
current_user = os.getlogin() | |
defaultPath = "/home/" + current_user + "/Videos/" | |
outputPath = str(input("Where do you want to save this video? (" + defaultPath + ")\n") or defaultPath) | |
if len(video_url) > 0: | |
Download(video_url, outputPath) | |
else: | |
print("No URL provided.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment