JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
http://pytubefix.rtfd.io/
MIT License
454 stars 67 forks source link

Callback "on_progress_callback" is not wotking correctly #198

Closed Imad-AHDDAD closed 2 weeks ago

Imad-AHDDAD commented 3 weeks ago

Callback "on_progress_callback" is not wotking correctly


code

def on_progress(stream: Stream, chunk: bytes, bytes_remaining: int) -> None:
    filesize = stream.filesize
    bytes_received = filesize - bytes_remaining
    percentage = (bytes_received / filesize) * 100
    print(f"Download progress: {percentage:.2f}%")

@app.route("/download/test", methods=["POST"])
def test_download():
    url = "https://www.youtube.com/watch?v=DK_0jXPuIr0"
    yt = YouTube(url, on_progress_callback = on_progress)
    print(yt.title)
    ys = yt.streams.get_highest_resolution()
    ys.download()
    return "OK"

I expected to show a full progress information, like 1%, 2% ...... 100% but it's showing just 3 values : Download progress: 33.93% Download progress: 67.85% Download progress: 100.00%


Environment