Created the basic structure of the code.

This commit is contained in:
2024-02-19 20:41:15 -05:00
parent 9ef1e41d28
commit 053e37f8d8

24
main.py
View File

@@ -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}")