Skip to content

feat(metadata): choose the Amazon store used by the Amazon provider - #1671

Open
privatepenguinzero wants to merge 1 commit into
crocodilestick:mainfrom
privatepenguinzero:feat/amazon-store-region
Open

privatepenguinzero wants to merge 1 commit into
crocodilestick:mainfrom
privatepenguinzero:feat/amazon-store-region

Conversation

@privatepenguinzero

Copy link
Copy Markdown

Choose the Amazon store for the Amazon metadata provider

Closes #1606.

The Amazon provider always searched amazon.com, so libraries in other languages only got English editions (titles, descriptions, covers). This adds an Amazon Store setting under the metadata provider settings, similar to the region option of the Amazon source in Calibre desktop.

Changes

  • New setting metadata_amazon_domain (TEXT, default 'com') in cwa_schema.sql. Existing installs get the column through the usual schema sync, and the default keeps today's behaviour.
  • Settings page: a store selector (amazon.com, .co.uk, .ca, .com.au, .in, .de, .fr, .it, .es, .nl, .com.br, .com.mx) below "Enabled Metadata Providers". Saved by the existing string-settings handler.
  • amazon.py:
    • search and product URLs use the selected store, with a matching Accept-Language header
    • unknown or invalid values fall back to amazon.com
    • the series bullet regex also matches localized text ("Libro 2 di 5", "Buch 2 von 5", "Tome 2 sur 5 :", ...)
    • absolute sponsored-ad links in search results are skipped (they were requested as https://www.amazon.com/https://... and returned 404)
  • Amazon Japan keeps its own provider (amazonjp), so co.jp isn't in the list.

Testing

  • New tests/unit/test_amazon_provider.py (18 tests): domain normalisation, localized series parsing, the search request using the configured store, and the fallback when the settings DB can't be read.
  • Live searches with the default com and with it / de: each returns that store's local editions, and com behaves as before.

The Amazon metadata provider was hardcoded to amazon.com, so books from
other countries only got English editions. Add a "Amazon Store" setting
(metadata_amazon_domain, default "com") to the metadata provider settings,
like the region option of the Amazon source in Calibre desktop.

- amazon.py: build search and product URLs from the selected store and send
  a matching Accept-Language header; unknown values fall back to amazon.com
- series bullet parsing also understands "Libro 2 di 5", "Buch 2 von 5",
  "Tome 2 sur 5"... used by non-English stores
- skip absolute sponsored-ad links in results (they produced 404s)
- unit tests for the domain setting, series parsing and request URL

Japan keeps its own provider (amazonjp). Refs crocodilestick#1606.
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.

[Feature Request] Allowing other regions in metadata providers (Amazon, Kobo, ...)

1 participant