The Python script youtube-dl returns a new file
I'm writing a script which uses youtube-dl in a subprocess, p = subprocess.Popen(cmd)
, to download a YouTube video. What is the best way to get back the new file (which is determined by %(title)s.%(ext)s
variables by youtube-dl --output=TEMPLATE
)?
Unfortunately, there is no option to print the new fi开发者_运维知识库le name which I could redirect to a variable. I could check for the latest created file in the download directory, but that feels unsafe, as I'll be using the information for other commands.
It does print destination filenane on stdout. It looks like this:
[download] Destination: XXX
if you give it options --no-progress --output=XXX
.
Or you could make a template for filename that would allow you to easily recognize newly downloaded file: %(title)s.%(ext)s-latest-download
or something and rename it later.
精彩评论