Я хочу получить процент загрузки из модуля youtube-dl для python, причина этого в том, что я хочу поместить его в индикатор выполнения в pyqt5. Я не нашел и документации на youtube-dl GitHub или где-либо еще по этому вопросу, кто-нибудь случайно узнает?
Я не нашел ни одного успешного ответа нигде на google / stack overflow / GitHub.
def downloadYoutube(self):
self.changeText()
# try:
self.lblState.setText('Downloading...')
url = self.txtURL.text()
if 'https://www.youtube.com/watch?' not in url:
buttonReply = QMessageBox.critical(self, 'Error! :(', "{} is an invalid URL".format(url), QMessageBox.Ok, QMessageBox.Ok)
return
# if 'https://youtu.be/' not in url:
# buttonReply = QMessageBox.critical(self, 'Error! :(', "{} is an invalid URL".format(url), QMessageBox.Ok, QMessageBox.Ok)
# return
if self.radAudio.isChecked() == True:
ydl_opts = {
'format': 'bestaudio/best',
'extractaudio': True,
'audioformat': "mp3",
'noplaylist': True,
}
else:
ydl_opts = {
'noplaylist': True,
}
info_dict = youtube_dl.YoutubeDL(ydl_opts).extract_info(url, download = False)
video_id = info_dict.get("id", None)
video_title = info_dict.get('title', None)
self.lblTitle.setText(str(video_title))
try:
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
self.lblState.setText('Downloading...')
ydl.download([url])
except Exception as e:
self.lblState.setText('')
buttonReply = QMessageBox.critical(self, 'Error! :(', "Problem downloading {}\n\nError Log:\n{}".format(url, e), QMessageBox.Ok, QMessageBox.Ok)
return
Я бы ожидал, что процент будет в переменной форме, но я не могу извлечь процент из любого места.