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

[redgifs] Failed to get Bearer token due to concatenation error #3080

Closed
slowthgt opened this issue Oct 20, 2022 · 1 comment
Closed

[redgifs] Failed to get Bearer token due to concatenation error #3080

slowthgt opened this issue Oct 20, 2022 · 1 comment

Comments

@slowthgt
Copy link

A follow-up from #3037

Tested with current release and latest CI.

Could be that the text.extract is not functioning properly?

[gallery-dl][debug] Version 1.23.3 - Executable
[gallery-dl][debug] Python 3.7.9 - Windows-10-10.0.19041
[gallery-dl][debug] requests 2.28.1 - urllib3 1.26.12
[gallery-dl][debug] Starting DownloadJob for 'https://redgifs.com/watch/foolishforkedabyssiniancat'
[redgifs][debug] Using RedgifsImageExtractor for 'https://redgifs.com/watch/foolishforkedabyssiniancat'
[redgifs][debug] Retrieving Bearer token
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.redgifs.com:443
[urllib3.connectionpool][debug] https://www.redgifs.com:443 "GET / HTTP/1.1" 200 None
[urllib3.connectionpool][debug] https://www.redgifs.com:443 "GET /assets/js/index.5da1b193.js HTTP/1.1" 200 None
[redgifs][error] An unexpected error occurred: TypeError - can only concatenate str (not "NoneType") to str. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[redgifs][debug]
Traceback (most recent call last):
  File "gallery_dl\job.pyc", line 82, in run
  File "gallery_dl\extractor\redgifs.pyc", line 36, in items
  File "gallery_dl\extractor\redgifs.pyc", line 127, in gifs
  File "gallery_dl\extractor\redgifs.pyc", line 137, in __init__
  File "gallery_dl\cache.pyc", line 115, in __call__
  File "gallery_dl\extractor\redgifs.pyc", line 182, in _fetch_bearer_token
TypeError: can only concatenate str (not "NoneType") to str
@chio0hai
Copy link
Contributor

It's just RedGifs changing their api again.

The following works for me:

--- a/gallery_dl/extractor/redgifs.py
+++ b/gallery_dl/extractor/redgifs.py
@@ -174,12 +174,7 @@ class RedgifsAPI():
     def _fetch_bearer_token(self, extr):
         extr.log.debug("Retrieving Bearer token")
 
-        page = extr.request(extr.root + "/").text
-        index = text.extract(page, "/assets/js/index", ".js")[0]
-
-        url = extr.root + "/assets/js/index" + index + ".js"
-        page = extr.request(url, encoding="utf-8").text
-        token = "ey" + text.extract(page, '="ey', '"')[0]
+        token = extr.request(self.API_ROOT + '/v2/auth/temporary').json()['token']
 
         extr.log.debug("Token: '%s'", token)
         return token

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

Successfully merging a pull request may close this issue.

3 participants