通过Python脚本下载YouTube视频

释放双眼,带上耳机,听听看~!

我正在尝试使用 this script使用Python下载YouTube视频.

目前我使用如下


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

在他们编写的文档中我可以使用这些文档


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

他们还没有写过如何使用它.

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

他们告诉使用它,但我不知道如何在命令行中使用它.


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

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

The -o option allows users to
indicate a template for the output
file names
. The basic usage is not
to set any template arguments when
downloading a single file, like in
youtube-dl -o funny_video.flv
http://some/video”. However, it may
contain special sequences that will be
replaced when downloading each video.
The special sequences have the format %(NAME)s. To clarify, that’s
a percent symbol followed by a name in
parenthesis, followed by a lowercase
S. Allowed names are: …

您可以像这样运行命令以使用这些特殊输出参数:


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

给TA打赏
共{{data.count}}人
人已打赏
安全技术

C++遍历文件夹

2022-1-11 12:36:11

安全技术

php截取字符串函数

2022-1-12 12:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索