Added a try/except block around progress_bar function.

This commit is contained in:
2024-02-19 21:05:50 -05:00
parent 5bdc69c548
commit 3bf3760178

View File

@@ -10,11 +10,14 @@ def get_video_url():
# Callback function to show the progress bar.
def progress_bar(stream, _chunk, bytes_remaining):
try:
current = ((stream.filesize - bytes_remaining)/stream.filesize)
percent = ('{0:.1f}').format(current * 100)
progress = int(50 * current)
status = '' * progress + '-' * (50 - progress)
print(f'\r|{status}| {percent}%', end='')
except Exception as e:
print(f"An error has occurred: {e}")
# Downloads the video.
def video_download(video_url):