Skip to content

Fix compatibiity with calibre-web and standard ebooks#150

Open
mawise wants to merge 1 commit into
evan-buss:mainfrom
mawise:calibre-web-and-standard-ebooks
Open

Fix compatibiity with calibre-web and standard ebooks#150
mawise wants to merge 1 commit into
evan-buss:mainfrom
mawise:calibre-web-and-standard-ebooks

Conversation

@mawise

@mawise mawise commented May 21, 2026

Copy link
Copy Markdown

Fix OpenSearch descriptor fetching and resolution

The OPDS proxy previously attempted to fetch the OpenSearch descriptor at search time rather than during feed parsing. This failed on OPDS servers like calibre-web that required proxy authentication.

This commit shifts the OpenSearch descriptor fetching into the feed parsing pipeline (in serveAtom), so that the true search template URL is injected directly into the proxy's rendered HTML. It correctly fetches the OSD files passing along any required credentials or custom User-Agents configured for that feed.

Additionally, standard OPDS search queries are now cleanly supported by simply appending ?query= to non-OSD endpoints.

fix: support generic xml content types for opds feeds

Standard Ebooks serves their OPDS search results with a generic application/xml or text/xml content type rather than the standard application/atom+xml. This causes opds-proxy to treat the results as a regular file download instead of intercepting and rendering them via HTML templates.

This commit updates the FormatByMimeType mapping in formats.go to recognize application/xml and text/xml as ATOM feeds, ensuring these feeds are correctly processed and rendered. Actual book downloads (e.g., application/epub+zip) are unaffected.

Tests have been added to verify that FormatByMimeType correctly handles both standard and generic XML content types, as well as book download formats.

Update OpenSearch template parsing to prioritize acquisition types

Update ParseOpenSearchTemplate to first prefer templates with type="application/atom+xml;profile=opds-catalog;kind=acquisition". If not found, it falls back to standard OPDS types, then general Atom types, and finally any valid template as a last resort. Update tests accordingly to reflect the new priority.

fix(opds): use prefix match for acquisition links

Updates the link parsing logic to use strings.HasPrefix when checking the link relationship for acquisitions, supporting extensions like /open-access used in OPDS 1.2 tags. Also updates a test case to verify this behavior.

…andard ebooks' opds feeds

Fix OpenSearch descriptor fetching and resolution

The OPDS proxy previously attempted to fetch the OpenSearch descriptor at search time rather than during feed parsing. This failed on OPDS servers like calibre-web that required proxy authentication.

This commit shifts the OpenSearch descriptor fetching into the feed parsing pipeline (in `serveAtom`), so that the true search template URL is injected directly into the proxy's rendered HTML. It correctly fetches the OSD files passing along any required credentials or custom User-Agents configured for that feed.

Additionally, standard OPDS search queries are now cleanly supported by simply appending `?query=` to non-OSD endpoints.

fix: support generic xml content types for opds feeds

Standard Ebooks serves their OPDS search results with a generic
`application/xml` or `text/xml` content type rather than the standard
`application/atom+xml`. This causes opds-proxy to treat the results
as a regular file download instead of intercepting and rendering
them via HTML templates.

This commit updates the `FormatByMimeType` mapping in `formats.go`
to recognize `application/xml` and `text/xml` as ATOM feeds,
ensuring these feeds are correctly processed and rendered. Actual
book downloads (e.g., `application/epub+zip`) are unaffected.

Tests have been added to verify that `FormatByMimeType` correctly
handles both standard and generic XML content types, as well as
book download formats.

Update OpenSearch template parsing to prioritize acquisition types

Update `ParseOpenSearchTemplate` to first prefer templates with
`type="application/atom+xml;profile=opds-catalog;kind=acquisition"`.
If not found, it falls back to standard OPDS types, then general Atom
types, and finally any valid template as a last resort. Update tests
accordingly to reflect the new priority.

fix(opds): use prefix match for acquisition links

Updates the link parsing logic to use strings.HasPrefix when checking
the link relationship for acquisitions, supporting extensions like
/open-access used in OPDS 1.2 tags. Also updates a test case to
verify this behavior.
@mawise

mawise commented May 21, 2026

Copy link
Copy Markdown
Author

Hi,

I was excited when I came across your project! I had a couple issues fetching my authenticated calibre-web opds feed, and with the standard ebooks feed, so I resolved the incompatibilities. These changes are AI-assisted. I've got it running great on my fork, deployed and working for both opds sources.

No pressure to merge these changes if you don't want to. Thanks for your work!

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