![如何修复 youtube-dl 错误:无法打开进行写入:[Errno 21] 是一个目录?](https://linux22.com/image/1202800/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%20youtube-dl%20%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E6%89%93%E5%BC%80%E8%BF%9B%E8%A1%8C%E5%86%99%E5%85%A5%EF%BC%9A%5BErrno%2021%5D%20%E6%98%AF%E4%B8%80%E4%B8%AA%E7%9B%AE%E5%BD%95%EF%BC%9F.png)
我正在尝试将youtube-dl
视频从 YouTube 下载到目录并弹出此错误:
$ youtube-dl -o ~/Videos http://www.youtube.com/watch?v=P0YiWsAM0O8
[youtube] P0YiWsAM0O8: Downloading webpage
[youtube] P0YiWsAM0O8: Downloading video info webpage
[youtube] P0YiWsAM0O8: Extracting video information
[youtube] P0YiWsAM0O8: Downloading MPD manifest
WARNING: Your copy of avconv is outdated and unable to properly mux separate video and audio files, youtube-dl will download single file media. Update avconv to version 10-0 or newer to fix this.
ERROR: unable to open for writing: [Errno 21] Is a directory: '/home/sami/Videos
我正在运行 Ubuntu 14.04 和youtube-dl
版本 2017.06.05
答案1
该-o
选项告诉youtube-dl
如何格式化目标路径和名称视频(而不仅仅是目录)。有点违反直觉。
-o
,--output TEMPLATE
输出文件名模板,请参阅“输出模板”了解所有信息
所以你需要类似这样的东西:
youtube-dl -o "$HOME/Videos/%(title)s.%(ext)s" 'http://www.youtube.com/watch?v=P0YiWsAM0O8'
要指定除默认值之外的其他内容%(title)s-%(id)s.%(ext)s
。我猜你很可能只想进入你的~/Videos
文件夹并youtube-dl
在那里运行而不使用任何选项。