Added a try/except block around progress_bar function.
This commit is contained in:
3
main.py
3
main.py
@@ -10,11 +10,14 @@ def get_video_url():
|
|||||||
|
|
||||||
# Callback function to show the progress bar.
|
# Callback function to show the progress bar.
|
||||||
def progress_bar(stream, _chunk, bytes_remaining):
|
def progress_bar(stream, _chunk, bytes_remaining):
|
||||||
|
try:
|
||||||
current = ((stream.filesize - bytes_remaining)/stream.filesize)
|
current = ((stream.filesize - bytes_remaining)/stream.filesize)
|
||||||
percent = ('{0:.1f}').format(current * 100)
|
percent = ('{0:.1f}').format(current * 100)
|
||||||
progress = int(50 * current)
|
progress = int(50 * current)
|
||||||
status = '█' * progress + '-' * (50 - progress)
|
status = '█' * progress + '-' * (50 - progress)
|
||||||
print(f'\r|{status}| {percent}%', end='')
|
print(f'\r|{status}| {percent}%', end='')
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An error has occurred: {e}")
|
||||||
|
|
||||||
# Downloads the video.
|
# Downloads the video.
|
||||||
def video_download(video_url):
|
def video_download(video_url):
|
||||||
|
|||||||
Reference in New Issue
Block a user