Help us understand the problem. What is going on with this article?

youtube-dlを使いやすくするScript

More than 1 year has passed since last update.

youtube-dlが必要なのでInstall

$ pip install youtube-dl

youtube-dl公式site

youtube-dlを使いやすくするScript

youtube-dl-helper.py

Scriptを実行する事で作られるhistory.txt

これはDownload済みの動画のIDが記録された物で、これによって同じ動画を再び落とさずに済みます。

Downloadが上手くいかない時

品質を表す数値を直接指定してやる事で上手くいく場合がある。

品質を表す数値を列挙

$ youtube-dl --list-format <動画のIDもしくはURL>
コマンド例
$ youtube-dl --list-format _m6U18GE1CM
出力
[info] Available formats for _m6U18GE1CM:
format code  extension  resolution note
140          m4a        audio only DASH audio  129k , m4a_dash container, mp4a.40.2@128k (44100Hz)
160          mp4        256x144    DASH video  108k , avc1.4d400b, 6fps, video only
134          mp4        640x360    DASH video  200k , avc1.4d4016, 6fps, video only
133          mp4        426x240    DASH video  242k , avc1.4d400c, 6fps, video only
135          mp4        854x480    DASH video 1155k , avc1.4d4014, 6fps, video only
137          mp4        1920x1080  DASH video 1266k , avc1.640028, 6fps, video only
136          mp4        1280x720   DASH video 2310k , avc1.4d4016, 6fps, video only
17           3gp        176x144    small , mp4v.20.3,  mp4a.40.2@ 24k
36           3gp        320x180    small , mp4v.20.3,  mp4a.40.2
43           webm       640x360    medium , vp8.0,  vorbis@128k
18           mp4        640x360    medium , avc1.42001E,  mp4a.40.2@ 96k
22           mp4        1280x720   hd720 , avc1.64001F,  mp4a.40.2@192k (best)

品質を直接指定してDownload

上の出力を見ると最高画質は1920x1080で、その"format code"は137です。又"audio only"の付いた物は一つだけで、その"format code"は140です。なので

--format 137+140 --merge-output-format mkv

とする事で、最高品質がDownloadができます。

最後に

Youtube側の仕様変更に対応する為なのか、頻りに(月に数回)Versionアップしてるようです。今まで動いていたのが何故か動かなくなった時は、まずUpdateする事をお薦めします。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away