Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Crunchyroll] ERROR: Wrong login info: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop. #17190

Open
justLetMeSubmitABugReport opened this issue Aug 9, 2018 · 8 comments

Comments

@justLetMeSubmitABugReport
Copy link

@justLetMeSubmitABugReport justLetMeSubmitABugReport commented Aug 9, 2018

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like this: [x])
  • Use the Preview tab to see what your issue will actually look like

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

  • I've verified and I assure that I'm running youtube-dl 2018.08.04

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones
  • Checked that provided video/audio/playlist URLs (if any) are alive and playable in a browser

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

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 ```):

user@laptop ~ $ youtube-dl http://www.crunchyroll.com/my-hero-academia/episode-54-shiketsu-high-lurking-775773 -u USERNAME -p PASSWORD -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'http://www.crunchyroll.com/my-hero-academia/episode-54-shiketsu-high-lurking-775773', u'-u', u'PRIVATE', u'-p', u'PRIVATE', u'-v']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.08.04
[debug] Python version 2.7.12 (CPython) - Linux-4.4.0-34-generic-x86_64-with-LinuxMint-18-sarah
[debug] exe versions: ffmpeg 2.8.14-0ubuntu0.16.04.1, ffprobe 2.8.14-0ubuntu0.16.04.1, rtmpdump 2.4
[debug] Proxy map: {}
[Crunchyroll] Logging in
ERROR: Wrong login info: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Moved Temporarily (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 599, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2211, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 467, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 654, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 467, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 654, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 467, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 654, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 467, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 654, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 467, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 644, in http_error_302
    self.inf_msg + msg, headers, fp)
...
<end of log>


Description of your issue, suggested solution and other information

The username and password is correct, but it says "Wrong login info". This was working fine as of July 27th, but now I am unable to download anything from Crunchyroll.

It looks like this same issue is referenced here: #17116 (comment)

I haven't tested the fix mentioned in that comment, but it would be nice if youtube-dl could be updated to officially fix the issue. Thank you.

@bato3
Copy link
Contributor

@bato3 bato3 commented Aug 9, 2018

The reason is the lack of the fail_url parameter in the logging function.

@noobmagnet
Copy link

@noobmagnet noobmagnet commented Aug 16, 2018

Getting this error on version 2018.08.04

@nascalsn
Copy link

@nascalsn nascalsn commented Sep 29, 2018

Getting this error on version 2018.09.26

@nascalsn
Copy link

@nascalsn nascalsn commented Oct 5, 2018

Getting this error on version 2018.10.05

@ytdl-org ytdl-org locked and limited conversation to collaborators Oct 5, 2018
@ytdl-org ytdl-org unlocked this conversation Jan 23, 2019
@shinji257
Copy link

@shinji257 shinji257 commented Jan 24, 2019

Please only contribute in this thread (don't just issue bump) please!

Known working workaround: Supply a cookies file rather than having Youtube-DL login for you. This seems to work until the script can be fixed to login properly.

Anyways I did some digging on this issue. It looks like the issue is here during the CrunchyRoll login.

crunchyroll.py -- Line 59-67

    def _login(self):
        username, password = self._get_login_info()
        if username is None:
            return

        self._download_webpage(
            'https://www.crunchyroll.com/?a=formhandler',
            None, 'Logging in', 'Wrong login info',
            data=urlencode_postdata({
                'formname': 'RpcApiUser_Login',
                'next_url': 'https://www.crunchyroll.com/acct/membership',
                'name': username,
                'password': password,
            }))

When I attempt to run that url manually even the browser shows 302 redirects happening in a loop which it eventually halts. This looks like a change on CrunchyRoll ends for how the authentication should be happening. What I'm not understanding is why it works fine for Windows and not on Linux since authentication would be happening the same way for both.

Changing the parameters doesn't seem to work... yet.

Watching headers shows the login form is posting the following parameters back to itself (I think).
login_form[name] (username)
login_form[password] (password)
login_form[redirect_url] (redirect url)
login_form[_token] (a seemingly random token -- it changes each load)

As of right now changing the parameters at the function noted above stops the 302 loop but also doesn't login successfully.

EDIT: Fixed and changed the post url to https://www.crunchyroll.com/login and now getting 503 which means CloudFlare is getting in the way.

EDIT2: Implemented cfscrape as per a pull request for testing but it is still failing so I'm doing something wrong. I don't know what. As of right now documentation doesn't build but I'm just doing make youtube-dl instead since I'm just trying to get it working again.

@bato3
Copy link
Contributor

@bato3 bato3 commented Jan 25, 2019

@shinji257 You use requests.Session to get login page. But you import only CloudFlare cookies. I'm thinking, that you should import crunchy session. You get login_form[_token] in different session that you send it.

BTW:

  1. RpcApiUser_Login for some users works OK, but crunchyroll.com/login always raise cf-challenge. Your changes disable login feature for all users without cfscrape.
  2. Why you run cfscrape before checking is username provided?
  3. Use login_form = self._form_hidden_inputs(self._LOGIN_FORM, page) instead BeautifulSoup
  4. Are you aware that you are not checking if you logged in correctly?
  5. Is it possible that requests.Session stores the last response? (In scraper.get_token you get login form, but in next line you get it again)
  6. Sometimes I had problems when I tried to log in and I had an active session from a previous call (--cookie=cookie.txt). And if you download the login page anyway, you should check if you are logged in. (If you do not do it, you may not get the login form and _token)
  7. You make some strange changes in README.md, please revoke it ;)
@shinji257
Copy link

@shinji257 shinji257 commented Jan 25, 2019

@shinji257 You use requests.Session to get login page. But you import only CloudFlare cookies. I'm thinking, that you should import crunchy session. You get login_form[_token] in different session that you send it.

Yea.... I thought about that and I still need to figure things out on that. As mentioned later on it is ideal that we grab everything in one go otherwise I believe that is one reason why login isn't working.

BTW:

1. `RpcApiUser_Login` for some users works OK, but `crunchyroll.com/login` always raise cf-challenge. Your changes disable login feature for all users without `cfscrape`.

This is very much a work in progress. For RpcApiUser_Login I found that the method is what was causing the 302 loop to happen. Even in a browser when I try to push it through it fails to do so. If we can figure out why it fails like this for some people then that would probably be a better route anyways. Who knows... maybe I'm off the mark here and the issue actually lies elsewhere.

I do wonder if there is a better way. Currently cfscrape breaks one of the documentation build steps in the Makefile for unknown reasons so I'll probably go back and investigate another way to deal with this.

2. Why you run cfscrape before checking is `username` provided?

I mirrored my cfscrape to an existing implementation already as a pull request here. I have not tweaked it much right now. Ummm.... #11730

3. Use `login_form = self._form_hidden_inputs(self._LOGIN_FORM, page)` instead `BeautifulSoup`

Noted. I used BeautifulSoup because that's what I'm familiar with and I'm just trying to get a working implementation right now to get past the weird 302 loop normally.

4. Are you aware that you are not checking if you logged in correctly?

Nope. That's what I'm trying to figure out.

5. Is it possible that `requests.Session` stores the last response? (In `scraper.get_token` you get login form, but in next line you get it again)

This is very much a work in progress. I don't really program Python and I'm just trying to see if I can get something roughly working.

6. Sometimes I had problems when I tried to log in and I had an active session from a previous call (`--cookie=cookie.txt`). And if you download the login page anyway, you should check if you are logged in. (If you do not do it, you may not get the login form and `_token`)

Hmm.... Interesting.

7. You make some [strange changes](https://github.com/shinji257/youtube-dl/commit/db6228a679b749bc3139d343788789aa5b0cf5b8) in `README.md`, please revoke it ;)

Heh. That was from me running make. The Makefile rebuilds all the .md files so it changed that file for some reason. I don't know why and didn't notice it until I had already committed it. To be honest I have not issued a pull request and won't do so until I'm comfortable with it. I put it up as a public fork so I don't lose "progress". Regardless when I'm done (and this is assuming I'm even successful) what I'll probably do is cleanup by re-pulling a fresh copy of your fork and reapplying there.

As for cfscrape.... The login route is what I'm seeing others using based on what I've seen but they also just grab the whole thing at once with cfscrape.get() and work from there then dump as a cookies file before invoking the actual script and including the cookies with it. Basically what I'm doing except I'm just dumping cookies from my browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
@bato3 @shinji257 @remitamine @noobmagnet @justLetMeSubmitABugReport @nascalsn and others
You can’t perform that action at this time.