2011-05-29 154 views
3

我试图使用this script使用Python下载YouTube视频。通过Python脚本下载YouTube视频

目前我使用这个如下

youtube-dl "http://www.youtube.com/watch?v=dvsdgyuv" 

在他们所写的,我该如何使用,我可以用这些

id: The sequence will be replaced by the video identifier. 
url: The sequence will be replaced by the video URL. 
uploader: The sequence will be replaced by the nickname of the person who uploaded the video. 
upload_date: The sequence will be replaced by the upload date in YYYYMMDD format. 
title: The sequence will be replaced by the literal video title. 
stitle: The sequence will be replaced by a simplified video title, restricted to alphanumeric characters and dashes. 
ext: The sequence will be replaced by the appropriate extension (like flv or mp4). 
epoch: The sequence will be replaced by the Unix epoch when creating the file. 
autonumber: The sequence will be replaced by a five-digit number that will be increased with each download, starting at zero.`enter code here` 

他们没有书面的文档。

如何使用视频文件名称与标题相同?

他们告诉使用这个,但我不知道如何在命令行上使用它。

%(title)s-%(id)s.%(ext)s. 

回答

3

在文档的底部,它说如何:

-o选项允许用户 指示输出 文件名的模板。当 下载单个文件时,基本用法不是 ,如 youtube-dl -o funny_video.flv “http:// some/video”。但是,它可能包含 下载每个视频时将被替换的 的特殊序列。 特殊序列的格式为%(NAME)s。为了澄清,这是 百分号后跟一个名称 括号,然后是小写 S.允许的名称是:...

你像这样运行命令使用这些特殊的输出参数:

youtube-dl "http://www.youtube.com/watch?v=dvsdgyuv" -o "%(title)s-%(id)s.%(ext)s." 
+0

谢谢你,我没有在该字符串之前使用双引号。也可以在不同的文件夹中下载。我的意思是第一个箱子文件夹,然后下载它 – user2134226 2011-05-29 05:35:21

+0

在Linux中,你只需运行'mkdir foo'并将'-o'设置为'foo /%(标题)...' – Blender 2011-05-29 05:37:34

+0

其实我想制作脚本会自动收集来自YouTube的播放列表并在特定文件夹中下载播放列表。我认为我需要在调用此脚本播放列表之前调用mkdir – user2134226 2011-05-29 05:40:39