{"id":2274,"date":"2021-11-04T20:48:13","date_gmt":"2021-11-04T12:48:13","guid":{"rendered":"http:\/\/blog.zengqq.com.cn\/?p=2274"},"modified":"2022-09-18T12:35:55","modified_gmt":"2022-09-18T04:35:55","slug":"aria2-%e5%92%8c-youtube-dl%e4%ba%8c%e8%80%85%e5%90%88%e7%94%a8%e5%ae%8c%e6%88%90%e5%a4%9a%e7%ba%bf%e7%a8%8b%e4%b8%8b%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/blog.zengqq.com.cn\/?p=2274","title":{"rendered":"aria2 \u548c youtube-dl\u4e8c\u8005\u5408\u7528\u5b8c\u6210\u591a\u7ebf\u7a0b\u4e0b\u8f7d"},"content":{"rendered":"\n<p>\u5728\u56fd\u5185\u770b\u4e86\u4e00\u4e2aPython\u7684\u6559\u7a0b\uff0c\u6ca1\u60f3\u5230\u88ab\u9a97\u4e86\u3002\u662f\u4e2a\u4e8c\u9053\u8d29\u5b50\u91cd\u65b0\u538b\u5236\u7684\uff0c\u81ea\u5df1\u52a0\u4e86\u7247\u5934\u7247\u5c3e\uff0c\u7136\u540e\u5669\u68a6\u6765\u4e86\uff0c\u514818\u96c6\u9047\u5230\u7684\u662f\u58f0\u97f3\u4e0d\u5339\u914d\u59cb\u7ec8\u662f\u5dee\u4e00\u70b9\uff0c\u96be\u53d7\u7684\u8981\u6b7b\u3002\u540e\u9762\u5f00\u59cb\u5c31\u4ed6\u5988\u7684\u8fde\u58f0\u97f3\u4e5f\u6ca1\u6709\u4e86\uff0c\u53ea\u6709\u7247\u5934\u7684\u51e0\u79d2\u6709\u58f0\u97f3\u3002\u4e00\u70b9\u90fd\u4e0d\u4e0a\u5fc3\uff0c\u540e\u6765\u7167\u7740\u7247\u5934\u4e00\u627e\uff0c\u6211\u53bb\u8fde\u7f51\u7ad9\u90fd\u505c\u4e86\u3002\u7136\u540e\u627e\u8d44\u6e90\uff0c\u4e00\u770byoutube\u548cyouku\u4e0a\u9762\u90fd\u6709\uff0c\u5f00\u59cb\u5c1d\u8bd5\u4e0b\u8f7d\u4e0b\u6765\uff0cyouku\u7684\u6ca1\u6210\u529f\uff0cyoutube\u7684\u5012\u662f\u53ef\u4ee5\u5c31\u662f\u6162\u7684\u8981\u6b7b\u3002\u51e0\u7ecf\u641c\u7d22\u627e\u5230\u4e86\u5e94\u5bf9\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>###0x00 \u5b89\u88c5\u8f6f\u4ef6<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt-get install youtube-dl aria2\n<\/pre>\n\n\n\n<p>###0x01 \u539f\u7406\u4ecb\u7ecd \u8fd9\u91cc\u4f7f\u7528\u7684\u662faria2\u7684\u591a\u7ebf\u7a0b\u65b9\u5f0f\u6765\u4e0b\u8f7d\uff0c\u8fd8\u6709\u4e00\u70b9\u5c31\u662f\u5728\u6240\u6709\u7684youtube\u8d44\u6e90\u91cc\u9762\uff0c\u901f\u5ea6\u6700\u5feb\u7684\u662f\u753b\u8d28\u4e3abest\u7684\u90a3\u4e2a\u537322 \u770b\u4e0b\u9762\u7684\u4ecb\u7ecd\u3002<\/p>\n\n\n\n<p>youtube-dl\u7528\u6cd5<\/p>\n\n\n\n<p>\u67e5\u770b\u4f7f\u7528\u5e2e\u52a9<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">youtube-dl -h\n<\/pre>\n\n\n\n<p>\u4e00\u4e9b\u5e38\u7528\u7684\u53c2\u6570\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">youtube-dl --list-extractors  #\u67e5\u770b\u652f\u6301\u7f51\u7ad9\u5217\u8868\nyoutube-dl -U  #\u7a0b\u5e8f\u5347\u7ea7\nyoutube-dl --get-format URL #\u83b7\u53d6\u89c6\u9891\u683c\u5f0f\nyoutube-dl -F URL #\u83b7\u53d6\u6240\u6709\u683c\u5f0f\uff08\u76ee\u524d\u4ec5\u652f\u6301YouTube\uff09\uff0c\u4f8b\u5982\uff1a\nyoutube-dl -F https:\/\/www.youtube.com\/watch?v=nCfrfCzaB2A\n[youtube] Setting language\n[youtube] n-BXNXvTvV4: Downloading video webpage\n[youtube] n-BXNXvTvV4: Downloading video info webpage\n[youtube] n-BXNXvTvV4: Extracting video information\n\u683c\u5f0f\u7f16\u53f7\nformat code extension resolution  note\n171         webm      audio only  DASH audio , audio@ 48k (worst)\n140         m4a       audio only  DASH audio , audio@128k\n160         mp4       144p        DASH video , video only\n242         webm      240p        DASH video , video only\n133         mp4       240p        DASH video , video only\n243         webm      360p        DASH video , video only\n134         mp4       360p        DASH video , video only\n244         webm      480p        DASH video , video only\n135         mp4       480p        DASH video , video only\n247         webm      720p        DASH video , video only\n136         mp4       720p        DASH video , video only\n248         webm      1080p       DASH video , video only\n137         mp4       1080p       DASH video , video only\n271         webm      1440p       DASH video , video only\n264         mp4       1440p       DASH video , video only\n272         webm      2160p       DASH video , video only\n138         mp4       2160p       DASH video , video only\n100         webm      360p        3D\n82          mp4       360p        3D\n84          mp4       720p        3D\n17          3gp       176x144\n36          3gp       320x240\n5           flv       400x240\n43          webm      640x360\n18          mp4       640x360\n22          mp4       1280x720    (best)\n\n\u5982\u679c\u4f60\u60f3\u4e0b\u771f\u6b63\u7684\u6700\u9ad8\u753b\u8d28\u9700\u8981\u5206\u522b\u4e0b\u4e0a\u9762\u7684138\u548c140\uff0c\u7136\u540e\u7528\u89c6\u9891\u8f6f\u4ef6\u5408\u6210\u3002\n\u4e0b\u8f7d\u666e\u901a\u7684\u89c6\u9891\u53ea\u9700\u8981youtube-dl https:\/\/www.youtube.com\/watch?v=nCfrfCzaB2A \u9ed8\u8ba4\u4e0b\u8f7d\u4e0b\u6765\u7684\u683c\u5f0f\u4e3awebm\nyoutube-dl -f format URL #\u4e0b\u8f7d\u6307\u5b9a\u683c\u5f0f\u7684\u89c6\u9891\uff0c\u8fd9\u91cc\u4ee5\u4e0b\u8f7d1080p\u539f\u753b\u8d28\u91cf\u7684\u89c6\u9891\u683c\u5f0f\u4e3a\u4f8b:\nyoutube-dl -f 137 http:\/\/www.youtube.com\/watch?v=n-BXNXvTvV4\n\n\n\u6240\u4ee5\u8981\u4e0b\u8f7d\u6700\u5feb\u7684\u5c31\u5f97\u7528\u4e0b\u9762\u8fd9\u6837\u7684\u4f8b\u5b50\u8bb0\u4f4f\u8fd9\u4e2a`22`\nyoutube-dl -f 22 http:\/\/www.youtube.com\/watch?v=n-BXNXvTvV4\n<\/pre>\n\n\n\n<p>\u4e0b\u9762\u8bf4\u8bf4<code>aria2\u591a\u7ebf\u7a0b<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">youtube-dl    https:\/\/www.youtube.com\/***   --external-downloader aria2c --external-downloader-args \"-x 16  -k 1M\"\n\n\u53c2\u6570\u8bf4\u660e\n--external-downloader aria2c \/\/\u8c03\u7528\u5916\u90e8\u4e0b\u8f7d\u5de5\u5177\n--external-downloader-args \/\/\u5916\u90e8\u4e0b\u8f7d\u5de5\u5177\u6307\u5b9a\u53c2\u6570\n-x 16 \/\/\u542f\u7528aria2 16\u4e2a\u7ebf\u7a0b\uff0c\u6700\u591a\u5c31\u652f\u630116\u7ebf\u7a0b\n-K 1M \/\/\u6307\u5b9a\u5757\u7684\u5927\u5c0f\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u603b\u7ed3\">\u603b\u7ed3<a href=\"http:\/\/ivo-wang.github.io\/2018\/10\/06\/youtube-dl%E4%B8%8B%E8%BD%BD%E9%80%9F%E5%BA%A6%E6%85%A2%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95\/#%E6%80%BB%E7%BB%93\"><\/a><\/h3>\n\n\n\n<p>\u7efc\u4e0a\uff0c\u6700\u5feb\u7684\u65b9\u6cd5\u5c31\u662f\u7528\u4e0b\u9762\u7684\u8fd9\u4e2a\u547d\u4ee4\uff08\u5730\u5740\u90e8\u5206\u66ff\u6362\u6210\u81ea\u5df1\u7684\uff09<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> youtube-dl -f 22 https:\/\/www.youtube.com\/playlist\\?list\\=PLFx-dS8yeeGPPQAdpV6hiAqgi4Qzohcmk --external-downloader aria2c --external-downloader-args \"-x 16  -k 1M\"\n\n<\/pre>\n\n\n\n<p>\u5982\u679c\u4f7f\u7528\u4e86socks5\u7684\u4ee3\u7406\u8fd8\u53ef\u4ee5\u52a0\u4e0a\u4ee3\u7406<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> youtube-dl -f 22 --proxy 'socks5:\/\/127.0.0.1:1080'  https:\/\/www.youtube.com\/playlist\\?list\\=PLFx-dS8yeeGPPQAdpV6hiAqgi4Qzohcmk --external-downloader aria2c --external-downloader-args \"-x 16  -k 1M\"\n<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u97f3\u9891\u4e0b\u8f7dDownload Audio from YouTube<\/h1>\n\n\n\n<p><code>-i<\/code>&nbsp;&#8211; ignore errors<\/p>\n\n\n\n<p><code>-c<\/code>&nbsp;&#8211; continue<\/p>\n\n\n\n<p><code>-t<\/code>&nbsp;&#8211; use video title as file name<\/p>\n\n\n\n<p><code>--extract-audio<\/code>&nbsp;&#8211; extract audio track<\/p>\n\n\n\n<p><code>--audio-format mp3<\/code>&nbsp;&#8211; convert to mp3<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-highlight-color\"><code>--audio-quality 0<\/code>\u00a0&#8211; the best audio quality<\/mark><\/p>\n\n\n\n<p><code>--yes-playlist<\/code>&nbsp;&#8211; affirm that url points to a playlist<\/p>\n\n\n\n<p><code>YT_URL<\/code>&nbsp;&#8211; video url from youtube<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Download single entry \u7528\u6700\u9ad8\u54c1\u8d28\u5355\u6b21\u4e0b\u8f7d\nyoutube-dl -i --extract-audio --audio-format mp3 --audio-quality 0 YT_URL\n\n# Download playlist \u9ad8\u54c1\u8d28\u4e0b\u8f7d\u6574\u4e2a\u6b4c\u5355\nyoutube-dl -ict --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 https:\/\/www.youtube.com\/playlist?list=UUCvVpbYRgYjMN7mG7qQN0Pg\n\n# Download playlist, --download-archive downloaded.txt add successfully downloaded files into downloaded.txt \u4e0b\u8f7d\u201cdownload.txt\u201d\u4e2d\u7684\u6240\u6709\u6b4c\u66f2\nyoutube-dl --download-archive downloaded.txt --no-overwrites -ict --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 --socket-timeout 5 https:\/\/www.youtube.com\/playlist?list=UUCvVpbYRgYjMN7mG7qQN0Pg\n\n# Retry until success, no -i option\nwhile ! youtube-dl --download-archive downloaded.txt --no-overwrites -ct --yes-playlist --extract-audio --audio-forma<\/pre>\n\n\n\n<p>\u5728youtube-dl\u7684\u5168\u5c40\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\uff08\u9ed8\u8ba4\u6ca1\u6709\u6b64\u6587\u4ef6\uff0c\u8981\u81ea\u5df1\u5efa\uff0c\u4e8e\u662f\u81ea\u5df1vim\u4e00\u4e2a\uff09\uff0c\u6211\u7684\u914d\u7f6e\u5982\u4e0b:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo vim \/etc\/youtube-dl.conf\n#\u5185\u5bb9\u5982\u4e0b\uff1a\n# Lines starting with # are comments\n\n# Always extract audio\n#-x\n\n# Do not copy the mtime\n#--no-mtime\n\n# Use this proxy\n#--proxy 127.0.0.1:3128\n\n# External-downloader :ARIA2\n# Down load via external tool arai2c to expedite and gain a 16x download speed\n --external-downloader aria2c --external-downloader-args \"-x 16  -k 1M\"\n\n# Save all videos under Movies directory in your home directory\n-o ~\/Yt\/%(title)s.%(ext)s<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u56fd\u5185\u770b\u4e86\u4e00\u4e2aPython\u7684\u6559\u7a0b\uff0c\u6ca1\u60f3\u5230\u88ab\u9a97\u4e86\u3002\u662f [&#8230;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[253,249],"tags":[463,356,484,486,465,487,485,489,488,464],"class_list":{"0":"post-2274","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-fun","7":"category-technology","8":"tag-aria2","9":"tag-youtube","10":"tag-youtube-dl","11":"tag-mp3","13":"tag-487","14":"tag-485","15":"tag-489","16":"tag-488","17":"tag-464"},"_links":{"self":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/2274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2274"}],"version-history":[{"count":3,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/2274\/revisions"}],"predecessor-version":[{"id":3004,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/2274\/revisions\/3004"}],"wp:attachment":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}