24

When I try to download on of my private videos I get the following:

youtube-dl https://youtu.be/Q-xxxx-xxxx
[youtube] Q-xxxx-xxxx: Downloading webpage
[youtube] Q-xxxx-xxxx: Downloading video info webpage
WARNING: Unable to extract video title
ERROR: This video is unavailable.

When I try to use username and password it fails on my 2FA.

youtube-dl [email protected]  https://youtu.be/Q-xxxx-xxxx
Type account password and press [Return]: 
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
Type 2-step verification code and press [Return]: 
[youtube] Submitting TFA code
WARNING: Unable to submit TFA code: HTTP Error 400: Bad Request
[youtube] Q-xxxx-xxxx: Downloading webpage
[youtube] Q-xxxx-xxxx: Downloading video info webpage
WARNING: Unable to extract video title
ERROR: This video is unavailable.

If I try to use --cookies exported with EditThisCookie in Chrome then it also fails. I exported by going to the video in Chrome and copying the cookies into a file.

youtube-dl --cookies=cookies.txt  https://youtu.be/Q-xxxx-xxxx
Traceback (most recent call last):
  File "/usr/bin/youtube-dl", line 11, in <module>
    load_entry_point('youtube-dl==2018.6.14', 'console_scripts', 'youtube-dl')()
  File "/usr/lib/python3.6/site-packages/youtube_dl/__init__.py", line 472, in main
    _real_main(argv)
  File "/usr/lib/python3.6/site-packages/youtube_dl/__init__.py", line 439, in _real_main
    with YoutubeDL(ydl_opts) as ydl:
  File "/usr/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 414, in __init__
    self._setup_opener()
  File "/usr/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2303, in _setup_opener
    self.cookiejar.load()
  File "/usr/lib/python3.6/http/cookiejar.py", line 1784, in load
    self._really_load(f, filename, ignore_discard, ignore_expires)
  File "/usr/lib/python3.6/http/cookiejar.py", line 2007, in _really_load
    filename)
http.cookiejar.LoadError: 'cookies.txt' does not look like a Netscape format cookies fil

How can I download my private video with youtube-dl?

EDIT:

I also tried an app password but for some reason this also failed for me:

youtube-dl [email protected] --password=xxxxxxxxx youtu.be/Q-xxxxxxxx
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
WARNING: Unable to login: Invalid password
[youtube] Q-xxxxxx: Downloading webpage
[youtube] Q-xxxxxx: Downloading video info webpage
WARNING: Unable to extract video title
ERROR: This video is unavailable.
2

1 Answer 1

34

I was able to download private videos by using the --cookies route. I had to first format the cookies to Netscape format, which is an option in EditThisCookie. Remember you'll not only need the cookies for https://youtube.com but also for https://accounts.google.com. You'll have to do this manually with EditThisCookie Chrome plugin.

I then needed to fix the format of the cookies generated with EditThisCookie with curl. Something like: curl -b oldcookiefile.txt --cookie-jar newcookiefile.txt 'https://youtube.com'.

The --cookies flag can then be used with youtube-dl to download private videos.

I also created a blog post describing what I learned in more detail.

4
  • 11
    Use the "cookies.txt" chrome extension, it's easier :-) chrome.google.com/webstore/detail/cookiestxt/…
    – sekmo
    Oct 15, 2018 at 17:43
  • Brilliant, thanks Dave. I followed the other comment and used 'cookies.txt'. The went to youtube.com, hit the button for cookies.txt and saved all out. They only for youtube.com. The followed the rest of your blog post.
    – HankCa
    Dec 20, 2018 at 13:00
  • 3
    @sekmo: it may be easier, but browser extensions are a security and privacy risk. You can simply copy/paste the cookies from Chrome, then convert them to Netscape format. Mar 28, 2020 at 12:58
  • 1
    I have a slight challenge with downloading content which I have already paid for. I have tried multiple tools and the latest one that looks promising is youtube-dl. I managed to follow the cookies workaround to get the video to download (previously it was not logging in or downloading) however, after reviewing the downloaded video, the image is scrambled as well as the audio. That means that either its still not successfully authenticating, or its just not working. Has anyone run into this issue? I cant seem to find anything online and all signs point to this should be working. Apr 2, 2020 at 12:19

Not the answer you're looking for? Browse other questions tagged .