如何在输出中获取youtube_dl的视频计数256之1

问题描述

我正在通过pyside2在Qt Creator中创建一个GUI程序,该程序可让您下载Youtube音乐。我的目标是下载播放列表时获得视频计数,例如256的x或2的x或 256的1 ,但我不知道如何。我遇到了两个问题。

我不知道如何从youtube_dl输出获取此信息

[youtube:playlist] Downloading playlist PLi0XaxnSihZSnD1TNm82Y43o92r6UNEfH - add --no-playlist to just download video -5EmnQp3V48
[youtube:playlist] PLi0XaxnSihZSnD1TNm82Y43o92r6UNEfH: Downloading webpage
[download] Downloading playlist: Dance Central Songs
[youtube:playlist] PLi0XaxnSihZSnD1TNm82Y43o92r6UNEfH: Downloading page #1
[youtube:playlist] PLi0XaxnSihZSnD1TNm82Y43o92r6UNEfH: Downloading page #2
[youtube:playlist] playlist Dance Central Songs: Downloading 251 videos
[download] Downloading video **1 of 251**
[youtube] bESGLojNYSo: Downloading webpage
[download] Destination: Lady Gaga - Poker Face (Official Music Video)-bESGLojNYSo.webm
[download] 100% of 3.50MiB in 00:01                   
Finished
[ffmpeg] Destination: Lady Gaga - Poker Face (Official Music Video)-bESGLojNYSo.mp3
Deleting original file Lady Gaga - Poker Face (Official Music Video)-bESGLojNYSo.webm (pass -k to keep)
[download] Downloading video **2 of 251**
[youtube] E2tMV96xULk: Downloading webpage
14:03:36: C:\python38\python.exe exited with code 0

我尝试手动获取它,但是它没有用,然后我检查了youtube_dl github下载字典键,没有一个键可以获取该视频计数 1 of 256

print("Download keys:",download.keys())
Download keys: dict_keys(['status','downloaded_bytes','total_bytes','tmpfilename','filename','eta','speed','elapsed','_eta_str','_percent_str','_speed_str','_total_bytes_str'])

工作线程中的Youtube_dl代码

def run(self):
    self.main_window.progressBar.setValue(0)

    self.ydl_opts = {
        'format': 'bestaudio/best','noplaylist': self.main_window.playlist,'source_address': '0.0.0.0','ignoreerrors': True,'progress_hooks': [self.my_hook],'postprocessors': [{
            'key': 'FFmpegExtractAudio','preferredcodec': 'mp3'
        }]
    }

    with youtube_dl.YoutubedL(self.ydl_opts) as ydl:
        ydl.download([f'{self.main_window.downloadURL.text()}'])

def my_hook(self,download):
    if download["status"] == "finished":
        print("Finished")
        self.main_window.progresstext.setText("Ready")
    if download["status"] == "downloading":
        self.updateText.emit("Downloading...")
        percent = download["_percent_str"]
        percent = percent.replace("%","")
        self.updateProgress.emit(float(percent))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...