【最全】you-get和youtube-dl的安装和使用

2023-05-16

目录

  • 一、ffmpeg、you-get、youtube-dl简介
  • 二、ffmpeg、you-get、youtube-dl安装
    • 2.1 安装
    • 2.2 配置
  • 三、you-get使用
  • 四、youtube-dl使用
    • 4.1 常用选项
      • ● 获取视频格式列表
      • ●下载指定格式(format)视频
      • ●保存到指定位置
    • 4.2 综合使用
  • 五、附录:youtube-dl参数及说明
    • 5.1帮助内容原文:
    • 5.2帮助内容译文:
      • 5.21常规选项
      • 5.22网络选项
      • 5.23地理区域限制
      • 5.24视频选择
      • 5.25下载选项
      • 5.26文件系统选项
      • 5.27缩略图选项
      • 5.28 详细程度/模拟选项
      • 5.29工作环境选项
      • 5.30视频格式选项
      • 5.31字幕选项
      • 5.32身份验证选项
      • 5.33Adobe 通行证选项
      • 5.34后处理选项

一、ffmpeg、you-get、youtube-dl简介

直接在github上搜索这些项目也可以查看简介、下载等。

you-get:
  You-Get 是一个小型命令行实用程序,用于从 Web 下载媒体内容(视频、音频、图像)。
youtube-dl:
  youtube-dl 是一款基于 Python 的小型命令行工具,允许从 YouTube、Dailymotion、Google Video、Photobucket、Facebook、Yahoo、Metacafe、Depositfiles、Bilibili 和类似网站下载视频。 它是用 pygtk 编写的,需要 Python 解释器来运行,它不受平台限制,可以在任何 GNU/Linux、Windows 或 macOS 系统上运行。
  youtube-dl 还允许选择特定的可用视频质量格式进行下载,或让程序本身自动从网站下载更高质量的视频。它还支持特定的播放列表下载,在下载的视频文件中添加自定义或原始标题的选项,并支持proxy等。
ffmpeg:
  FFmpeg 是处理多媒体内容(例如音频、视频、字幕和相关元数据)的库和工具的集合。FFmpeg 是处理多媒体内容(例如音频、视频、字幕和相关元数据)的库和工具的集合。

在这里使用ffmpeg的原因是:you-get和youtube-dl下载的内容可能是音视频分开下载的(某些分辨率或者某些站点),用视频剪辑软件合并又要浪费一定的时间,而安装ffmpeg之后,则可以自动合并(merge)。

二、ffmpeg、you-get、youtube-dl安装

2.1 安装

  1. 直接在github上搜索,安装项目里面的说明下载安装。通常是使用pip或者conda来安装。
  2. 下载exe版本,我已经放在我的仓库里面了(也可以github或者gitee上搜索下载)。

下载链接。

2.2 配置

配置很简单,添加到环境变量(Path)就可以了。
其中,ffmpeg不是单独的可执行文件,把文件夹中的bin文件夹添加到环境变量就可以了。
如下是我的设置:
在这里插入图片描述

配置好之后,在命令行即可使用对应命令:
在这里插入图片描述

三、you-get使用

详细的使用见文章:You-get && FFmpeg,由于某种原因,翻译成英文才发布成功,不过不难读懂。

在这里,我使用python脚本的方式演示youtube视频的下载(需要proxy)。

代码:

# -*- coding = utf-8 -*-
# @TIME : 2022/10/24 下午 4:02
# @Author : CQUPTLei
# @File : YouTube_download.py.py
# @Softeare : PyCharm

import time
import os
from you_get import common

'''
默认参数
'''
#视频链接
v_url = 'https://www.bilibili.com/video/BV1JF411L7zw?spm_id_from=333.851.b_7265636f6d6d656e64.5'
#保存格式
v_format = 'dash-flv'
#保存路径
save_dir = 'D:\Python_Study\File_Save\IU'

#提示信息打印函数
#'\033[5;36m' 用来设置输出内容的字体颜色和背景颜色
def LOG(info):
    print('\033[5;36m' + 'You-get: ' + time.strftime('%Y-%m-%d %H:%M:%S',
        time.localtime(time.time())) + ' '+info + '\033[0m')

#设置要下载的视频连接
LOG("输入要下载的视频链接:")
url=input("URL:")
if url=='':
    pass
else:
    v_url=url.replace('&','"&"')
    #print(v_url)
    #v_url=url

#设置代理,默认不设置
#也可以在pycharm设置中设置(proxy)
# LOG("是否需要设置代理下载(y/n)?")
# proxy=input()
# if proxy=='y':
#     common.set_http_proxy(input("请输入代理服务器和端口,例如:127.0.0.1:1080"))
# elif proxy=='':
#     pass
#或者直接设置
# common.set_http_proxy('127.0.0.1:7890')

#打印输出可供选择的清晰度
LOG("正在加载可供下载的清晰度...")
if input()=='':
    pass
os.system('you-get -i '+v_url)

#选择清晰度默认MP4最高画质
LOG("请输入你要下载的清晰度(默认dash-flv):")
quality=input("format select:")
if quality=='':
   pass
else:
    v_format=quality

#设置保存路径,默认为D:\Python_Study\File_Save
LOG("请设置保存路径(默认路径为:D:\Python_Study\File_Save)")
path=input("save path:")
if path=='':
    pass
else:
    save_dir=path

#根据设置的参数进行下载
LOG("开始下载...")
common.any_download(url=v_url,stream_id=v_format,info_only=False,output_dir=save_dir,merge=True)
LOG("下载完毕")

效果:
视频地址: [IU] Blueming Live Clip (2019 IU Tour Concert ‘Love, poem’)
在这里插入图片描述

ffmpeg自动运行:

在这里插入图片描述

保存下来的视频:
在这里插入图片描述

四、youtube-dl使用

4.1 常用选项

● 获取视频格式列表

youtube-dl -F URL

在这里插入图片描述

●下载指定格式(format)视频

youtube-dl -f format URL 

format可以使用上面列出的,也可以:
best 选择最佳质量的音/视频文件 worst 选择质量最差的格式(视频和音频)
bestvideo 选择最佳质量的仅视频格式(例如DASH视频),可能无法使用。
worstvideo选择质量最差的纯视频格式,可能无法使用。
bestaudio 选择最优质的音频格式,可能无法使用。
worstaudio 选择质量最差的音频格式,可能无法使用。

还可以这样组合:

youtube-dl -f bestvideo+bestaudio URL

如果要分开下载把“+”改成“,”即可。

●保存到指定位置

不支持直接指定输出位置,但可以采用以下方法:

  1. 使用’-o’参数,同时指定输出目录和保存的文件名称。如 youtube-dl -o 'D:\Python_Study\File_Save\JayChou\name.flv' URL,如果只写了保存文件名称,则会默认保存在user目录之下,如果没有写‘-o’参数,则默认为视频标题,默认保存在user下。
  2. 使用’cd’命令进入到文件保存位置,再下载。

4.2 综合使用

这里写一个bat脚本演示,读者使用时注意将编码设置为ANSI。

@echo off
::olor 02
::==========================目录设置========================
::默认下载目录
:default_save_dir
set default_dir=D:\Python_Study\File_Save\test
pushd %default_dir%
echo 默认保存路径是:%cd%
set /p mode=是否需要重新设置保存目录?(y/n)
if /i %mode%==y call :set_dir
if /i %mode%==n call :download
if /i not %mode%==y if /i not %mode%==n  echo 输入有误
echo.
call :default_save_dir


::==========================下载========================
::下载视频,不点击退出则可一直在上述文件夹下下载
:download
echo.
set /p url=请输入视频URL:
set url=%url:&=^^^&%
::打印可供下载的视频格式
youtube-dl -F %url%
if errorlevel 1 goto :download
echo.
set /p code=请输入视频格式(format):
::开始下载
youtube-dl -f %code% %url%
goto :download


::::==========================手动设置目录========================
:set_dir
echo.
set /p dir=请输入保存路径:
set dir=%dir:/=\%
::保存并切换到该目录
pushd %dir%
::比较当前路径与前面输入的路径是否一致,%cd%表示当前的绝对路径
if /i not %dir%==%cd% goto :set_dir
echo 现在的下载目录为:%cd%

效果:
在这里插入图片描述
可见速度比较慢。
在同一网络,同一proxy之下,使用youtube-dl的升级版yt-dlp速度很快,如下:
在这里插入图片描述
对于yt-dlp的介绍见后续文章。

五、附录:youtube-dl参数及说明

youtube-dl的说明内容比较多(57KB左右),直接在命令行使用youtube-dl -h命令打印显示不完整(增大缓冲区也不行),这里直接将输出重定向,保存到文本中。
命令:youtube-dl -h >C:\Users\secret\Desktop\help.txt

5.1帮助内容原文:

Usage: youtube-dl.exe [OPTIONS] URL [URL...]

Options:
  General Options:
    -h, --help                           Print this help text and exit
    --version                            Print program version and exit
    -U, --update                         Update this program to latest version.
                                         Make sure that you have sufficient
                                         permissions (run with sudo if needed)
    -i, --ignore-errors                  Continue on download errors, for
                                         example to skip unavailable videos in a
                                         playlist
    --abort-on-error                     Abort downloading of further videos (in
                                         the playlist or the command line) if an
                                         error occurs
    --dump-user-agent                    Display the current browser
                                         identification
    --list-extractors                    List all supported extractors
    --extractor-descriptions             Output descriptions of all supported
                                         extractors
    --force-generic-extractor            Force extraction to use the generic
                                         extractor
    --default-search PREFIX              Use this prefix for unqualified URLs.
                                         For example "gvsearch2:" downloads two
                                         videos from google videos for youtube-
                                         dl "large apple". Use the value "auto"
                                         to let youtube-dl guess ("auto_warning"
                                         to emit a warning when guessing).
                                         "error" just throws an error. The
                                         default value "fixup_error" repairs
                                         broken URLs, but emits an error if this
                                         is not possible instead of searching.
    --ignore-config                      Do not read configuration files. When
                                         given in the global configuration file
                                         /etc/youtube-dl.conf: Do not read the
                                         user configuration in ~/.config
                                         /youtube-dl/config (%APPDATA%/youtube-
                                         dl/config.txt on Windows)
    --config-location PATH               Location of the configuration file;
                                         either the path to the config or its
                                         containing directory.
    --flat-playlist                      Do not extract the videos of a
                                         playlist, only list them.
    --mark-watched                       Mark videos watched (YouTube only)
    --no-mark-watched                    Do not mark videos watched (YouTube
                                         only)
    --no-color                           Do not emit color codes in output

  Network Options:
    --proxy URL                          Use the specified HTTP/HTTPS/SOCKS
                                         proxy. To enable SOCKS proxy, specify a
                                         proper scheme. For example
                                         socks5://127.0.0.1:1080/. Pass in an
                                         empty string (--proxy "") for direct
                                         connection
    --socket-timeout SECONDS             Time to wait before giving up, in
                                         seconds
    --source-address IP                  Client-side IP address to bind to
    -4, --force-ipv4                     Make all connections via IPv4
    -6, --force-ipv6                     Make all connections via IPv6

  Geo Restriction:
    --geo-verification-proxy URL         Use this proxy to verify the IP address
                                         for some geo-restricted sites. The
                                         default proxy specified by --proxy (or
                                         none, if the option is not present) is
                                         used for the actual downloading.
    --geo-bypass                         Bypass geographic restriction via
                                         faking X-Forwarded-For HTTP header
    --no-geo-bypass                      Do not bypass geographic restriction
                                         via faking X-Forwarded-For HTTP header
    --geo-bypass-country CODE            Force bypass geographic restriction
                                         with explicitly provided two-letter ISO
                                         3166-2 country code
    --geo-bypass-ip-block IP_BLOCK       Force bypass geographic restriction
                                         with explicitly provided IP block in
                                         CIDR notation

  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.
    --match-title REGEX                  Download only matching titles (regex or
                                         caseless sub-string)
    --reject-title REGEX                 Skip download for matching titles
                                         (regex or caseless sub-string)
    --max-downloads NUMBER               Abort after downloading NUMBER files
    --min-filesize SIZE                  Do not download any videos smaller than
                                         SIZE (e.g. 50k or 44.6m)
    --max-filesize SIZE                  Do not download any videos larger than
                                         SIZE (e.g. 50k or 44.6m)
    --date DATE                          Download only videos uploaded in this
                                         date
    --datebefore DATE                    Download only videos uploaded on or
                                         before this date (i.e. inclusive)
    --dateafter DATE                     Download only videos uploaded on or
                                         after this date (i.e. inclusive)
    --min-views COUNT                    Do not download any videos with less
                                         than COUNT views
    --max-views COUNT                    Do not download any videos with more
                                         than COUNT views
    --match-filter FILTER                Generic video filter. Specify any key
                                         (see the "OUTPUT TEMPLATE" for a list
                                         of available keys) to match if the key
                                         is present, !key to check if the key is
                                         not present, key > NUMBER (like
                                         "comment_count > 12", also works with
                                         >=, <, <=, !=, =) to compare against a
                                         number, key = 'LITERAL' (like "uploader
                                         = 'Mike Smith'", also works with !=) to
                                         match against a string literal and & to
                                         require multiple matches. Values which
                                         are not known are excluded unless you
                                         put a question mark (?) after the
                                         operator. For example, to only match
                                         videos that have been liked more than
                                         100 times and disliked less than 50
                                         times (or the dislike functionality is
                                         not available at the given service),
                                         but who also have a description, use
                                         --match-filter "like_count > 100 &
                                         dislike_count <? 50 & description" .
    --no-playlist                        Download only the video, if the URL
                                         refers to a video and a playlist.
    --yes-playlist                       Download the playlist, if the URL
                                         refers to a video and a playlist.
    --age-limit YEARS                    Download only videos suitable for the
                                         given age
    --download-archive FILE              Download only videos not listed in the
                                         archive file. Record the IDs of all
                                         downloaded videos in it.
    --include-ads                        Download advertisements as well
                                         (experimental)

  Download Options:
    -r, --limit-rate RATE                Maximum download rate in bytes per
                                         second (e.g. 50K or 4.2M)
    -R, --retries RETRIES                Number of retries (default is 10), or
                                         "infinite".
    --fragment-retries RETRIES           Number of retries for a fragment
                                         (default is 10), or "infinite" (DASH,
                                         hlsnative and ISM)
    --skip-unavailable-fragments         Skip unavailable fragments (DASH,
                                         hlsnative and ISM)
    --abort-on-unavailable-fragment      Abort downloading when some fragment is
                                         not available
    --keep-fragments                     Keep downloaded fragments on disk after
                                         downloading is finished; fragments are
                                         erased by default
    --buffer-size SIZE                   Size of download buffer (e.g. 1024 or
                                         16K) (default is 1024)
    --no-resize-buffer                   Do not automatically adjust the buffer
                                         size. By default, the buffer size is
                                         automatically resized from an initial
                                         value of SIZE.
    --http-chunk-size SIZE               Size of a chunk for chunk-based HTTP
                                         downloading (e.g. 10485760 or 10M)
                                         (default is disabled). May be useful
                                         for bypassing bandwidth throttling
                                         imposed by a webserver (experimental)
    --playlist-reverse                   Download playlist videos in reverse
                                         order
    --playlist-random                    Download playlist videos in random
                                         order
    --xattr-set-filesize                 Set file xattribute ytdl.filesize with
                                         expected file size
    --hls-prefer-native                  Use the native HLS downloader instead
                                         of ffmpeg
    --hls-prefer-ffmpeg                  Use ffmpeg instead of the native HLS
                                         downloader
    --hls-use-mpegts                     Use the mpegts container for HLS
                                         videos, allowing to play the video
                                         while downloading (some players may not
                                         be able to play it)
    --external-downloader COMMAND        Use the specified external downloader.
                                         Currently supports aria2c,avconv,axel,c
                                         url,ffmpeg,httpie,wget
    --external-downloader-args ARGS      Give these arguments to the external
                                         downloader

  Filesystem Options:
    -a, --batch-file FILE                File containing URLs to download ('-'
                                         for stdin), one URL per line. Lines
                                         starting with '#', ';' or ']' are
                                         considered as comments and ignored.
    --id                                 Use only video ID in file name
    -o, --output TEMPLATE                Output filename template, see the
                                         "OUTPUT TEMPLATE" for all the info
    --output-na-placeholder PLACEHOLDER  Placeholder value for unavailable meta
                                         fields in output filename template
                                         (default is "NA")
    --autonumber-start NUMBER            Specify the start value for
                                         %(autonumber)s (default is 1)
    --restrict-filenames                 Restrict filenames to only ASCII
                                         characters, and avoid "&" and spaces in
                                         filenames
    -w, --no-overwrites                  Do not overwrite files
    -c, --continue                       Force resume of partially downloaded
                                         files. By default, youtube-dl will
                                         resume downloads if possible.
    --no-continue                        Do not resume partially downloaded
                                         files (restart from beginning)
    --no-part                            Do not use .part files - write directly
                                         into output file
    --no-mtime                           Do not use the Last-modified header to
                                         set the file modification time
    --write-description                  Write video description to a
                                         .description file
    --write-info-json                    Write video metadata to a .info.json
                                         file
    --write-annotations                  Write video annotations to a
                                         .annotations.xml file
    --load-info-json FILE                JSON file containing the video
                                         information (created with the "--write-
                                         info-json" option)
    --cookies FILE                       File to read cookies from and dump
                                         cookie jar in
    --cache-dir DIR                      Location in the filesystem where
                                         youtube-dl can store some downloaded
                                         information permanently. By default
                                         $XDG_CACHE_HOME/youtube-dl or ~/.cache
                                         /youtube-dl . At the moment, only
                                         YouTube player files (for videos with
                                         obfuscated signatures) are cached, but
                                         that may change.
    --no-cache-dir                       Disable filesystem caching
    --rm-cache-dir                       Delete all filesystem cache files

  Thumbnail Options:
    --write-thumbnail                    Write thumbnail image to disk
    --write-all-thumbnails               Write all thumbnail image formats to
                                         disk
    --list-thumbnails                    Simulate and list all available
                                         thumbnail formats

  Verbosity / Simulation Options:
    -q, --quiet                          Activate quiet mode
    --no-warnings                        Ignore warnings
    -s, --simulate                       Do not download the video and do not
                                         write anything to disk
    --skip-download                      Do not download the video
    -g, --get-url                        Simulate, quiet but print URL
    -e, --get-title                      Simulate, quiet but print title
    --get-id                             Simulate, quiet but print id
    --get-thumbnail                      Simulate, quiet but print thumbnail URL
    --get-description                    Simulate, quiet but print video
                                         description
    --get-duration                       Simulate, quiet but print video length
    --get-filename                       Simulate, quiet but print output
                                         filename
    --get-format                         Simulate, quiet but print output format
    -j, --dump-json                      Simulate, quiet but print JSON
                                         information. See the "OUTPUT TEMPLATE"
                                         for a description of available keys.
    -J, --dump-single-json               Simulate, quiet but print JSON
                                         information for each command-line
                                         argument. If the URL refers to a
                                         playlist, dump the whole playlist
                                         information in a single line.
    --print-json                         Be quiet and print the video
                                         information as JSON (video is still
                                         being downloaded).
    --newline                            Output progress bar as new lines
    --no-progress                        Do not print progress bar
    --console-title                      Display progress in console titlebar
    -v, --verbose                        Print various debugging information
    --dump-pages                         Print downloaded pages encoded using
                                         base64 to debug problems (very verbose)
    --write-pages                        Write downloaded intermediary pages to
                                         files in the current directory to debug
                                         problems
    --print-traffic                      Display sent and read HTTP traffic
    -C, --call-home                      Contact the youtube-dl server for
                                         debugging
    --no-call-home                       Do NOT contact the youtube-dl server
                                         for debugging

  Workarounds:
    --encoding ENCODING                  Force the specified encoding
                                         (experimental)
    --no-check-certificate               Suppress HTTPS certificate validation
    --prefer-insecure                    Use an unencrypted connection to
                                         retrieve information about the video.
                                         (Currently supported only for YouTube)
    --user-agent UA                      Specify a custom user agent
    --referer URL                        Specify a custom referer, use if the
                                         video access is restricted to one
                                         domain
    --add-header FIELD:VALUE             Specify a custom HTTP header and its
                                         value, separated by a colon ':'. You
                                         can use this option multiple times
    --bidi-workaround                    Work around terminals that lack
                                         bidirectional text support. Requires
                                         bidiv or fribidi executable in PATH
    --sleep-interval SECONDS             Number of seconds to sleep before each
                                         download when used alone or a lower
                                         bound of a range for randomized sleep
                                         before each download (minimum possible
                                         number of seconds to sleep) when used
                                         along with --max-sleep-interval.
    --max-sleep-interval SECONDS         Upper bound of a range for randomized
                                         sleep before each download (maximum
                                         possible number of seconds to sleep).
                                         Must only be used along with --min-
                                         sleep-interval.

  Video Format Options:
    -f, --format FORMAT                  Video format code, see the "FORMAT
                                         SELECTION" for all the info
    --all-formats                        Download all available video formats
    --prefer-free-formats                Prefer free video formats unless a
                                         specific one is requested
    -F, --list-formats                   List all available formats of requested
                                         videos
    --youtube-skip-dash-manifest         Do not download the DASH manifests and
                                         related data on YouTube videos
    --merge-output-format FORMAT         If a merge is required (e.g.
                                         bestvideo+bestaudio), output to given
                                         container format. One of mkv, mp4, ogg,
                                         webm, flv. Ignored if no merge is
                                         required

  Subtitle Options:
    --write-sub                          Write subtitle file
    --write-auto-sub                     Write automatically generated subtitle
                                         file (YouTube only)
    --all-subs                           Download all the available subtitles of
                                         the video
    --list-subs                          List all available subtitles for the
                                         video
    --sub-format FORMAT                  Subtitle format, accepts formats
                                         preference, for example: "srt" or
                                         "ass/srt/best"
    --sub-lang LANGS                     Languages of the subtitles to download
                                         (optional) separated by commas, use
                                         --list-subs for available language tags

  Authentication Options:
    -u, --username USERNAME              Login with this account ID
    -p, --password PASSWORD              Account password. If this option is
                                         left out, youtube-dl will ask
                                         interactively.
    -2, --twofactor TWOFACTOR            Two-factor authentication code
    -n, --netrc                          Use .netrc authentication data
    --video-password PASSWORD            Video password (vimeo, youku)

  Adobe Pass Options:
    --ap-mso MSO                         Adobe Pass multiple-system operator (TV
                                         provider) identifier, use --ap-list-mso
                                         for a list of available MSOs
    --ap-username USERNAME               Multiple-system operator account login
    --ap-password PASSWORD               Multiple-system operator account
                                         password. If this option is left out,
                                         youtube-dl will ask interactively.
    --ap-list-mso                        List all supported multiple-system
                                         operators

  Post-processing Options:
    -x, --extract-audio                  Convert video files to audio-only files
                                         (requires ffmpeg/avconv and
                                         ffprobe/avprobe)
    --audio-format FORMAT                Specify audio format: "best", "aac",
                                         "flac", "mp3", "m4a", "opus", "vorbis",
                                         or "wav"; "best" by default; No effect
                                         without -x
    --audio-quality QUALITY              Specify ffmpeg/avconv audio quality,
                                         insert a value between 0 (better) and 9
                                         (worse) for VBR or a specific bitrate
                                         like 128K (default 5)
    --recode-video FORMAT                Encode the video to another format if
                                         necessary (currently supported:
                                         mp4|flv|ogg|webm|mkv|avi)
    --postprocessor-args ARGS            Give these arguments to the
                                         postprocessor
    -k, --keep-video                     Keep the video file on disk after the
                                         post-processing; the video is erased by
                                         default
    --no-post-overwrites                 Do not overwrite post-processed files;
                                         the post-processed files are
                                         overwritten by default
    --embed-subs                         Embed subtitles in the video (only for
                                         mp4, webm and mkv videos)
    --embed-thumbnail                    Embed thumbnail in the audio as cover
                                         art
    --add-metadata                       Write metadata to the video file
    --metadata-from-title FORMAT         Parse additional metadata like song
                                         title / artist from the video title.
                                         The format syntax is the same as
                                         --output. Regular expression with named
                                         capture groups may also be used. The
                                         parsed parameters replace existing
                                         values. Example: --metadata-from-title
                                         "%(artist)s - %(title)s" matches a
                                         title like "Coldplay - Paradise".
                                         Example (regex): --metadata-from-title
                                         "(?P<artist>.+?) - (?P<title>.+)"
    --xattrs                             Write metadata to the video file's
                                         xattrs (using dublin core and xdg
                                         standards)
    --fixup POLICY                       Automatically correct known faults of
                                         the file. One of never (do nothing),
                                         warn (only emit a warning),
                                         detect_or_warn (the default; fix file
                                         if we can, warn otherwise)
    --prefer-avconv                      Prefer avconv over ffmpeg for running
                                         the postprocessors
    --prefer-ffmpeg                      Prefer ffmpeg over avconv for running
                                         the postprocessors (default)
    --ffmpeg-location PATH               Location of the ffmpeg/avconv binary;
                                         either the path to the binary or its
                                         containing directory.
    --exec CMD                           Execute a command on the file after
                                         downloading and post-processing,
                                         similar to find's -exec syntax.
                                         Example: --exec 'adb push {}
                                         /sdcard/Music/ && rm {}'
    --convert-subs FORMAT                Convert the subtitles to other format
                                         (currently supported: srt|ass|vtt|lrc)

5.2帮助内容译文:

用的Google翻译,我校准了一下,对于有些不怎么用的选项,懒得校准,读者对比英文理解。

用法:youtube-dl.exe [OPTIONS] URL [URL...]

5.21常规选项

用法:youtube-dl.exe [OPTIONS] URL [URL...]

选项:
  常规选项:
-h, --help                           打印此帮助文本并退出
--version                            打印程序版本并退出
-U, --update                         将此程序更新到最新版本。
                                     确保你有足够的权限(如果需要,使用 sudo 运行)
-i, --ignore-errors                  发生错误时继续(比如跳过一个播放列表中不可用的视频)
--abort-on-error                     发生错误时,中止下载更多视频
--dump-user-agent                    显示当前浏览器鉴别
--list-extractors                    列出所有支持的提取器
--extractor-descriptions             输出所有支持的描述提取器
--force-generic-extractor            强制提取以使用泛型提取器
--default-search PREFIX              将此前缀用于不合格的 URL。
--ignore-config                      不读取配置文件。什么时候在全局配置文件中给出
                                         /etc/youtube-dl.conf:不要阅读  ~/.config 中的用
                                         户配置/youtube-dl/config (%APPDATA%/youtube-
                                         dl/config.txt 在 Windows 上)
--config-location PATH               配置文件的位置; 配置的路径或其包含目录。
--flat-playlist                      不提取一个视频播放列表,仅列出它们。
--mark-watched                       标记已观看的视频(仅限 YouTube)
--no-mark-watched                    不标记已观看的视频(仅限YouTube)
--no-color                           不要在输出中发出颜色代码

5.22网络选项

--proxy URL                               使用指定的HTTP/HTTPS/SOCKS代理。如果要启用 SOCKS 
                                          代理,请指定适当的方案。 例如so cks5: //127.0.0.1: 1080/ 。传入一个空字符串 (--proxy "") 用于直联。
--socket-timeout SECONDS                  放弃前等待的时间,单位为秒
--source-address IP                       要绑定的客户端 IP 地址
-4, --force-ipv4                          通过 IPv4 建立所有连接
-6, --force-ipv6 						  通过 IPv6 建立所有连接

5.23地理区域限制

--geo-verification-proxy URL             使用此代理验证 IP 地址对于一些受地理限制的站点。这
                                         --proxy 指定的默认代理(或无,如果该选项不存在)是
                                         用于实际下载。
--geo-bypass                             绕过地理限制,伪造 X-Forwarded-For HTTP 标头
--no-geo-bypass                          不绕过地理限制通过伪造 X-Forwarded-For HTTP 标头
--geo-bypass-country CODE                强制绕过地理限制明确提供两个字母的 ISO3166-2 国家代码
--geo-bypass-ip-block IP_BLOCK           强制绕过地理限制具有明确提供的 IP 块CIDR 符号

5.24视频选择

--playlist-start NUMBER                  从视频列表中的第几个视频开始(默认为1)
--playlist-end NUMBER                    到视频列表中的第几个视频为止(默认为最后一个)
--playlist-items ITEM_SPEC               指定视频列表中要下载的视频的索引,例如:
                                         “--playlist-items 1,2,5,8” ,是
                                         下载播放列表中索引为 1、2、5、8 的视频。
                                         您可以指定范围:
                                         “--playlist-items 1-3,7,10-13”,它将
                                         下载索引 1、2、3 处的视频,7、10、11、12 和 13。
--match-title REGEX                      只下载匹配的标题(正则表达式或不区分大小写的字符串)
--reject-title REGEX 					 跳过下载匹配的标题(正则表达式或不区分大小写的字符串)
--max-downloads NUMBER 					 下载 NUMBER 个文件后中止
--min-filesize SIZE 					 不要下载任何小于指定尺寸的视频(例如 50k 或 44.6m)
--max-filesize SIZE 					 不要下载任何大于指定尺寸(例如 50k 或 44.6m)
--date DATE 							 仅下载在此日期上传的视频
--datebefore DATE 						 仅下载上传于或在此日期之前(包括在内)
--dateafter DATE 						 仅下载上传于或在此日期之后(包括在内)
--min-views COUNT 						 不要下载任何不足 COUNT 次观看的视频
--max-views COUNT 						 不要下载任何超过 COUNT 次观看的视频
--match-filter FILTER 					 通用视频过滤器。指定任意键
                                         (有关列表,请参阅“输出模板”
                                         的可用键)匹配,如果键
                                         存在,!key 检查密钥是否存在
                                         不存在,键 > NUMBER(如
                                         “comment_count > 12”,也适用于
                                         >=, <, <=, !=, =) 与 a 进行比较
                                         number, key = 'LITERAL' (如“上传者
                                         = 'Mike Smith'",也适用于 !=)
                                         匹配字符串文字和 & to
                                         需要多个匹配。价值观
                                         不知道被排除在外,除非你
                                         在后面加上问号 (?)
                                         操作员。例如,只匹配
                                         被点赞超过
                                         100 次,不喜欢少于 50 次
                                         次(或不喜欢的功能是
                                         在给定的服务中不可用),
                                         但谁也有描述,使用
                                         --match-filter "like_count > 100 &
                                         不喜欢计数 <? 50 & 描述”。
--no-playlist 							 仅下载视频,如果 URL指向的是视频和播放列表。
--yes-playlist 							 下载播放列表,如果是 URL指向的是视频和播放列表。
--age-limit YEARS 						 只下载适合给定年龄
--download-archive FILE 				 仅下载未在存档文件。记录所有人的ID下载的视频在里面。
--include-ads 							 也下载广告

5.25下载选项

-r, --limit-rate RATE 					 最大下载速率(以字节为单位)秒(例如 50K 或 4.2M)
-R, --retries RETRIES 					 重试次数(默认为 10),或 “无穷”。
--fragment-retries RETRIES				 片段的重试次数(默认为 10)或“无限”(DASH,
                                         hlsnative 和 ISM)
--skip-unavailable-fragments 			 跳过不可用的片段(DASH,hlsnative 和 ISM)
--abort-on-unavailable-fragment 		 某些片段被中断时中止下载无法使用
--keep-fragments 						 将下载的片段保存在磁盘上下载完成;片段是默认擦除
--buffer-size SIZE 						 下载缓冲区的大小(例如 1024 或16K)(默认为 1024)
--no-resize-buffer 						 不自动调整缓冲区尺寸。默认情况下,缓冲区大小为
                                         从初始值自动调整大小的值。
--http-chunk-size SIZE 					 基于块的 HTTP 的块大小下载(例如 10485760 或 10M)
                                         (默认为禁用)。可能有用绕过带宽限制由网络服务器强加(实验性)
--playlist-reverse 						反向下载播放列表视频命令
--playlist-random 						随机下载播放列表视频命令
--xattr-set-filesize 					设置文件 xattribute ytdl.filesize预期文件大小
--hls-prefer-native 					使用本机 HLS 下载器ffmpeg 的
--hls-prefer-ffmpeg 					使用 ffmpeg 代替原生 HLS下载器
--hls-use-mpegts 						使用 mpegts 容器进行 HLS视频,允许播放视频
                                         下载时(有些玩家可能不会可以玩)
--external-downloader COMMAND 			使用指定的外部下载器。目前支持 aria2c,avconv,axel,c
                                         网址,ffmpeg,httpie,wget
--external-downloader-args ARGS 		将这些参数提供给外部下载器

5.26文件系统选项

-a, --batch-file FILE 					 包含要下载的 URL 的文件('-'
                                         对于标准输入),每行一个 URL。线条
                                         从...开始 '#'';'或者是
                                         被视为评论并被忽略。
--id 									 在文件名中仅使用视频ID
-o, --output TEMPLATE 					 输出文件名模板,见所有信息的“输出模板”
--output-na-placeholder PLACEHOLDER 	 不可用元的占位符值输出文件名模板中的字段
                                         (默认为“NA”)
--autonumber-start NUMBER 				 指定起始值%(自动编号)s (默认为 1)
--restrict-filenames 					 将文件名限制为仅 ASCII字符,并避免使用“&”和空格
                                         文件名
-w, --no-overwrites 					 不覆盖文件
-c, --continue 							 强制恢复部分下载文件。默认情况下,youtube-dl 将
                                         如果可能,继续下载。
--no-continue 							 不恢复部分下载文件(从头开始)
--no-part 								 不要使用 .part 文件 - 直接写入进入输出文件
--no-mtime 								 不要使用 Last-modified 标头设置文件修改时间
--write-description 					 将视频描述写入.description 文件
--write-info-json 						 将视频元数据写入 .info.json文件
--write-annotations 					 将视频注释写入.annotations.xml 文件
--load-info-json FILE 					 包含视频的 JSON 文件 信息(使用“--write-
                                         info-json" 选项)
--cookies FILE 							 读取和转储cookies
--cache-dir DIR 						 文件系统中的位置youtube-dl 可以存储一些下载的
                                         信息永久。默认 $XDG_CACHE_HOME/youtube-dl 或 ~/.cache
                                         /youtube-dl 。目前,只有YouTube 播放器文件(适用于带有 混淆签名)被缓存,但 这可能会改变。
--no-cache-dir 							 禁用文件系统缓存
--rm-cache-dir 							 删除所有文件系统缓存文件

5.27缩略图选项

--write-thumbnail 						 将缩略图图像写入磁盘
--write-all-thumbnails 					 将所有缩略图图像格式写入磁盘
--list-thumbnails 						 列出所有可用的缩略图格式

5.28 详细程度/模拟选项

-q, --quiet 							 激活安静模式
--no-warnings 							 忽略警告
-s, --simulate 							 不下载视频也不将任何内容写入磁盘
--skip-download 						 不下载视频
-g, --get-url 							 模拟,安静但打印 URL
-e, --get-title 						 模拟,安静但打印标题
--get-id 								 模拟,安静但打印 id
--get-thumbnail 						 模拟,安静但打印缩略图 URL
--get-description 						 模拟,安静但打印视频 描述
--get-duration 							 模拟,安静但打印视频长度
--get-filename 							 模拟,安静但打印输出文件名
--get-format 							 模拟,安静但打印输出格式
-j, --dump-json 						 模拟,安静但打印 JSON信息。请参阅“输出模板”
                                         有关可用密钥的说明。
-J, --dump-single-json 					 模拟,安静但打印 JSON每个命令行的信息
                                         争论。如果 URL 指向一个播放列表,转储整个播放列表
                                         信息在一行中。
--print-json 							 安静并打印视频JSON 格式的信息(视频仍然
                                         正在下载)。
--newline 								 将进度条输出为新行
--no-progress 							 不打印进度条
--console-title 						 在控制台标题栏中显示进度
-v, --verbose 							 打印各种调试信息
--dump-pages 							 打印使用编码的下载页面base64 来调试问题(非常冗长)
--write-pages 							 将下载的中间页面写入 当前目录下要调试的文件问题
--print-traffic 						 显示发送和读取的 HTTP 流量
-C, --call-home 						 联系 youtube-dl 服务器调试
--no-call-home 							 不要联系 youtube-dl 服务器用于调试

5.29工作环境选项

解决方法:
--encoding ENCODING 					 强制指定编码(实验性)
--no-check-certificate 					 禁止 HTTPS 证书验证
--prefer-insecure 						 使用未加密的连接检索有关视频的信息。
                                         (目前仅支持 YouTube)
--user-agent UA 						 指定自定义用户代理
--referer URL 							 指定一个自定义的referer,如果是
                                         视频访问仅限于一个领域
--add-header FIELD:VALUE 				 指定自定义 HTTP 标头及其
                                         值,用冒号 ':' 分隔。你可以多次使用此选项
--bidi-workaround 						 解决缺少的终端双向文本支持。需要
                                         PATH 中的 bidiv 或 fribidi 可执行文件
--sleep-interval SECONDS 				 每次之前休眠的秒数单独使用或更低时下载
                                         随机睡眠范围的界限每次下载之前(最少可能
                                         睡眠秒数)使用时连同 --max-sleep-interval。
--max-sleep-interval SECONDS 			 随机范围的上限每次下载前休眠(最大
                                         可能的睡眠秒数)。只能与 --min- 一起使用
                                         睡眠间隔。

5.30视频格式选项

-f, --format FORMAT 					 视频格式代码,见“FORMAT” SELECTION”获取所有信息
--all-formats 							 下载所有可用的视频格式
--prefer-free-formats 					 首选免费视频格式,除非要求具体的
-F, --list-formats 						 列出请求的视频所有可用格式
--youtube-skip-dash-manifest 			 不要下载 DASH 清单和YouTube 视频的相关数据
--merge-output-format FORMAT 			 如果需要合并(例如
                                         bestvideo+bestaudio),输出到给定
                                         容器格式。 mkv,mp4,ogg之一,
                                         韦姆湖如果没有合并则忽略必需的

5.31字幕选项

--write-sub 							  写入字幕文件
--write-auto-sub 						  写入自动生成的字幕文件(仅限 YouTube)
--all-subs 								  下载所有可用的字幕
--list-subs 							  列出所有可用的字幕
--sub-format FORMAT 					  字幕格式,接受格式偏好,例如:“srt”或
                                          “ass/srt/best”
--sub-lang LANGS 						  要下载的字幕语言(可选)用逗号分隔,使用
                                          --list-subs 可用的语言标签

5.32身份验证选项

-u, --username USERNAME 				 使用此帐户 ID 登录
-p, --password PASSWORD 				 帐户密码。 如果这个选项是漏掉了,youtube-dl 会问
                                         交互式地。
-2, --twofactor TWOFACTOR 				 双因素认证码
-n, --netrc 							 使用 .netrc 认证数据
--video-password PASSWORD 				 视频密码(vimeo、优酷)

5.33Adobe 通行证选项

--ap-mso MSO Adobe Pass 				 多系统操作员(电视 provider) 标识符,使用 --ap-list-mso
                                          获取可用 MSO 的列表
--ap-username USERNAME 					 多系统操作员账号登录
--ap-password PASSWORD 					 多系统操作员帐户密码。 如果省略此选项,
                                          youtube-dl 将以交互方式询问。
--ap-list-mso 							 列出所有支持的多系统运营商

5.34后处理选项

-x, --extract-audio 					 将视频文件转换为纯音频文件(需要 ffmpeg/avconv 和
                                         ffprobe/avprobe)
--audio-format FORMAT 					 指定音频格式:"best", "aac",
                                         “flac”、“mp3”、“m4a”、“opus”、“vorbis”、
                                         或“wav”;默认为“最佳”;没有效果没有 -x
--audio-quality QUALITY 				 指定 ffmpeg/avconv 音频质量,
                                         插入一个介于 0(更好)和 9 之间的值
                                         (更糟)对于 VBR 或特定比特率像 128K(默认 5)
--recode-video FORMAT 					 将视频编码为另一种格式,如果必要的(目前支持:
                                         mp4|flv|ogg|webm|mkv|avi)
--postprocessor-args ARGS 				 将这些参数提供给后处理器
-k, --keep-video 						 将视频文件保存在磁盘上后期处理;视频被删除默认
--no-post-overwrites 					 不覆盖后处理文件;后处理的文件是默认覆盖
--embed-subs 							 在视频中嵌入字幕(仅适用于mp4、webm 和 mkv 视频)
--embed-thumbnail 						 在音频中嵌入缩略图作为封面艺术
--add-metadata 							 将元数据写入视频文件
--metadata-from-title FORMAT 			 解析额外的元数据,如歌曲视频标题中的标题/艺术家。格式语法与
                                          - 输出。带有命名的正则表达式
                                         也可以使用捕获组。这 解析的参数替换现有的
                                         价值观。示例:--metadata-from-title
                                         "%(artist)s - %(title)s" 匹配一个
                                         像“酷玩 - 天堂”这样的标题。
                                         示例(正则表达式):--metadata-from-title
                                         “(?P<艺术家>.+?) - (?P<标题>.+)--xattrs 								 将元数据写入视频文件的xattrs(使用都柏林核心和 xdg
                                         标准)
--fixup POLICY 							 自动纠正已知故障文件。从不(什么都不做)之一,
                                         warn(仅发出警告),detect_or_warn(默认;修复文件
                                         如果可以,请另行警告)
--prefer-avconv 						 运行时首选 avconv 而不是 ffmpeg后处理器
--prefer-ffmpeg 						 优先使用 ffmpeg 而不是 avconv 来运行后处理器(默认)
--ffmpeg-location PATH ffmpeg/avconv 	 二进制文件的位置;二进制文件的路径或其包含目录。
--exec CMD 								 对文件执行命令后下载和后处理,
                                         类似于 find 的 -exec 语法。示例:--exec 'adb push {}
                                         /sdcard/Music/ && rm {}'
--convert-subs FORMAT 					 将字幕转换为其他格式(目前支持:srt|ass|vtt|lrc)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【最全】you-get和youtube-dl的安装和使用 的相关文章

  • 了解Web前端-1 Http基本原理

    HTTP基本原理 1 HTTP协议2 HTTP与Web服务器3 浏览器中的请求和响应1xx 信息2xx 成功3xx 重定向4xx 客户端错误5xx 服务器错误 1 HTTP协议 Hyper Text Transfer Protocol xf
  • 了解Web前端2-HTML语言

    HTML语言 1 什么是HTML2 了解HTML结构4 HTML的基本标签4 1 不是标签4 2 文件开始标签 96 96 4 3文件头部标签 96 96 4 4文件标题标签 96 96 4 5元信息标签 96 96 4 6页面的主体标签
  • 了解Web前端3-CSS层叠样式表

    CSS样式层叠表 1 CSS 概述2 属性选择器2 1属性选择器2 2属性和值选择器2 3属性和值的选择器 多值 3 类和ID选择器3 1ID选择器3 2类选择器3 3为特定元素使用class 1 CSS 概述 CSS是一种标记语言 xff
  • 了解Web前端4-JavaScript动态脚本语言

    JavaScript 动态脚本语言 1 页面中直接嵌入JavaScript代码2 连接外部JavaScript文件 JavaScript 是 web 开发人员必须学习的 3 门语言中的一门 xff1a HTML 定义了网页的内容CSS 描述
  • 爬虫の简介

    爬虫简介 一 什么是爬虫二 Python爬虫架构 一 什么是爬虫 爬虫 xff1a 一段自动抓取互联网信息的程序 xff0c 从互联网上抓取对于我们有价值的信息 二 Python爬虫架构 Python 爬虫架构主要由五个部分组成 xff0c
  • 一个不错的在线作图网站

    菜鸟教程的一个在线工具 连接 xff1a https c runoob com more shapefly diagram 优点 xff1a 没有广告 xff0c 不用关注微信公众号 xff0c 不用登陆 此外 xff0c 菜鸟还提供了其他
  • ABB机器人复习

    1 工业机器人最显著的特点 xff1a 2 工业气人的5种典型的结构 xff1a 3 认识示教器 xff1a 4 ABB机器人坐标系 xff1a 5 轴运动与线性运动 xff1a 1 轴运动 xff1a 2 线性运动 xff1a 6 重定位
  • step7basic的许可无法彻底完成

    安装博途并 后 xff0c 在项目中选择设备时可能会出现 xff1a step7basic的许可无法彻底完成 因为automation license manager中 的报错 原因 xff1a win10系统的更新 xff0c 导致软件不
  • 西门子学习第一章 S7-1200基础

    第一章 1 1 S7 1200系统概述 xff08 1 xff09 PLC 运用领域 xff08 2 xff09 S7 1200外观 xff08 3 xff09 西门子系列分类 1 2博途软件1 3 S7 1200系列PLC的硬件介绍 xf
  • 可见光的波长转换为RGB值颜色,光谱波长与RGBA分量,不同波长的光转换成不同的RGB值,JavaScript版本

    JS版本的光谱波长转换RGBA颜色值的方法 xff0c 在网上没找到 xff0c 后来领导发来一个C 43 43 版本的 xff0c 我对照着改为JS版 xff0c 有需要的朋友 可以参考 xff0c 代码如下 xff1a lt html
  • Modbus TCP Server端(附超全注释)

    实验项目名称 Modbus TCP实验 一 实验目的二 实验内容三 实验环境四 设计方案五 实验结果及分析 xff08 或设计总结 xff09 六 完整代码6 1 server c6 2 respond c6 3 respond h 开发语
  • ORB特征提取和匹配

    一 步骤二 代码三 部分结果展示3 1 使用Sobel算子且方向为vertical xff0c 进行边缘检测3 2 特征点提取 xff08 部分 xff09 3 3 特征点匹配 一 步骤 Step1 xff1a 读取彩色图片 1 新建实验用
  • windows下 Gitee(码云)使用

    1 注册Gitee并新建远程仓库2 初始化本地工作空间3 Git 全局设置 4 SSH公钥绑定5 提交文件到远程仓库 本文前提 xff1a 你已经在windows安装了git xff0c 如图所示 xff0c 关于git的安装 xff0c
  • 在 VS Code 中使用 Git

    1 VS Code安装2 在VS Code中登录Github账号3 Git 安装4 Git配置5 新建远程仓库并用命令行提交6 使用VSCode提交 1 VS Code安装 到vs code官网下载合适的版本并安装 2 在VS Code中登
  • 图像处理与机器视觉复习

    完整资源 xff1a GIthub链接 一 填空题 图像灰度均值 方差 图像的灰度平均值是平指灰度的平均水平 平均方差是衡量一个样本波动大小的量 xff0c 对图像来说 xff0c 平均方差反应的是图像高频部分的大小 方差小 xff0c 则
  • You-get && FFmpeg

    一 引言二 you get 介绍2 1 you get 安装2 2 you get语法及参数2 3 you get运用实例 三 FFmpeg介绍3 1 FFmpeg安装3 2 you get与FFmpeg的结合使用 四 HEVC 扩展 一
  • 一文读懂 主成分分析 与 因子分析

    2023 2 20更新 xff1a 修改了一些文字错误 xff0c 优化了排版 xff0c 增加了一些拓展内容 xff0c 祝大家学业有成 xff01 xff08 期待三连 x1f601 x1f601 xff09 目录 一 主成分分析二 因
  • Ubuntu 18.04 升级 20.04

    1 更换源2 安装所有更新包3 移除Ubuntu18 04上未用的旧包4 升级 鸿蒙开发要使用Ubuntu 20 04 及以上编译源码 xff0c 故将原来学习ROS 的Ubuntu18 04升级为20 04 1 更换源 好久没用这系统了
  • Ubuntu 20.04 update 报错 Problem executing scripts APT::Update

    报错内容 xff1a appstreamcli error span class token keyword while span loading shared libraries libxapian so 22 cannot span c
  • 解决Ubuntu20.04 开机黑屏光标闪烁进不去系统

    问题描述 xff1a 我是双系统 xff0c 原Ubuntu系统是18 04的 xff0c 使用命令行升级到20 04 xff0c 我搞到晚上2 xff1a 00 xff0c tnnd学校插座断电了 xff0c 大部分是升级好了 xff0c

随机推荐