pcubillos / bibmanager

A BibTeX manager for LaTeX projects
https://bibmanager.rtfd.io
MIT License
62 stars 13 forks source link

problem fetching older articles #118

Closed trentdupuy closed 5 months ago

trentdupuy commented 6 months ago

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.

pcubillos commented 6 months ago

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

pcubillos commented 6 months ago

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...

pcubillos commented 5 months ago

Solved by #120

pcubillos commented 5 months ago

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

trentdupuy commented 5 months ago

The test case I mentioned does indeed work now!