Skip to content

Fix BaseContent.get() ignoring the url property of subclasses - #110

Open
raffaelemancuso wants to merge 1 commit into
J535D165:mainfrom
raffaelemancuso:content_url_fix
Open

raffaelemancuso wants to merge 1 commit into
J535D165:mainfrom
raffaelemancuso:content_url_fix

Conversation

@raffaelemancuso

Copy link
Copy Markdown
Contributor

Problem

BaseContent.get() rebuilds the plain content URL from self.key instead of using the url property:

content_url = f"https://content.openalex.org/works/{self.key}"

But PDF and TEI exist precisely to override url with the .pdf / .grobid-xml variants — so work.pdf.get() and work.tei.get() (and their download()) silently fetch the generic work content instead of the format they advertise.

The existing test_work_pdf_and_tei_download doesn't catch this because it only asserts the downloaded files are non-empty, which the plain URL satisfies too.

Change

One line: get() now requests self.url, so each subclass downloads what its URL points at. Verified that BaseContent/PDF/TEI.get() now request …/works/W1, …/works/W1.pdf and …/works/W1.grobid-xml respectively.

🤖 Generated with Claude Code

get() rebuilt the plain content URL from self.key instead of using
self.url, so PDF.get() and TEI.get() fetched the generic work content
rather than the .pdf / .grobid-xml variants their url overrides point
at. Use self.url so subclasses download what their URL advertises.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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