如何使用youtube-dl脚本从播放列表中的某个索引开始下载?

59

如何使用 youtube-dl 指定起始位置和上限下载播放列表呢?

我尝试在代码中使用以下命令:

youtube-dl -o '~/Documents/%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s - %(title)s.%(ext)s' URL

它停在中间。我想从索引为i的视频重新启动进程,而不是从头开始。

4个回答

96

youtube-dl --help, 包含:

Video Selection:
  --playlist-start NUMBER          Playlist video to start at (default is 1)
  --playlist-end NUMBER            Playlist video to end at (default is last)
  --playlist-items ITEM_SPEC       Playlist video items to download. Specify
                                   indices of the videos in the playlist
                                   separated by commas like: "--playlist-items
                                   1,2,5,8" if you want to download videos
                                   indexed 1, 2, 5, 8 in the playlist. You can
                                   specify range: "--playlist-items
                                   1-3,7,10-13", it will download the videos
                                   at index 1, 2, 3, 7, 10, 11, 12 and 13.
因此,选项--playlist-start NUMBER可以帮助您从指定的NUMBER开始播放中间的播放列表。

非常感谢,这对我帮助很大。但是我如何从某个数字开始计数视频呢?这会下载正确的视频,但是从数字1而不是我插入的数字开始。 - hadar

19

我播放列表中共有135个视频。其中已成功下载了38个,于是我手动使用了这个命令。

youtube-dl --playlist-start 39 -u uname@gmail.com -p mypassword https://www.udemy.com/learn-ethical-hacking-from-scratch/learn/v4/content

正在下载我剩下的97个视频。


我遇到了以下错误: ERROR: Unable to download webpage: <urlopen error [Errno 1] _ssl.c:504: error:14 07742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version> (caused by URLError(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERV ER_HELLO:tlsv1 alert protocol version'),)) 请问你能帮我下载这些视频吗? - Hunterr
@HunterrJ,您能否请提供您正在使用的下载命令? - Ravi Yadav
我尝试过了,D:\tutorials>youtube-dl -u email -p password https://www.udemy.com/data-analysis-with-pandas/learn/v4/ - Hunterr
@HunterrJ,你尝试过在末尾添加“--playlist-start 1”以从第一个视频开始下载吗? - Ravi Yadav
@HunterrJ 首先你需要安装Python脚本,然后才能运行命令。 - Ravi Yadav
即使我尝试执行Python脚本。`def youtube(url): import youtube_dl ydl_opts = { 'verbose': False, 'format': '22/best', 'outtmpl': '%(title)s-%(id)s.%(ext)s', 'noplaylist': False, 'playliststart' : 1, 'u':'username', 'p':'password' } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([url])`仍然抛出相同的错误。 - Hunterr

1
这有所帮助:
youtube-dl -f best <playlist link> --playlist-start 15

-f best 选择最佳的视频格式。使用 youtube-dl --help 了解更多选项。


0
如果您只想下载类似于m4a的音频格式,那么以下命令将最适合。即使有播放列表,并提供开始和结束索引。此外,M4a格式文件大小更小。
youtube-dl -i -f mp4 --yes-playlist --playlist-start 'start_index' 'https://www.youtube.com/watch?v=7Vy8970q0Xc&list=PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2'

在使用ffmpeg之前使用内置的音频格式可以减少享受音乐或视频所需的时间。在后台,您可以获得更好的格式


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接