Search code examples
pythongtk3youtube-dl

Python GTK GUI for YouTube-DL show progress in window


I am currently working on my own YouTube-DL GTK GUI in Python. I would like to display the download progress by reading it out of the YouTube-DL progress hook. if I do this as below, it will only be displayed as 100% at the end of the download.
Why doesn't it update during the download?

        def my_hook(d):
            if d['status']      == 'downloading':
               self.label.set_text("Fortschritt:"+d['_percent_str']+"Verbleibende Zeit:"+d['_eta_str'])
                
        ydl_opts = {
            'format': (Art),
            'outtmpl': (Out),
            'noplaylist': (self.playlist),
            'extract-audio': (audio),
            'progress_hooks': [my_hook],
        }
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download([URL])

Solution

  • Are you sure you are using threads to download? In my own tk program, this works completely fine and updates as I expect it would, but that may be a possible solution.

    https://realpython.com/intro-to-python-threading/