pcubillos/bibmanager

problem fetching older articles

Closed this issue · 5 comments

I've noticed that articles in ADS that are older and have two PDF options - "ADS PDF" and "ADS Scanned" - seem to fail when I try to fetch them. Here's an example:

bibm ads-add 1995AJ....109..709A 1995AJ....109..709A -f

gives the following result for me:

Updated 1 existing entries.
Fetching PDF file from Journal website:
Traceback (most recent call last):
File "/Users/tdupuy/opt/anaconda3/bin/bibm", line 8, in <module>
sys.exit(main())
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/bibmanager/__main__.py", line 1296, in main
args.func(args)
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/bibmanager/__main__.py", line 369, in cli_ads_add
cli_fetch(args)
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/bibmanager/__main__.py", line 421, in cli_fetch
pm.fetch(bib.bibcode, filename)
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/bibmanager/pdf_manager/pdf_manager.py", line 378, in fetch
req = request_ads(bibcode, source='journal')
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/bibmanager/pdf_manager/pdf_manager.py", line 321, in request_ads
req = requests.get(query, headers=headers)
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 668, in send
history = [resp for resp in gen] if allow_redirects else []
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 668, in <listcomp>
history = [resp for resp in gen] if allow_redirects else []
File "/Users/tdupuy/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 165, in resolve_redirects
raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
requests.exceptions.TooManyRedirects: Exceeded 30 redirects.

Hi!, it looks like there was a change in the ADS API. I'll take a look this week. Thanks for letting me know.

Ahh, I think I understand. When I make the PDF request to ADS, instead of sending you directly to the PDF's URL it redirects you to a link (through the DOI) that will take you to the PDF.
The request call could not handle the redirect response, so it was trapped in a loop until it broke.
I hope I can find a solution in the next couple of days.

Also, like you said, it seems to happen only for older entries...

Solved by #120

Hi @trentdupuy
This issue should be solved by now (version 1.4.11). Let me know if it's working on your end

The test case I mentioned does indeed work now!