我使用youtube-dl从YouTube下载文件。我尝试过下载多个文件,但是对我来说效果不好。每次想要下载一个视频时,我都必须打开多个终端并重新开始。
你能帮助我通过只在一个终端窗口中一次性提及所有URL来下载多个文件吗?我使用的是Ubuntu 12.04 64位操作系统。
你能帮助我通过只在一个终端窗口中一次性提及所有URL来下载多个文件吗?我使用的是Ubuntu 12.04 64位操作系统。
如果所有视频都在同一个播放列表或同一个频道中,您可以使用以下快捷方式来节省时间。
youtube-dl -f FORMAT -ciw -o "%(title)s.%(ext)s" -v <url-of-playlist>
<url-of-playlist>
被替换为播放列表的URL,将FORMAT
替换为任何可用的视频格式,例如18
。您可以使用-F
选项来查看所有有效的格式,如下所示:youtube-dl -F 'http://www.youtube.com/some-alphanumeric-string'
youtube-dl -f FORMAT -ci --playlist-start NUMBER --playlist-end NUMBER <url-of-playlist>
<url-of-playlist>
被替换为播放列表的URL,将FORMAT
替换为任何可用的视频格式,例如18
,而NUMBER
是播放列表中要开始/结束下载的视频编号。
youtube-dl -f FORMAT -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>
...其中<url-of-channel>
将替换为频道的URL,将FORMAT
替换为任何可用的视频格式,例如18
。
首先创建一个批处理文件,它是一个包含要从YouTube下载的视频的URL列表的文本文件。URL应该按照每行只有一个URL且没有其他内容的列表进行排列,并且每个URL都应该有一个新行。使用易于记忆的名称保存批处理文件,例如batch-file.txt。如果多个文件都在YouTube上的同一个播放列表、频道或用户网页上,您可以通过运行以下命令生成一个包含该页面上所有链接的列表的文本文件:
sudo apt install jq
youtube-dl -j --flat-playlist "https://<yourYoutubeWebpage>" | jq -r '.id' | sed 's_^_https://youtu.be/_' > batch-file.txt
youtube-dl -ct --simulate --batch-file='/path/to/batch-file.txt'
youtube-dl -ct -f 34 --simulate 'http://www.youtube.com/some-alphanumeric-string'
--simulate
选项时不会收到任何错误消息。您还可以添加-F选项以查看所有有效格式,如下所示:youtube-dl -F 'http://www.youtube.com/some-alphanumeric-string'
-f 34
。你可能更喜欢尝试flv 480p视频格式,可以使用-f 35
。所以在将你想要的视频格式添加到命令之后,命令会变成这样:youtube-dl -ciw -o "%(title)s.%(ext)s" --batch-file='/path/to/batch-file.txt'
--simulate
选项,所以这个命令将会真正执行。youtube-dl --help
使用方法:youtube-dl [选项] url [url...]
示例输入:youtube-dl http://www.youtube.com/watch?v=fqULJBBEVQE http://www.youtube.com/watch?v=vDbbz-BdyYc http://www.youtube.com/watch?v=OrIFaWJ9Glo
示例输出:
[youtube] Setting language
[youtube] fqULJBBEVQE: Downloading video webpage
[youtube] fqULJBBEVQE: Downloading video info webpage
[youtube] fqULJBBEVQE: Extracting video information
[download] Destination: Web Components - A Tectonic Shift for Web Development - Google I_O 2013-fqULJBBEVQE.mp4
[download] 100% of 238.14MiB in 36:54
[youtube] vDbbz-BdyYc: Downloading video webpage
[youtube] vDbbz-BdyYc: Downloading video info webpage
[youtube] vDbbz-BdyYc: Extracting video information
[download] Paul Irish on Web Application Development Workflow-vDbbz-BdyYc.mp4 has already been downloaded
[youtube] OrIFaWJ9Glo: Downloading video webpage
[youtube] OrIFaWJ9Glo: Downloading video info webpage
[youtube] OrIFaWJ9Glo: Extracting video information
[download] Got server HTTP error. Retrying (attempt 1 of 20)...
[download] Destination: Single Page Web Applications - JavaScript End-to-End (The Hard Stuff)-OrIFaWJ9Glo.mp4
[download] 100% of 553.10MiB in 42:17
打开桌面,创建一个名为 list
(或其他任意名称)的文本文件。将你想要下载的文件的URL复制并粘贴到文件中,每行一个URL。
打开终端并进入桌面
cd ~/Desktop
要下载列表中的文件,请输入以下命令(如果你给文件取了其他名称,请相应地替换 list
)
youtube-dl -a list
youtube-dl -citk -format mp4 -yes-playlist VIDEO_PLAYLIST_LINK
-c
继续下载部分文件-i
忽略任何错误。-t
使用视频标题作为文件名。-k
在后处理完成后保留视频在磁盘上。--format mp4
将视频文件保存为MP4格式。--yes-playlist
确认跟随的URL指向一个视频播放列表。-citk
非常具有误导性,可能会导致错误。-c
强制恢复,即使这样做并没有太多意义。默认情况下已经是继续操作。-i
可能还可以,但要注意可能会错过一些视频的错误。-t
已经是默认设置,并且已被弃用。-k
与-f mp4
结合没有意义。请参阅youtube-dl FAQ获取更多详细信息。 - phihag#!/bin/bash
terminal=`tty`
exec < ~/Documents/youtubevideolinks.txt
while read -r line
do
cd ~/Desktop/TilakDa/
youtube-dl -f 18 "$line"
done
exec < "$terminal"
-f 18
选项是用于360p视频。--batch-file
脚本(我不知道它存在多久了),它将文本文件的每一行作为一个URL处理。 - MrMeseesyoutube-dl -cit --format=mp4 --batch-file=./list-of-youtube-videos-link.txt
是我结合 https://askubuntu.com/a/947676/481688 和 https://askubuntu.com/a/334097/481688 的解决方案,对我起作用。我在这里单独记录下来,以便将来不再滚动多个答案。
--batch-file=./list-of-youtube-videos-link.txt
是一个包含YouTube链接列表的文件--format=mp4
期望输出为mp4格式-c
恢复部分下载的文件-i
忽略任何错误-t
使用视频标题作为文件名youtube-dl -f FORMAT --yes-playlist [url-of-playlist]
--yes-playlist
将下载播放列表,如果URL引用的是视频和播放列表。while read LL ; do youtube-dl "$LL" ; done < your_file
youtube-dl -f FORMAT {url1,url2,url...}
youtube-dl -f FORMAT url1; !:- url2; !:-url...
输入命令,然后输入&&
,再输入下一个命令,如:
youtube-dl--add-metadata -xic http://(the url) && youtube-dl--add-metadata -xic http://(the url)
主题仍然相关,因此:
获取您的YouTube链接。 删除以“?”开头的第一个视频参数。 像这样使用 :-) youtube-dl.exe --yes-playlist https://www.youtube.com/watch?list=yourlistlink