Skip to content

Use session for HTTP requests in AMUniversal and USA Today downloaders#320

Open
clodpated wants to merge 1 commit intothisisparker:mainfrom
clodpated:fix/amuniversal-use-session
Open

Use session for HTTP requests in AMUniversal and USA Today downloaders#320
clodpated wants to merge 1 commit intothisisparker:mainfrom
clodpated:fix/amuniversal-use-session

Conversation

@clodpated
Copy link
Copy Markdown

Summary

  • AMUniversalDownloader.fetch_data() uses bare requests.get() instead of self.session.get(), bypassing the session's configured User-Agent header
  • The AMUniversal API (gamedata.services.amuniversal.com) returns 403 to the default python-requests User-Agent, making the Universal downloader fail
  • Same issue in USATodayDownloader.fetch_data() and USATodayDownloader.find_by_date() (requests.get() and requests.head())

Switching to self.session sends the xword-dl/VERSION User-Agent configured by BaseDownloader, which resolves the 403. This also brings these two downloaders in line with the pattern used by other downloaders (AmuseLabs, CrosswordCompiler, etc.) that already use self.session.

Changes

Three one-line changes in amuniversaldownloader.py:

Class Method Before After
AMUniversalDownloader fetch_data requests.get(solver_url) self.session.get(solver_url)
USATodayDownloader find_by_date requests.head(url) self.session.head(url)
USATodayDownloader fetch_data requests.get(solver_url) self.session.get(solver_url)

Test plan

  • Verified xword-dl uni successfully downloads Universal puzzle (previously returned 403)
  • Verified xword-dl usa still works correctly
  • Confirmed requests import is still needed (requests.HTTPError reference on line 138)

…oaders

AMUniversalDownloader.fetch_data() and USATodayDownloader.fetch_data()
and find_by_date() use bare requests.get()/requests.head() instead of
self.session, bypassing the session's configured User-Agent header.

The AMUniversal API (gamedata.services.amuniversal.com) returns 403 to
the default python-requests User-Agent. Using self.session sends the
xword-dl User-Agent configured by BaseDownloader, which resolves the
issue.

This also brings these downloaders in line with the pattern used by
other downloaders (AmuseLabs, CrosswordCompiler, etc.) that already
use self.session for their HTTP requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant