youtube-dl shows the download progress as a command prompt output messege. It works fine in cmd, but when used by a script, youtube-dl only shows this warning
WARNING: Falling back on generic information extractor.
and continues to download the file silently while having any other output hidden.
here is the script
import os
link = "example_link"
filename = "C:\Path\to\folder\file.mp4"
command = f'youtube-dl --newline -i -f best -o "{filename}" "{link}"'
print(os.popen(command).read())
My goal is to find a way to show the output while the script is running.
This code prints (stdout) the download progress with the same params:
import youtube_dl
link = "example_link"
filename = "C:\Path\to\folder\file.mp4"
ytb_opts = {
'newline':True,
'ignoreerrors':True,
'format':'best',
'outtmpl':filename
}
ydl = youtube_dl.YoutubeDL(ytb_opts)
ydl.download([link])
If you need to custom the progress message, you must override the report_progress function in FileDownloader class.