rero-invenio-thumbnails
RERO Invenio extension to discover book thumbnail URLs from multiple providers.
Features
- Multiple Providers: Chainable providers query external services in order and return the first available thumbnail URL
- Built-in Providers: FilesProvider (local files), GoogleBooksProvider, GoogleApiProvider, AmazonProvider, DnbProvider, BnfProvider, InternetArchiveProvider, OpenLibraryProvider
- Plugin Architecture: Extensible via entry points - register custom providers without modifying core code
- Smart Caching: Redis-based caching with configurable TTL
- RESTful API: JSON endpoint for thumbnail URL retrieval
Custom Providers
You can register custom thumbnail providers via entry points. Create a provider
that inherits from BaseProvider:
from rero_invenio_thumbnails.contrib.api import BaseProvider
class MyCustomProvider(BaseProvider):
def get_thumbnail_url(self, isbn):
# Your implementation here
url = f"https://example.com/covers/{isbn}.jpg"
return (url, "custom")
Register it in your pyproject.toml:
[project.entry-points."rero_invenio_thumbnails.providers"]
custom = "my_package.providers:MyCustomProvider"
Then reference it in your configuration:
RERO_INVENIO_THUMBNAILS_PROVIDERS = ["custom", "files", "open library"]
Quick start
Install:
pip install rero-invenio-thumbnails
Configure the providers and files dir in your application config:
# Provider configuration (optional - if not set, all discovered providers are used)
RERO_INVENIO_THUMBNAILS_PROVIDERS = [
"files",
"google books",
"google api",
"amazon",
"bnf",
"internet archive",
"open library",
]
# Files provider configuration
RERO_INVENIO_THUMBNAILS_FILES_DIR = "/path/to/thumbnails"
# Cache configuration
RERO_INVENIO_THUMBNAILS_CACHE_EXPIRE = 3600
DNB / MVB license requirement: The
dnbprovider is not enabled by default. Its cover images are sourced from VLB (Verzeichnis Lieferbarer Bücher, operated by MVB GmbH) and are subject to copyright. To enable it, add"dnb"to your instance-specificRERO_INVENIO_THUMBNAILS_PROVIDERSlist. A valid data licence agreement with MVB is required. Contact: kundenservice@mvb-online.de
Initialize the extension:
from rero_invenio_thumbnails import REROInvenioThumbnails
ext = REROInvenioThumbnails()
ext.init_app(app)
API
Get a thumbnail URL for an ISBN:
from rero_invenio_thumbnails.api import get_thumbnail_url
# Returns a tuple: (url, provider_name)
url, provider = get_thumbnail_url("9780134685991")
print(f"Found thumbnail at {url} from {provider}")
HTTP Endpoints
GET /thumbnails-url/<isbn> - Returns JSON with thumbnail URL
Returns JSON containing the thumbnail URL and provider name if found, or 404 if no thumbnail is available:
{
"url": "https://covers.openlibrary.org/b/isbn/9780134685991-L.jpg",
"isbn": "9780134685991",
"provider": "open library"
}
Example:
curl http://localhost/thumbnails-url/9780134685991
GET /thumbnails/<isbn> - Serves the actual thumbnail image file
Returns the thumbnail image file directly from local storage with appropriate MIME type (image/jpeg or image/png). Supports client-side caching with ETag and Last-Modified headers, along with conditional requests (If-None-Match, If-Modified-Since) returning 304 Not Modified when appropriate. Returns 404 if the file is not found.
Example:
# First request - returns 200 with ETag and Last-Modified headers
curl -v http://localhost/thumbnails/9780134685991 -o thumbnail.jpg
# Subsequent requests can use conditional headers for efficient caching
curl -H "If-None-Match: \"abc123...\"" http://localhost/thumbnails/9780134685991
Testing
Run the test-suite using the project's uv-based tooling:
uv sync
uv run poe run_tests
Contributing
Contributions are welcome. Please follow the repository CONTRIBUTING.md and
open pull requests against the staging branch.
Metadata
Release files for rero-invenio-thumbnails 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rero_invenio_thumbnails-2.0.1.tar.gz | 34.9 kB | Without provenance | Details for rero_invenio_thumbnails-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rero_invenio_thumbnails-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for rero_invenio_thumbnails-2.0.1-py3-none-any.whl |
Total release size: 84.8 kB
Release files / rero_invenio_thumbnails-2.0.1.tar.gz
| Download URL | rero_invenio_thumbnails-2.0.1.tar.gz |
|---|---|
| Size | 34.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d88e9c011c5910b9afc3fe844db3d4870566f2c34a50242fb0bce76e2f89dea
|
|
BLAKE2b-256 checksum How to use checksums |
7fc128b539c0931b9c85e22186c2ce0112eaebd5659766e982ae6856bca13e62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / rero_invenio_thumbnails-2.0.1-py3-none-any.whl
| Download URL | rero_invenio_thumbnails-2.0.1-py3-none-any.whl |
|---|---|
| Size | 49.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1625b70d2f82607996cc4a28da5b85f699b4e381964b794d35df51825006591b
|
|
BLAKE2b-256 checksum How to use checksums |
ff0fbf4180a2124263e62b36f8347b8dd638e3b94c605ac72e3db95fd9796b96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for rero-invenio-thumbnails 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.