How to add progress bar?

后端 未结 5 1883
逝去的感伤
逝去的感伤 2020-12-21 02:22

Is there a way to add progress bar in pytube? I don\'t know how to use the following method:

pytube.Stream().on_progress(chunk, file_handler, bytes_remaining         


        
5条回答
  •  一个人的身影
    2020-12-21 03:15

    I know this is already answered, but i came across this and for me the progress was counting down from 100 to 0. Since I wanted to fill a progress bar with the percentage value, I couldn't use this.

    So i came up with this solution:

    def progress_func(self, stream, chunk, file_handle,bytes_remaining):
      size = self.video.filesize
      progress = (float(abs(bytes_remaining-size)/size))*float(100)
      self.loadbar.setValue(progress)
    

    The loadbar is my Progress Bar from PyQt5. Hope this helps someone.

提交回复
热议问题