いろいろ試して見ましたがエラーが出ます。直接
コード*1の文を端末に貼り付けて実行できますがpython側からだと無理みたいです。
#コード
python
1 2#youtube-dl --extract-audio --audio-format mp3 3#youtube-dl -x --audio-format mp3 4com='youtube-dl -x --audio-format mp3' 5url='https://www.youtube.com/watch?v=' 6 7l=[] 8r=[] 9 10path = 'Demo.txt' 11 12with open(path) as f: 13 for s_line in f: 14 l.append(s_line) 15 16 17 18for i in l:r.append(i[9:20]) 19#for i in r:i=url+i 20 21print(com,url+r[0]) # *1 22 23 24import subprocess 25#i='-a' 26#print(subprocess.check_output(['ls',i ],shell=True)) 27 28s=subprocess.call([com,url+r[0]],shell=True) 29print(s) 30 31""" 32for i in r: 33 try: 34 subprocess.call([com,url+i ],shell=True) 35 except: 36 print(com,url+i) 37 #subprocess.check_output(['youtube-dl -x --audio-format mp3',i ],shell=True) 38 #subprocess.call(['youtube-dl -x --audio-format mp3 ',url+i ],shell=True) 39 #subprocess.check_output(["youtube-dl -x --audio-format mp3",url+i ],shell=True) 40""" 41 42
#エラー
python
1youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=xxxxxxxx 2Usage: youtube-dl [OPTIONS] URL [URL...] 3 4youtube-dl: error: You must provide at least one URL. 5Type youtube-dl --help to see a list of all options. 62 7
URLもdlオプションも間違ってないと思いますが、何処が悪いのでしょうか?
環境
リリース Linux Mint 18.3 Sylvia 64 ビット
カーネル Linux 4.15.0-36-generic x86_64
MATE 1.18.0
python 3.5.2 (default, Nov 23 2017)
[GCC 5.4.0 20160609]
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。