【发布时间】:2022-11-18 00:08:07
【问题描述】:
我正在尝试使用 yt-dlp 下载 youtube 视频。 python 文件使用 yt-dlp 通过使用 subprocess.Open 函数将视频的 URL 手动传递到 python 脚本来下载 youtube 视频。
import subprocess
from moviepy.editor import *
import os
import moviepy.editor as mp
# Download files through url and saves it in yt-vidoes dir
command = "yt-dlp "
URL = 'https://www.youtube.com/watch?v=C_rsdqKA6ok'
parameters = ' --output yt-videos/%(title)s'
def download_video():
downloading = subprocess.Popen(command + URL)
downloading.wait()
print(downloading.returncode)
download_video()
它在 Windows 上运行良好,但在 Ubuntu 上出现此错误:
Traceback (most recent call last):
File "/home/purelogics/Arslan/shorts_bot/moveis/movies.py", line 17, in <module>
download_video()
File "/home/purelogics/Arslan/shorts_bot/moveis/movies.py", line 13, in download_video
downloading = subprocess.Popen(command + URL)
File "/home/linuxbrew/.linuxbrew/Cellar/python@3.10/3.10.8/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/linuxbrew/.linuxbrew/Cellar/python@3.10/3.10.8/lib/python3.10/subprocess.py", line 1847, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'yt-dlp https://www.youtube.com/watch?v=C_rsdqKA6ok'
【问题讨论】:
-
...
yt-dlp是该 Ubuntu 系统上 $PATH 上的可执行文件吗?
标签: python subprocess moviepy