python〜youtube-dl:错误:没有这样的选项:--audio-format [英] python ~ youtube-dl: error: no such option: --audio-format
问题描述
这是我的代码:
call(['youtube-dl', '-i', '--extract-audio', '--audio-format mp3','-w','ytsearch:'+song ,'-o '+song2file(song)+'.%(ext)s'], shell=False)
注意:这是此代码的实现:youtuble-dl -i --extract-audio --audio-format mp3 -w ytsearch:Wham Bam -o WhamBam.%(ext)s
在Song = Wham Bam的地方,当我运行此cmd时,它可以正常运行,但是python实现无法正常工作.
Note:This is an implementation of this code : youtuble-dl -i --extract-audio --audio-format mp3 -w ytsearch:Wham Bam -o WhamBam.%(ext)s
Where song = Wham Bam, When I run this cmd it works perfectly but the python implementation is not working.
在运行它时,它会向我返回此错误:
On running it, it returns me this error:
youtube-dl:错误:无此类选项:--audio-format
youtube-dl: error: no such option: --audio-format
推荐答案
作为解决方案的一部分,最好像这样正确格式化字符串:
as part of solution, it better to format your string properly like this:
arg= ['-i', '--extract-audio', '--audio-format mp3','-w','ytsearch:'+song ,'-o
'+song2file(song)+'.%(ext)s'];
yt-arg= " ".join(str(x) for x in arg);
然后称呼它
subprocess.call(['youtube-dl', yt-arg], shell=False)
这已经解决了您描述的问题,但-o选项似乎仍然有问题. 请记住要正确格式化您的字符串,不要不小心.
this already solve the problem you describe but it seems still have issue on the -o option. please remember to format your string properly, not carelessly.
这篇关于python〜youtube-dl:错误:没有这样的选项:--audio-format的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!