差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン両方とも次のリビジョン | ||
python:youtube-dl [2020/01/27 17:53] – ともやん | python:youtube-dl [2021/05/29 13:06] – ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ~~CLOSETOC~~ | ||
====== youtube-dl - YouTube や他の動画サイトから動画をダウンロード ====== | ====== youtube-dl - YouTube や他の動画サイトから動画をダウンロード ====== | ||
+ | {{python: | ||
youtube-dl は、YouTube などの動画共有サービスから動画のダウンロードや音声の抽出を行うコマンドラインプログラムである。\\ | youtube-dl は、YouTube などの動画共有サービスから動画のダウンロードや音声の抽出を行うコマンドラインプログラムである。\\ | ||
Python で書かれているのでクロスプラットフォームである。Unlicense の下で配布されている。\\ | Python で書かれているのでクロスプラットフォームである。Unlicense の下で配布されている。\\ | ||
- | [[https:// | + | [[wpjp>Youtube-dl|youtube-dl - Wikipedia]] より\\ |
- | ===== ダウンロード ===== | + | ===== pip によるインストール ===== |
+ | **youtube-dl** CUI\\ | ||
+ | < | ||
+ | $ pip install youtybe-dl | ||
+ | </ | ||
+ | |||
+ | **youtube-dl-gui** GUI\\ | ||
+ | < | ||
+ | $ pip install youtube-dl-gui | ||
+ | </ | ||
+ | |||
+ | ===== ダウンロードによるインストール | ||
+ | [[windows: | ||
< | < | ||
$ git clone https:// | $ git clone https:// | ||
</ | </ | ||
+ | < | ||
+ | $ git clone https:// | ||
+ | </ | ||
+ | **youtube-dl-gui** のバイナリインストーラは以下からダウンロードできる。\\ | ||
+ | [[https:// | ||
+ | |||
+ | ===== ダウンロード形式の指定 ===== | ||
+ | **mp4** コンテナに最高画質/ | ||
+ | < | ||
+ | <WRAP prewrap 100%> | ||
+ | < | ||
+ | $ youtube-dl --format " | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [youtube] PQhWrgVWHXU: | ||
+ | [download] Destination: | ||
+ | [download] 100% of 101.66MiB in 00:18 | ||
+ | [download] Destination: | ||
+ | [download] 100% of 4.72MiB in 00:01 | ||
+ | [ffmpeg] Merging formats into " | ||
+ | Deleting original file 吉幾三「百年桜」MV(2020年4月29日発売)-PQhWrgVWHXU.f137.mp4 (pass -k to keep) | ||
+ | Deleting original file 吉幾三「百年桜」MV(2020年4月29日発売)-PQhWrgVWHXU.f140.m4a (pass -k to keep) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **m4a** コンテナに最高音質で音声のみ保存する。\\ | ||
+ | < | ||
+ | <WRAP prewrap 100%> | ||
+ | < | ||
+ | $ youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata https:// | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [youtube] mzGo1Ar-f1w: | ||
+ | [youtube] mzGo1Ar-f1w: | ||
+ | [youtube] mzGo1Ar-f1w: | ||
+ | [download] ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a has already been downloaded | ||
+ | [download] 100% of 3.90MiB | ||
+ | [ffmpeg] Correcting container in " | ||
+ | [ffmpeg] Adding metadata to ' | ||
+ | [ffmpeg] Converting thumbnail " | ||
+ | [atomicparsley] Adding thumbnail to " | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== 手動で形式を指定する場合 ==== | ||
+ | ダウンロード可能なフォーマットコードを調べる。\\ | ||
+ | **youtube-dl -F < | ||
+ | < | ||
+ | $ youtube-dl -F https:// | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [youtube] PQhWrgVWHXU: | ||
+ | [info] Available formats for PQhWrgVWHXU: | ||
+ | format code extension | ||
+ | 249 webm audio only tiny 54k , opus @ 50k (48000Hz), 1.79MiB | ||
+ | 250 webm audio only tiny 72k , opus @ 70k (48000Hz), 2.37MiB | ||
+ | 140 m4a audio only tiny 130k , m4a_dash container, mp4a.40.2@128k (44100Hz), 4.72MiB | ||
+ | 251 webm audio only tiny 140k , opus @160k (48000Hz), 4.65MiB | ||
+ | 394 mp4 256x144 | ||
+ | 278 webm | ||
+ | 160 mp4 256x144 | ||
+ | 395 mp4 426x240 | ||
+ | 242 webm | ||
+ | 133 mp4 426x240 | ||
+ | 396 mp4 640x360 | ||
+ | 243 webm | ||
+ | 134 mp4 640x360 | ||
+ | 397 mp4 854x480 | ||
+ | 244 webm | ||
+ | 135 mp4 854x480 | ||
+ | 398 mp4 1280x720 | ||
+ | 247 webm | ||
+ | 136 mp4 1280x720 | ||
+ | 248 webm | ||
+ | 399 mp4 1920x1080 | ||
+ | 137 mp4 1920x1080 | ||
+ | 18 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | フォーマットコードで形式を指定してダウンロードする。\\ | ||
+ | **youtube-dl -f <format code> < | ||
+ | < | ||
+ | $ youtube-dl -f 137 https:// | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [youtube] PQhWrgVWHXU: | ||
+ | [download] Destination: | ||
+ | [download] 100% of 101.66MiB in 00:23 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== トラブルシューティング ===== | ||
+ | |||
+ | ==== ERROR: AtomicParsley was not found. Please install. が発生する場合 ==== | ||
+ | <WRAP prewrap 100%> | ||
+ | < | ||
+ | $ youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata https:// | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [youtube] mzGo1Ar-f1w: | ||
+ | [youtube] mzGo1Ar-f1w: | ||
+ | [youtube] mzGo1Ar-f1w: | ||
+ | [download] Destination: | ||
+ | [download] 100% of 3.85MiB in 00:06 | ||
+ | [ffmpeg] Correcting container in " | ||
+ | [ffmpeg] Adding metadata to ' | ||
+ | [ffmpeg] Converting thumbnail " | ||
+ | ERROR: AtomicParsley was not found. Please install. | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Windows の場合は [[windows: | ||
+ | <WRAP prewrap 100%> | ||
+ | < | ||
+ | $ scoop install atomicparsley | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | Installing ' | ||
+ | AtomicParsley-win32-0.9.0.zip (438.9 KB) [================================================] 100% | ||
+ | Checking hash of AtomicParsley-win32-0.9.0.zip ... ok. | ||
+ | Extracting AtomicParsley-win32-0.9.0.zip ... done. | ||
+ | Linking ~\scoop\apps\atomicparsley\current => ~\scoop\apps\atomicparsley\0.9.0 | ||
+ | Creating shim for ' | ||
+ | ' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== HTTP Error 403: Forbidden が発生する場合 ==== | ||
+ | <WRAP prewrap 100%> | ||
+ | < | ||
+ | $ youtube-dl https:// | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [youtube] Hs-h6xmzaaU: | ||
+ | ERROR: unable to download video data: HTTP Error 403: Forbidden | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | youtube-dl のダウンロードキャッシュを削除する。\\ | ||
+ | < | ||
+ | $ youtube-dl --rm-cache-dir | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | Removing cache dir C: | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | キャッシュ削除後に再度ダウンロードしなおす。\\ | ||
+ | < | ||
+ | $ youtube-dl https:// | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [youtube] Hs-h6xmzaaU: | ||
+ | [youtube] Hs-h6xmzaaU: | ||
+ | [youtube] Hs-h6xmzaaU: | ||
+ | [download] Destination: | ||
+ | [download] 100% of 19.66MiB in 00:06 | ||
+ | [download] Destination: | ||
+ | [download] 100% of 4.46MiB in 00:01 | ||
+ | [ffmpeg] Merging formats into " | ||
+ | Deleting original file 高橋真梨子(たかはし まりこ) For You..( 歌詞付き).中日字幕.譚詠麟 霧之戀 - 原曲-Hs-h6xmzaaU.f248.webm (pass -k to keep) | ||
+ | Deleting original file 高橋真梨子(たかはし まりこ) For You..( 歌詞付き).中日字幕.譚詠麟 霧之戀 - 原曲-Hs-h6xmzaaU.f251.webm (pass -k to keep) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== 参考文献 ===== | ||
+ | [[https:// | ||
+ | [[https:// | ||