Skip to content
Advertisement

How to add “pytube” downloading info to tqdm Progress Bar?

I am trying make a YouTube video downloader. I want make a progress bar while downloading the YouTube video but I cant get any info (how many MB have been downloaded or how many video MB). I don’t know if this is possible with python or not. Here is my code so far:

JavaScript

Advertisement

Answer

To access the progress of the download, you can use the on_progress_callback argument when creating a YouTube instance.

The pytube quickstart says the following:

The on_progress_callback function will run whenever a chunk is downloaded from a video, and is called with three arguments: the stream, the data chunk, and the bytes remaining in the video. This could be used, for example, to display a progress bar.

JavaScript

Sample output:

JavaScript

Pytube has a built-in progress bar, but it does not use tqdm. Please see https://stackoverflow.com/a/60678355/5666087 for more information.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement