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.22k stars 10.03k forks source link

Twitch asks to complete CAPTCHA even with cookies provided #16090

Closed heyhippari closed 6 years ago

heyhippari commented 6 years ago

Please follow the guide below


Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2018.04.03. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

Before submitting an issue make sure you have:

What is the purpose of your issue?


The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add the -v flag to your command line you run youtube-dl with (youtube-dl -v <your command line>), copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '--no-continue', '--no-overwrites', '--keep-video', '--no-post-overwrites', '--external-downloader', 'aria2c', '--external-downloader-args', '-c -j 3 -x 3 -s 3 -k 1M', '--cookies', '/home/mrtimscampi/cookies.txt', '--netrc', '--download-archive', '/mnt/unionfs/Videos/downloaded.txt', '--write-description', '--write-info-json', '--write-annotations', '--write-thumbnail', '--all-subs', '-i', '-o', '/mnt/unionfs/Videos/%(extractor_key)s/%(uploader)s/%(upload_date)s - %(title)s - (%(duration)ss) [%(resolution)s].%(ext)s', '-f', 'best', '--batch-file=/mnt/unionfs/Videos/channel_list.txt']
[debug] Batch file urls: [<redacted>]
[debug] Encodings: locale ISO-8859-1, fs iso8859-1, out ISO-8859-1, pref ISO-8859-1
[debug] youtube-dl version 2018.04.03
[debug] Python version 3.6.3 (CPython) - Linux-4.13.0-37-generic-x86_64-with-Ubuntu-17.10-artful
[debug] exe versions: ffmpeg 3.3.4-2, ffprobe 3.3.4-2, rtmpdump 2.4
[debug] Proxy map: {}
[twitch:videos:all] Downloading login page
[twitch:videos:all] Logging in
ERROR: Unable to login. Twitch said: Please complete the CAPTCHA correctly.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 519, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/YoutubeDL.py", line 2199, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/twitch.py", line 83, in login_step
    headers=headers)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 692, in _download_json
    encoding=encoding, data=data, headers=headers, query=query)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 634, in _download_webpage
    res = self._download_webpage_handle(url_or_request, video_id, note, errnote, fatal, encoding=encoding, data=data, headers=headers, query=query)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 539, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote, fatal, data=data, headers=headers, query=query)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 528, in _request_webpage
    raise ExtractorError(errmsg, sys.exc_info()[2], cause=err)
youtube_dl.utils.ExtractorError: Unable to download JSON metadata: HTTP Error 400: Bad Request (caused by <HTTPError 400: 'Bad Request'>); 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.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 519, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/YoutubeDL.py", line 2199, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/twitch.py", line 83, in login_step
    headers=headers)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 692, in _download_json
    encoding=encoding, data=data, headers=headers, query=query)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 634, in _download_webpage
    res = self._download_webpage_handle(url_or_request, video_id, note, errnote, fatal, encoding=encoding, data=data, headers=headers, query=query)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 539, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote, fatal, data=data, headers=headers, query=query)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 528, in _request_webpage
    raise ExtractorError(errmsg, sys.exc_info()[2], cause=err)
youtube_dl.utils.ExtractorError: Unable to download JSON metadata: HTTP Error 400: Bad Request (caused by <HTTPError 400: 'Bad Request'>); 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.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/YoutubeDL.py", line 785, in extract_info
    ie_result = ie.extract(url)
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 439, in extract
    self.initialize()
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/common.py", line 397, in initialize
    self._real_initialize()
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/twitch.py", line 56, in _real_initialize
    self._login()
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/twitch.py", line 111, in _login
    'password': password,
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/twitch.py", line 88, in login_step
    fail(response.get('message') or response['errors'][0])
  File "/usr/local/lib/python3.6/dist-packages/youtube_dl/extractor/twitch.py", line 65, in fail
    'Unable to login. Twitch said: %s' % message, expected=True)
youtube_dl.utils.ExtractorError: Unable to login. Twitch said: Please complete the CAPTCHA correctly.

If the purpose of this issue is a site support request please provide all kinds of example URLs support for which should be included (replace following example URLs by yours):

Note that youtube-dl does not support sites dedicated to copyright infringement. In order for site support request to be accepted all provided example URLs should not violate any copyrights.


Description of your issue, suggested solution and other information

While trying to download restricted VODs on Twitch, I noticed the error above despite passing a cookies.txt with proper Twitch cookies (I tried with multiple cookies.txt files, both from the headless server running this -using X Forwarding to login to Twitch using Firefox on that machine- and from my own machine).

dstftw commented 6 years ago

Solved captcha is not stored in cookies. If you use cookies use authenticated cookies and don't do explicit authentication.