Youtube-dl

From XPUB & Lens-Based wiki

http://rg3.github.com/youtube-dl/

Upgrade frequently

Due to frequent changes to youtube (and other platforms youtube-dl supports), the software change frequently. Using pip you can upgrade your installation to the latest version by saying:

 pip3 install --upgrade youtube-dl

or (depending on your setup)

 sudo pip3 install --upgrade youtube-dl

Otherwise you'll see errors like the following.

[youtube] vP4iY1TtS3s: Downloading webpage
[youtube] vP4iY1TtS3s: Downloading video info webpage
ERROR: Signature extraction failed: Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/youtube_dl/extractor/youtube.py", line 1385, in _decrypt_signature
    video_id, player_url, s
  File "/usr/local/lib/python3.7/dist-packages/youtube_dl/extractor/youtube.py", line 1262, in _extract_signature_function
    raise ExtractorError('Cannot identify player %r' % player_url)
youtube_dl.utils.ExtractorError: Cannot identify player 'https://www.youtube.com/s/player/e3cd195e/player_ias.vflset/en_US/base.js'; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
 (caused by ExtractorError("Cannot identify player 'https://www.youtube.com/s/player/e3cd195e/player_ias.vflset/en_US/base.js'; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.")); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

Show and select particular formats

The command to show the list of available formats if -F. To then select a particular one to download use -f with the numeric code of the format.

 youtube-dl -F https://www.youtube.com/watch?v=vP4iY1TtS3s
[youtube] vP4iY1TtS3s: Downloading webpage
[youtube] vP4iY1TtS3s: Downloading js player e3cd195e
[youtube] vP4iY1TtS3s: Downloading js player e3cd195e
[info] Available formats for vP4iY1TtS3s:
format code  extension  resolution note
249          webm       audio only tiny   56k , opus @ 50k (48000Hz), 2.43MiB
250          webm       audio only tiny   67k , opus @ 70k (48000Hz), 3.11MiB
251          webm       audio only tiny  127k , opus @160k (48000Hz), 5.85MiB
140          m4a        audio only tiny  130k , m4a_dash container, mp4a.40.2@128k (44100Hz), 6.27MiB
278          webm       256x144    144p   97k , webm container, vp9, 24fps, video only, 4.56MiB
394          mp4        256x144    144p  100k , av01.0.00M.08, 24fps, video only, 4.14MiB
160          mp4        256x144    144p  110k , avc1.4d400c, 24fps, video only, 4.17MiB
242          webm       426x240    240p  227k , vp9, 24fps, video only, 8.44MiB
395          mp4        426x240    240p  232k , av01.0.00M.08, 24fps, video only, 8.14MiB
133          mp4        426x240    240p  244k , avc1.4d4015, 24fps, video only, 7.81MiB
396          mp4        640x360    360p  412k , av01.0.01M.08, 24fps, video only, 14.56MiB
243          webm       640x360    360p  413k , vp9, 24fps, video only, 14.95MiB
134          mp4        640x360    360p  632k , avc1.4d401e, 24fps, video only, 18.87MiB
397          mp4        854x480    480p  727k , av01.0.04M.08, 24fps, video only, 25.18MiB
244          webm       854x480    480p  760k , vp9, 24fps, video only, 22.78MiB
135          mp4        854x480    480p 1157k , avc1.4d401e, 24fps, video only, 34.14MiB
398          mp4        1280x720   720p 1490k , av01.0.05M.08, 24fps, video only, 49.98MiB
247          webm       1280x720   720p 1508k , vp9, 24fps, video only, 36.92MiB
136          mp4        1280x720   720p 2314k , avc1.4d401f, 24fps, video only, 58.30MiB
18           mp4        640x360    360p  611k , avc1.42001E, 24fps, mp4a.40.2@ 96k (44100Hz), 29.59MiB
22           mp4        1280x720   720p  702k , avc1.64001F, 24fps, mp4a.40.2@192k (44100Hz) (best)

To download the webm (audio only) 160k opus (code = 251)

   youtube-dl -f251 https://www.youtube.com/watch?v=vP4iY1TtS3s

Downloading manually added subtitles

 youtube-dl --skip-download --write-sub https://www.youtube.com/watch?v=vP4iY1TtS3s

Downloading only the automatically generated subtitles (in vtt format)

 youtube-dl --skip-download --write-auto-sub URL