ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.54k stars 10.05k forks source link

Can't seem to set up cookies #29834

Closed rusemode closed 2 years ago

rusemode commented 3 years ago

Checklist

Verbose log

C:\Users\Lenovo>youtube-dl -v --cookies ""\C:\Users\Lenovo\Downloads\youtube.com_cookies.txt"" -u ********** -p ******* https://m.youtube.com/watch?v=xH9FtFmYxOM
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--cookies', '\\C:\\Users\\Lenovo\\Downloads\\youtube.com_cookies.txt', '-u', 'PRIVATE', '-p', 'PRIVATE', 'https://m.youtube.com/watch?v=xH9FtFmYxOM']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.19041
[debug] exe versions: ffmpeg 2021-08-14-git-acd079843b-full_build-www.gyan.dev, ffprobe 2021-08-14-git-acd079843b-full_build-www.gyan.dev
[debug] Proxy map: {}
[youtube] Downloading login page
[youtube] Looking up account info
WARNING: Unable to look up account info: HTTP Error 400: Bad Request
[youtube] xH9FtFmYxOM: Downloading webpage
[youtube] xH9FtFmYxOM: Refetching age-gated info webpage
WARNING: unable to download video info webpage: HTTP Error 410: Gone
ERROR: Sign in to confirm your age
This video may be inappropriate for some users.
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 815, in wrapper
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 836, in __extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\common.py", line 534, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\youtube.py", line 1713, in _real_extract
youtube_dl.utils.ExtractorError: Sign in to confirm your age
This video may be inappropriate for some users.

Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 815, in wrapper
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 836, in __extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\common.py", line 534, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\youtube.py", line 1713, in _real_extract
youtube_dl.utils.ExtractorError: Sign in to confirm your age
This video may be inappropriate for some users.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\__init__.py", line 465, in _real_main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 2069, in download
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 808, in extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 824, in wrapper
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 628, in report_error
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 598, in trouble
youtube_dl.utils.DownloadError: ERROR: Sign in to confirm your age
This video may be inappropriate for some users.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "__main__.py", line 19, in <module>
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\__init__.py", line 475, in main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\__init__.py", line 468, in _real_main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 569, in __exit__
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\utils.py", line 2775, in save
OSError: [Errno 22] Invalid argument: '\\C:\\Users\\Lenovo\\Downloads\\youtube.com_cookies.txt'

Description

I followed different guides and setup the cookie.txt file but I can't seem to be able to login in order to download the link.

coletdjnz commented 3 years ago
  1. See the last error. You need to fix the path to your cookies file. I think it should be C:\Users\Lenovo\Downloads\youtube.com_cookies.txt
  2. Remove -u and -p, it doesn't work for YouTube.

Official guide for cookies is here for reference: https://github.com/ytdl-org/youtube-dl#how-do-i-pass-cookies-to-youtube-dl

rusemode commented 3 years ago
  1. See the last error. You need to fix the path to your cookies file. I think it should be C:\Users\Lenovo\Downloads\youtube.com_cookies.txt
  2. Remove -u and -p, it doesn't work for YouTube.

Official guide for cookies is here for reference: https://github.com/ytdl-org/youtube-dl#how-do-i-pass-cookies-to-youtube-dl

Ok, that worked, but now I have a different problem?

C:\Users\Lenovo>youtube-dl --cookies ""C:\Users\Lenovo\Downloads\youtube.com_cookies.txt"" https://m.youtube.com/watch?v=xH9FtFmYxOM [youtube] xH9FtFmYxOM: Downloading webpage [youtube] xH9FtFmYxOM: Downloading MPD manifest WARNING: Requested formats are incompatible for merge and will be merged into mkv. [dashsegments] Total fragments: 1044 [download] Destination: Io monaca per 3 carogne e 7 peccatrici (1972) FILM COMPLETO-xH9FtFmYxOM.f244.webm [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 1 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 2 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 3 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 4 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 5 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 6 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 7 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 8 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 9 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 10 of 10)... ERROR: giving up after 10 fragment retries

dirkf commented 3 years ago

See also #29811.

It's trying to download format 244 and according to this there is one (an alternative formulation using {"clientName":"ANDROID","clientScreen":"EMBED","clientVersion":"16.05"} doesn't list it, presumably listing formats suitable for mobile):

wget -O- -q --header='Content-Type: application/json' --header='X-Goog-Api-Key: AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8' --method=POST --body-data='{"context" :{"client":{"clientName": "WEB", "clientScreen": "EMBED", "clientVersion": "2.20210721.00.00"}}, "videoId": "xH9FtFmYxOM"}' 'https://www.youtube.com/youtubei/v1/player' | grep '"itag"'
        "itag": 18,
        "itag": 135,
        "itag": 244,
        "itag": 134,
        "itag": 243,
        "itag": 133,
        "itag": 242,
        "itag": 160,
        "itag": 278,
        "itag": 140,
        "itag": 249,
        "itag": 250,
        "itag": 251,
$

As you have the cookies, you can use -F (with the cookies) to list the available formats. From the above list, try format 135 (ie f 135):

        "mimeType": "video/mp4; codecs=\"avc1.4d401e\"",
        "bitrate": 3438815,
        "width": 640,
        "height": 480,

See #29832 for why the link listed in the YT API response for format 244 gives 404.

coletdjnz commented 3 years ago
  1. See the last error. You need to fix the path to your cookies file. I think it should be C:\Users\Lenovo\Downloads\youtube.com_cookies.txt
  2. Remove -u and -p, it doesn't work for YouTube.

Official guide for cookies is here for reference: https://github.com/ytdl-org/youtube-dl#how-do-i-pass-cookies-to-youtube-dl

Ok, that worked, but now I have a different problem?

C:\Users\Lenovo>youtube-dl --cookies ""C:\Users\Lenovo\Downloads\youtube.com_cookies.txt"" https://m.youtube.com/watch?v=xH9FtFmYxOM [youtube] xH9FtFmYxOM: Downloading webpage [youtube] xH9FtFmYxOM: Downloading MPD manifest WARNING: Requested formats are incompatible for merge and will be merged into mkv. [dashsegments] Total fragments: 1044 [download] Destination: Io monaca per 3 carogne e 7 peccatrici (1972) FILM COMPLETO-xH9FtFmYxOM.f244.webm [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 1 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 2 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 3 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 4 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 5 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 6 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 7 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 8 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 9 of 10)... [download] Got server HTTP error: HTTP Error 404: Not Found. Retrying fragment 1 (attempt 10 of 10)... ERROR: giving up after 10 fragment retries

This is a different issue that is not related to cookies. Related: https://github.com/ytdl-org/youtube-dl/issues/29404 https://github.com/ytdl-org/youtube-dl/issues/29395 https://github.com/yt-dlp/yt-dlp/issues/502

This is likely a server side issue.

rusemode commented 3 years ago

This is likely a server side issue.

I'm not familiar with this, but the problem was fixed by choosing a different format as dirkf last adviced.