From 053e37f8d8510fa52bdf43cc74ae8f6b2730aac0 Mon Sep 17 00:00:00 2001 From: Leonard Excoffier Date: Mon, 19 Feb 2024 20:41:15 -0500 Subject: [PATCH] Created the basic structure of the code. --- main.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index b4e7a54..0fb8ef4 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,28 @@ +from pytube import YouTube + +# Asks the User for a youtube video URL. +def get_video_url(): + try: + video_url = input('YouTube video URL: ') + return video_url + except Exception as e: + print(f"An error has occured: {e}") + +# Download the video. +def video_download(video_url): + try: + youtube = YouTube(video_url) + video = youtube.streams.get_highest_resolution() + video.download() + except Exception as e: + print(f"An error has occured: {e}") + def main(): try: - print() + video_url = get_video_url() + video_download(video_url) + except KeyboardInterrupt: + print("Session ended by user.") except Exception as e: print(f"{e}")