X Tutup
Skip to content

Add PDF/EPUB IA links to search.json providers for open access books#11731

Merged
cdrini merged 5 commits intointernetarchive:masterfrom
ronibhakta1:fix/opds-download
Feb 23, 2026
Merged

Add PDF/EPUB IA links to search.json providers for open access books#11731
cdrini merged 5 commits intointernetarchive:masterfrom
ronibhakta1:fix/opds-download

Conversation

@ronibhakta1
Copy link
Contributor

Closes ArchiveLabs/pyopds2_openlibrary#20

Refactor OPDs results to return Download links for IA books

Technical

Testing

{
  "metadata": {
    "title": "Robinson Crusoe",
    "type": "http://schema.org/Book",
    "language": ["en"],
    "author": [
      {
        "name": "Daniel Defoe",
        "links": [
          {
            "href": "http://localhost:8080/authors/OL18283A",
            "type": "text/html",
            "rel": "author"
          }
        ]
      }
    ],
    "numberOfPages": 403
  },
  "links": [
    {
      "href": "http://localhost:8080/opds/books/OL24152177M",
      "type": "application/opds-publication+json",
      "rel": "self"
    },
    {
      "href": "http://localhost:8080/books/OL24152177M",
      "type": "text/html",
      "rel": "alternate"
    },
    {
      "href": "http://localhost:8080/books/OL24152177M.json",
      "type": "application/json",
      "rel": "alternate"
    },
    {
      "href": "https://archive.org/details/cu31924011498676?view=theater&wrapper=false",
      "type": "text/html",
      "rel": "http://opds-spec.org/acquisition/open-access",
      "properties": {
        "availability": "available",
        "more": {
          "href": "https://archive.org/services/loans/loan/?action=webpub&identifier=cu31924011498676&opds=1",
          "rel": "http://opds-spec.org/acquisition/",
          "type": "application/opds-publication+json"
        }
      }
    },
    {
      "href": "https://archive.org/download/cu31924011498676/cu31924011498676.pdf",
      "type": "application/pdf",
      "rel": "http://opds-spec.org/acquisition/open-access",
      "properties": {
        "availability": "available",
        "more": {
          "href": "https://archive.org/services/loans/loan/?action=webpub&identifier=cu31924011498676&opds=1",
          "rel": "http://opds-spec.org/acquisition/",
          "type": "application/opds-publication+json"
        }
      }
    },
    {
      "href": "https://archive.org/download/cu31924011498676/cu31924011498676.epub",
      "type": "application/epub+zip",
      "rel": "http://opds-spec.org/acquisition/open-access",
      "properties": {
        "availability": "available",
        "more": {
          "href": "https://archive.org/services/loans/loan/?action=webpub&identifier=cu31924011498676&opds=1",
          "rel": "http://opds-spec.org/acquisition/",
          "type": "application/opds-publication+json"
        }
      }
    }
  ]
}

Screenshot

Stakeholders

@mekarpeles @MarcCoquand

Copilot AI review requested due to automatic review settings January 24, 2026 14:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Internet Archive provider so that OPDS results include direct download links (PDF/EPUB) for open-access IA books, aligning the API with the behavior shown in the linked issue and example payload.

Changes:

  • Refactors InternetArchiveProvider.get_acquisitions to always create a primary “web” acquisition and, for open-access items, append additional acquisitions for direct PDF/EPUB downloads.
  • Introduces _get_ia_download_files, which uses cached ia.get_metadata() to derive available IA file names and select appropriate .pdf and .epub assets.
  • Leaves the global get_acquisitions(solr_edition, edition) dispatcher compatible while ensuring IA acquisitions now expose richer download options used downstream in OPDS responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MarcCoquand
Copy link
Contributor

Hey @cdrini @mekarpeles , any chance we can get this merged? I'd like to have it ready to show to Brewster on Thursday, and setup so it uses the PRs service.

@cdrini
Copy link
Collaborator

cdrini commented Feb 13, 2026

Hi @ronibhakta1 ! Apologies for the delay. This is making direct individual network requests for every search result, which is too much of a performance hit I'm afraid. Let's instead assume that for open access materials, pdf/epubs will always be present at the default paths, and let's see how that works as a heuristic.

@ronibhakta1
Copy link
Contributor Author

Hi @ronibhakta1 ! Apologies for the delay. This is making direct individual network requests for every search result, which is too much of a performance hit I'm afraid. Let's instead assume that for open access materials, pdf/epubs will always be present at the default paths, and let's see how that works as a heuristic.

Sounds great to me. I will work on the changes and get it resolved by tomorrow for you to review this again.

@ronibhakta1
Copy link
Contributor Author

@cdrini I have made the changes required you are good to go!

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Feb 14, 2026
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdrini cdrini changed the title Fix/opds download Add PDF/EPUB IA links to search.json providers for open access books Feb 23, 2026
@cdrini cdrini merged commit 878d29a into internetarchive:master Feb 23, 2026
4 checks passed
@cdrini cdrini removed the Needs: Response Issues which require feedback from lead label Feb 23, 2026
@RayBB RayBB removed the On Testing label Mar 1, 2026
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.

Include download links for open access books

6 participants

X Tutup