How can i make the progress bar in my tkinter youtube video downloader show the progress of the video downlaod?

Viewed 24

Am building a tkinter youtube video downloader using Python, so far I have managed to implement the download video feature, but now what I want is to display the progress of the video download using the progress bar, below is my code for downloading the video

# the function to download the video
def download_video():
    # the try statement to excute the download the video code
    try:
        # getting video url from entry
        video_link = url_entry.get()
        # getting video resolution from Combobox
        resolution = video_resolution.get()
        # creating a YouTube object
        video = YouTube(video_link)
        # checking if the combobox is empty
        if resolution == '':
            # display error message when combobox is empty
            showerror(title='Error', message='Please select a video resolution!!')
            
            
        elif resolution == 'None':
            # display error message when combobox value is None
            showerror(title='Error', message='None is an invalid video resolution!!\n'\
                    'Please select a valid video resolution')    
        
        # else let's download the video  
        else:
            
            # this try statement will run if the resolution exists for the video
            try:
                
                # downloading the video  
                video.streams.filter(res=resolution).first().download()
        
                # popup for dispalying the video downlaoded success message
                showinfo(title='Download Complete', message='Video has been downloaded successfully.')
                
            # the except will run when the resolution is not available or invalid
            except:
                # progress_bar.stop()
                showerror(title='Download Error', message='Failed to download video for this resolution')
        
    # the except statement to catch errors, URLConnectError, RegMatchError  
    except:
        # popup for displaying the error message
        showerror(title='Download Error', message='An error occurred while trying to ' \
                    'download the video\nThe following could ' \
                    'be the causes:\n->Invalid link\n->No internet connection\n'\
                     'Make sure you have stable internet connection and the video link is valid')
0 Answers
Related