如何使用youtube-dl下载视频标题作为文件名?


10

如何下载当前文件以显示原始标题?当我总是喜欢下载P9pzm5b6Fxx.mp4时,标题是Tigerking

如何设置它以便将其下载为tigerking.mp4


太奇怪了,对我来说,它会下载该视频,Tigerking-P9pzm5b6Fxx.mp4就像它的YouTube ID是一样P9pzm5b6Fxx
xjcl

Answers:


20

来自man youtube-dl

-o, --output TEMPLATE
      Output filename template.   Use  %(title)s  to  get  the  title,
      %(uploader)s  for  the  uploader  name,  %(uploader_id)s for the
      uploader  nickname  if  different,  %(autonumber)s  to  get   an
      automatically  incremented  number,  %(ext)s  for  the  filename
      extension, %(format)s for the format  description  (like  "22  -
      1280x720"  or  "HD"),  %(format_id)s  for  the  unique id of the
      format (like YouTube's itags: "137"),  %(upload_date)s  for  the
      upload date (YYYYMMDD), %(extractor)s for the provider (youtube,
      metacafe, etc), %(id)s for  the  video  id,  %(playlist_title)s,
      %(playlist_id)s,   or   %(playlist)s   (=title  if  present,  ID
      otherwise) for the playlist the video is in,  %(playlist_index)s
      for  the position in the playlist.  %(height)s and %(width)s for
      the width and height of the video format.  %(resolution)s for  a
      textual  description  of the resolution of the video format.  %%
      for a literal percent.  Use - to output to stdout.  Can also  be
      used  to  download to a different directory, for example with -o
      '/my/downloads/%(uploader)s /%(title)s-%(id)s.%(ext)s' .

因此,大概:

youtube-dl -o '%(title)s.%(ext)s' <URL-of-video>
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.