开发者

The Python script youtube-dl returns a new file

开发者 https://www.devze.com 2023-01-27 00:51 出处:网络
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.%(e

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号