Created the basic structure of the code.
This commit is contained in:
24
main.py
24
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():
|
def main():
|
||||||
try:
|
try:
|
||||||
print()
|
video_url = get_video_url()
|
||||||
|
video_download(video_url)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("Session ended by user.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{e}")
|
print(f"{e}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user