I am making an API
for youtube-dl in tkinter
& python
and need to know:
- How to get the info dict from youtube-dl in realtime (speed, percentage finished, file size, etc.) ??
I have tried:
import subprocess
def execute(command):
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
# Poll process for new output until finished
while True:
nextline = process.stdout.readline()
if nextline == '' and process.poll() != None:
break
sys.stdout.write(nextline.decode('utf-8'))
sys.stdout.flush()
output = process.communicate()[0]
exitCode = process.returncode
if (exitCode == 0):
return output
else:
raise ProcessException(command, exitCode, output)
execute("youtube-dl.exe www.youtube.com/watch?v=9bZkp7q19f0 -t")
from this Question
But it had to wait until finishing downloading to give me the info; maybe there is a way of getting the info from the youtube-dl source code.