jaquette 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jaquette-0.1.0/LICENSE +133 -0
- jaquette-0.1.0/PKG-INFO +207 -0
- jaquette-0.1.0/README.md +194 -0
- jaquette-0.1.0/pyproject.toml +56 -0
- jaquette-0.1.0/pyproject.toml.orig +56 -0
- jaquette-0.1.0/src/jaquette/__init__.py +42 -0
- jaquette-0.1.0/src/jaquette/cli.py +86 -0
- jaquette-0.1.0/src/jaquette/clients.py +573 -0
- jaquette-0.1.0/src/jaquette/exceptions.py +56 -0
- jaquette-0.1.0/src/jaquette/models.py +158 -0
- jaquette-0.1.0/src/jaquette/py.typed +0 -0
jaquette-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
Required Notice: Copyright (c) 2026 Martin TOUZOT
|
|
2
|
+
|
|
3
|
+
# PolyForm Noncommercial License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree
|
|
10
|
+
to them as both strict obligations and conditions to all
|
|
11
|
+
your licenses.
|
|
12
|
+
|
|
13
|
+
## Copyright License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a copyright license for the
|
|
16
|
+
software to do everything you might do with the software
|
|
17
|
+
that would otherwise infringe the licensor's copyright
|
|
18
|
+
in it for any permitted purpose. However, you may
|
|
19
|
+
only distribute the software according to [Distribution
|
|
20
|
+
License](#distribution-license) and make changes or new works
|
|
21
|
+
based on the software according to [Changes and New Works
|
|
22
|
+
License](#changes-and-new-works-license).
|
|
23
|
+
|
|
24
|
+
## Distribution License
|
|
25
|
+
|
|
26
|
+
The licensor grants you an additional copyright license
|
|
27
|
+
to distribute copies of the software. Your license
|
|
28
|
+
to distribute covers distributing the software with
|
|
29
|
+
changes and new works permitted by [Changes and New Works
|
|
30
|
+
License](#changes-and-new-works-license).
|
|
31
|
+
|
|
32
|
+
## Notices
|
|
33
|
+
|
|
34
|
+
You must ensure that anyone who gets a copy of any part of
|
|
35
|
+
the software from you also gets a copy of these terms or the
|
|
36
|
+
URL for them above, as well as copies of any plain-text lines
|
|
37
|
+
beginning with `Required Notice:` that the licensor provided
|
|
38
|
+
with the software. For example:
|
|
39
|
+
|
|
40
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
41
|
+
|
|
42
|
+
## Changes and New Works License
|
|
43
|
+
|
|
44
|
+
The licensor grants you an additional copyright license to
|
|
45
|
+
make changes and new works based on the software for any
|
|
46
|
+
permitted purpose.
|
|
47
|
+
|
|
48
|
+
## Patent License
|
|
49
|
+
|
|
50
|
+
The licensor grants you a patent license for the software that
|
|
51
|
+
covers patent claims the licensor can license, or becomes able
|
|
52
|
+
to license, that you would infringe by using the software.
|
|
53
|
+
|
|
54
|
+
## Noncommercial Purposes
|
|
55
|
+
|
|
56
|
+
Any noncommercial purpose is a permitted purpose.
|
|
57
|
+
|
|
58
|
+
## Personal Uses
|
|
59
|
+
|
|
60
|
+
Personal use for research, experiment, and testing for
|
|
61
|
+
the benefit of public knowledge, personal study, private
|
|
62
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
63
|
+
observance, without any anticipated commercial application,
|
|
64
|
+
is use for a permitted purpose.
|
|
65
|
+
|
|
66
|
+
## Noncommercial Organizations
|
|
67
|
+
|
|
68
|
+
Use by any charitable organization, educational institution,
|
|
69
|
+
public research organization, public safety or health
|
|
70
|
+
organization, environmental protection organization,
|
|
71
|
+
or government institution is use for a permitted purpose
|
|
72
|
+
regardless of the source of funding or obligations resulting
|
|
73
|
+
from the funding.
|
|
74
|
+
|
|
75
|
+
## Fair Use
|
|
76
|
+
|
|
77
|
+
You may have "fair use" rights for the software under the
|
|
78
|
+
law. These terms do not limit them.
|
|
79
|
+
|
|
80
|
+
## No Other Rights
|
|
81
|
+
|
|
82
|
+
These terms do not allow you to sublicense or transfer any of
|
|
83
|
+
your licenses to anyone else, or prevent the licensor from
|
|
84
|
+
granting licenses to anyone else. These terms do not imply
|
|
85
|
+
any other licenses.
|
|
86
|
+
|
|
87
|
+
## Patent Defense
|
|
88
|
+
|
|
89
|
+
If you make any written claim that the software infringes or
|
|
90
|
+
contributes to infringement of any patent, your patent license
|
|
91
|
+
for the software granted under these terms ends immediately. If
|
|
92
|
+
your company makes such a claim, your patent license ends
|
|
93
|
+
immediately for work on behalf of your company.
|
|
94
|
+
|
|
95
|
+
## Violations
|
|
96
|
+
|
|
97
|
+
The first time you are notified in writing that you have
|
|
98
|
+
violated any of these terms, or done anything with the software
|
|
99
|
+
not covered by your licenses, your licenses can nonetheless
|
|
100
|
+
continue if you come into full compliance with these terms,
|
|
101
|
+
and take practical steps to correct past violations, within
|
|
102
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
103
|
+
end immediately.
|
|
104
|
+
|
|
105
|
+
## No Liability
|
|
106
|
+
|
|
107
|
+
***As far as the law allows, the software comes as is, without
|
|
108
|
+
any warranty or condition, and the licensor will not be liable
|
|
109
|
+
to you for any damages arising out of these terms or the use
|
|
110
|
+
or nature of the software, under any kind of legal claim.***
|
|
111
|
+
|
|
112
|
+
## Definitions
|
|
113
|
+
|
|
114
|
+
The **licensor** is the individual or entity offering these
|
|
115
|
+
terms, and the **software** is the software the licensor makes
|
|
116
|
+
available under these terms.
|
|
117
|
+
|
|
118
|
+
**You** refers to the individual or entity agreeing to these
|
|
119
|
+
terms.
|
|
120
|
+
|
|
121
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
122
|
+
or other kind of organization that you work for, plus all
|
|
123
|
+
organizations that have control over, are under the control of,
|
|
124
|
+
or are under common control with that organization. **Control**
|
|
125
|
+
means ownership of substantially all the assets of an entity,
|
|
126
|
+
or the power to direct its management and policies by vote,
|
|
127
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
128
|
+
|
|
129
|
+
**Your licenses** are all the licenses granted to you for the
|
|
130
|
+
software under these terms.
|
|
131
|
+
|
|
132
|
+
**Use** means anything you do with the software requiring one
|
|
133
|
+
of your licenses.
|
jaquette-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jaquette
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Unofficial Python client for the public MyBluray API (cover art and title search).
|
|
5
|
+
Author: Martin TOUZOT
|
|
6
|
+
Author-email: Martin TOUZOT <mtouzot@proton.me>
|
|
7
|
+
License-Expression: PolyForm-Noncommercial-1.0.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: httpx>=0.28.1
|
|
10
|
+
Requires-Dist: pydantic>=2.13.5
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# jaquette
|
|
15
|
+
|
|
16
|
+
[](https://pypi.org/project/jaquette/)
|
|
17
|
+
[](https://pypi.org/project/jaquette/)
|
|
18
|
+
[](https://github.com/mtouzot/jaquette/actions)
|
|
19
|
+
[](https://github.com/mtouzot/jaquette/blob/HEAD/LICENSE)
|
|
20
|
+
|
|
21
|
+
Python client for the public [MyBluray](https://mybluray.fr/api) API (cover art and title search).
|
|
22
|
+
|
|
23
|
+
> **Non-commercial use only**, as required by MyBluray and by this project's license.
|
|
24
|
+
> This project is not affiliated with MyBluray or DVDFr.
|
|
25
|
+
|
|
26
|
+
- Synchronous (`Client`) and asynchronous (`AsyncClient`) clients with the same interface
|
|
27
|
+
- Typed responses ([pydantic](https://docs.pydantic.dev/)) and a typed package (`py.typed`)
|
|
28
|
+
- Search filters: media type, publisher, genre, release dates
|
|
29
|
+
- Automatic retries with `Retry-After` support and exponential backoff
|
|
30
|
+
- A clear exception hierarchy: one `except JaquetteException` catches everything
|
|
31
|
+
- A `jaquette` command-line tool
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install jaquette
|
|
37
|
+
# or
|
|
38
|
+
uv add jaquette
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Python 3.11 or newer is required.
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from jaquette import Client
|
|
47
|
+
|
|
48
|
+
with Client() as client:
|
|
49
|
+
# Cover art record by barcode (ISBN/EAN, as a string)
|
|
50
|
+
product = client.get_product("3333290016961")
|
|
51
|
+
print(product.title, product.media, product.editeur)
|
|
52
|
+
|
|
53
|
+
# All editions of a title
|
|
54
|
+
results = client.search("Breaking Bad")
|
|
55
|
+
print(f"{len(results)} editions (truncated: {results.truncated})")
|
|
56
|
+
for item in results:
|
|
57
|
+
print(item.isbn, item.media, item.title)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The ISBN is a **string**: barcodes can start with zeros, which an integer would lose.
|
|
61
|
+
Use the client as a context manager so the connection is closed for you.
|
|
62
|
+
|
|
63
|
+
### Searching with filters
|
|
64
|
+
|
|
65
|
+
All filters are optional and keyword-only. `media`, `editeur` and `genre` accept a
|
|
66
|
+
string or a list of strings.
|
|
67
|
+
|
|
68
|
+
| Parameter | Type | Description |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `media` | `str \| list[str]` | Media type, e.g. `"Blu-ray"`, `["DVD", "4K Ultra HD"]` |
|
|
71
|
+
| `editeur` | `str \| list[str]` | Publisher |
|
|
72
|
+
| `genre` | `str \| list[str]` | DVDFr genre |
|
|
73
|
+
| `parution_min` | `date \| "YYYY-MM-DD"` | Earliest release date |
|
|
74
|
+
| `parution_max` | `date \| "YYYY-MM-DD"` | Latest release date |
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
results = client.search(
|
|
78
|
+
"Alien",
|
|
79
|
+
media=["Blu-ray", "4K Ultra HD"],
|
|
80
|
+
parution_min="2015-01-01",
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> Always check `results.truncated`: when it is `True`, not all DVDFr pages could be
|
|
85
|
+
> crawled and the list is incomplete.
|
|
86
|
+
|
|
87
|
+
### Saving the barcode image
|
|
88
|
+
|
|
89
|
+
`product.barcode` holds the PNG bytes of the EAN-13 barcode:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from pathlib import Path
|
|
93
|
+
|
|
94
|
+
Path("barcode.png").write_bytes(product.barcode)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Asynchronous client
|
|
98
|
+
|
|
99
|
+
`AsyncClient` has the same methods, as coroutines:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import asyncio
|
|
103
|
+
|
|
104
|
+
from jaquette import AsyncClient
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
async def main() -> None:
|
|
108
|
+
isbns = ["3333290016961", "3333290016962"]
|
|
109
|
+
limit = asyncio.Semaphore(5) # be polite: at most 5 requests at a time
|
|
110
|
+
|
|
111
|
+
async with AsyncClient() as client:
|
|
112
|
+
|
|
113
|
+
async def fetch(isbn: str):
|
|
114
|
+
async with limit:
|
|
115
|
+
return await client.get_product(isbn)
|
|
116
|
+
|
|
117
|
+
# return_exceptions=True: one unknown barcode must not discard the others
|
|
118
|
+
results = await asyncio.gather(*(fetch(i) for i in isbns), return_exceptions=True)
|
|
119
|
+
|
|
120
|
+
for isbn, result in zip(isbns, results):
|
|
121
|
+
print(isbn, result if isinstance(result, Exception) else result.title)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
asyncio.run(main())
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Command line
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
jaquette product 3333290016961
|
|
131
|
+
jaquette search Breaking Bad
|
|
132
|
+
jaquette search Alien --media Blu-ray --media "4K Ultra HD" --from 2015-01-01
|
|
133
|
+
jaquette search Alien --json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
| Option | Applies to | Description |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `--json` | `product`, `search` | Print JSON instead of text (the barcode image is left out) |
|
|
139
|
+
| `--media`, `--editeur`, `--genre` | `search` | Filter; repeat the option to give several values |
|
|
140
|
+
| `--from`, `--to` | `search` | Release date bounds, `YYYY-MM-DD` |
|
|
141
|
+
|
|
142
|
+
The exit code is `0` on success and `1` on error (the message goes to stderr).
|
|
143
|
+
|
|
144
|
+
## Error handling
|
|
145
|
+
|
|
146
|
+
Every error raised by the library inherits from `JaquetteException`.
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
JaquetteException
|
|
150
|
+
├── InvalidISBNError malformed ISBN (no request sent)
|
|
151
|
+
├── InvalidQueryError query too short, or malformed date (no request sent)
|
|
152
|
+
├── NetworkError connection failure or timeout, after retries
|
|
153
|
+
├── InvalidResponseError the API response does not match the expected schema
|
|
154
|
+
└── APIError HTTP error (has .status_code, .message, .payload)
|
|
155
|
+
├── BadRequestError 400 / 422
|
|
156
|
+
├── NotFoundError 404
|
|
157
|
+
├── RateLimitError 429 (has .retry_after, in seconds)
|
|
158
|
+
└── ServerError 5xx
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from jaquette import Client, JaquetteException, NotFoundError
|
|
163
|
+
|
|
164
|
+
with Client() as client:
|
|
165
|
+
try:
|
|
166
|
+
product = client.get_product("9999999999999")
|
|
167
|
+
except NotFoundError as e:
|
|
168
|
+
print(f"Unknown barcode: {e.message}")
|
|
169
|
+
except JaquetteException as e:
|
|
170
|
+
print(f"Request failed: {e}")
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Put the most specific `except` first.
|
|
174
|
+
|
|
175
|
+
## Retries
|
|
176
|
+
|
|
177
|
+
Network errors, HTTP `429` and `502`/`503`/`504` are retried automatically, 2 times by
|
|
178
|
+
default. The client waits for the `Retry-After` header when the server sends one
|
|
179
|
+
(capped at 30 s), and otherwise waits 0.5 s, 1 s, 2 s... Other errors (404, 400...) are
|
|
180
|
+
never retried.
|
|
181
|
+
|
|
182
|
+
Use `Client(max_retries=0)` to disable retries.
|
|
183
|
+
|
|
184
|
+
## Design notes
|
|
185
|
+
|
|
186
|
+
- **One logic, two clients**: validation, error mapping, parsing and retry delays are plain
|
|
187
|
+
functions shared by `Client` and `AsyncClient`; only the network call differs.
|
|
188
|
+
- **Offline tests**: the suite runs against `httpx.MockTransport`, never the real API.
|
|
189
|
+
- **Bring your own `httpx` client**: `Client(client=my_httpx_client)` for proxies or
|
|
190
|
+
custom transports.
|
|
191
|
+
|
|
192
|
+
## Documentation
|
|
193
|
+
|
|
194
|
+
Full API reference: [**https://mtouzot.github.io/jaquette/**](https://mtouzot.github.io/jaquette/)
|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv sync
|
|
200
|
+
uv run pytest
|
|
201
|
+
uv run prek run --all-files
|
|
202
|
+
uv run mkdocs serve # documentation preview
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
Released under the [PolyForm Noncommercial License 1.0.0](https://github.com/mtouzot/jaquette/blob/HEAD/LICENSE).
|
jaquette-0.1.0/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# jaquette
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/jaquette/)
|
|
4
|
+
[](https://pypi.org/project/jaquette/)
|
|
5
|
+
[](https://github.com/mtouzot/jaquette/actions)
|
|
6
|
+
[](https://github.com/mtouzot/jaquette/blob/HEAD/LICENSE)
|
|
7
|
+
|
|
8
|
+
Python client for the public [MyBluray](https://mybluray.fr/api) API (cover art and title search).
|
|
9
|
+
|
|
10
|
+
> **Non-commercial use only**, as required by MyBluray and by this project's license.
|
|
11
|
+
> This project is not affiliated with MyBluray or DVDFr.
|
|
12
|
+
|
|
13
|
+
- Synchronous (`Client`) and asynchronous (`AsyncClient`) clients with the same interface
|
|
14
|
+
- Typed responses ([pydantic](https://docs.pydantic.dev/)) and a typed package (`py.typed`)
|
|
15
|
+
- Search filters: media type, publisher, genre, release dates
|
|
16
|
+
- Automatic retries with `Retry-After` support and exponential backoff
|
|
17
|
+
- A clear exception hierarchy: one `except JaquetteException` catches everything
|
|
18
|
+
- A `jaquette` command-line tool
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install jaquette
|
|
24
|
+
# or
|
|
25
|
+
uv add jaquette
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Python 3.11 or newer is required.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from jaquette import Client
|
|
34
|
+
|
|
35
|
+
with Client() as client:
|
|
36
|
+
# Cover art record by barcode (ISBN/EAN, as a string)
|
|
37
|
+
product = client.get_product("3333290016961")
|
|
38
|
+
print(product.title, product.media, product.editeur)
|
|
39
|
+
|
|
40
|
+
# All editions of a title
|
|
41
|
+
results = client.search("Breaking Bad")
|
|
42
|
+
print(f"{len(results)} editions (truncated: {results.truncated})")
|
|
43
|
+
for item in results:
|
|
44
|
+
print(item.isbn, item.media, item.title)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The ISBN is a **string**: barcodes can start with zeros, which an integer would lose.
|
|
48
|
+
Use the client as a context manager so the connection is closed for you.
|
|
49
|
+
|
|
50
|
+
### Searching with filters
|
|
51
|
+
|
|
52
|
+
All filters are optional and keyword-only. `media`, `editeur` and `genre` accept a
|
|
53
|
+
string or a list of strings.
|
|
54
|
+
|
|
55
|
+
| Parameter | Type | Description |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `media` | `str \| list[str]` | Media type, e.g. `"Blu-ray"`, `["DVD", "4K Ultra HD"]` |
|
|
58
|
+
| `editeur` | `str \| list[str]` | Publisher |
|
|
59
|
+
| `genre` | `str \| list[str]` | DVDFr genre |
|
|
60
|
+
| `parution_min` | `date \| "YYYY-MM-DD"` | Earliest release date |
|
|
61
|
+
| `parution_max` | `date \| "YYYY-MM-DD"` | Latest release date |
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
results = client.search(
|
|
65
|
+
"Alien",
|
|
66
|
+
media=["Blu-ray", "4K Ultra HD"],
|
|
67
|
+
parution_min="2015-01-01",
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
> Always check `results.truncated`: when it is `True`, not all DVDFr pages could be
|
|
72
|
+
> crawled and the list is incomplete.
|
|
73
|
+
|
|
74
|
+
### Saving the barcode image
|
|
75
|
+
|
|
76
|
+
`product.barcode` holds the PNG bytes of the EAN-13 barcode:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from pathlib import Path
|
|
80
|
+
|
|
81
|
+
Path("barcode.png").write_bytes(product.barcode)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Asynchronous client
|
|
85
|
+
|
|
86
|
+
`AsyncClient` has the same methods, as coroutines:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import asyncio
|
|
90
|
+
|
|
91
|
+
from jaquette import AsyncClient
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async def main() -> None:
|
|
95
|
+
isbns = ["3333290016961", "3333290016962"]
|
|
96
|
+
limit = asyncio.Semaphore(5) # be polite: at most 5 requests at a time
|
|
97
|
+
|
|
98
|
+
async with AsyncClient() as client:
|
|
99
|
+
|
|
100
|
+
async def fetch(isbn: str):
|
|
101
|
+
async with limit:
|
|
102
|
+
return await client.get_product(isbn)
|
|
103
|
+
|
|
104
|
+
# return_exceptions=True: one unknown barcode must not discard the others
|
|
105
|
+
results = await asyncio.gather(*(fetch(i) for i in isbns), return_exceptions=True)
|
|
106
|
+
|
|
107
|
+
for isbn, result in zip(isbns, results):
|
|
108
|
+
print(isbn, result if isinstance(result, Exception) else result.title)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
asyncio.run(main())
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Command line
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
jaquette product 3333290016961
|
|
118
|
+
jaquette search Breaking Bad
|
|
119
|
+
jaquette search Alien --media Blu-ray --media "4K Ultra HD" --from 2015-01-01
|
|
120
|
+
jaquette search Alien --json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
| Option | Applies to | Description |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| `--json` | `product`, `search` | Print JSON instead of text (the barcode image is left out) |
|
|
126
|
+
| `--media`, `--editeur`, `--genre` | `search` | Filter; repeat the option to give several values |
|
|
127
|
+
| `--from`, `--to` | `search` | Release date bounds, `YYYY-MM-DD` |
|
|
128
|
+
|
|
129
|
+
The exit code is `0` on success and `1` on error (the message goes to stderr).
|
|
130
|
+
|
|
131
|
+
## Error handling
|
|
132
|
+
|
|
133
|
+
Every error raised by the library inherits from `JaquetteException`.
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
JaquetteException
|
|
137
|
+
├── InvalidISBNError malformed ISBN (no request sent)
|
|
138
|
+
├── InvalidQueryError query too short, or malformed date (no request sent)
|
|
139
|
+
├── NetworkError connection failure or timeout, after retries
|
|
140
|
+
├── InvalidResponseError the API response does not match the expected schema
|
|
141
|
+
└── APIError HTTP error (has .status_code, .message, .payload)
|
|
142
|
+
├── BadRequestError 400 / 422
|
|
143
|
+
├── NotFoundError 404
|
|
144
|
+
├── RateLimitError 429 (has .retry_after, in seconds)
|
|
145
|
+
└── ServerError 5xx
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from jaquette import Client, JaquetteException, NotFoundError
|
|
150
|
+
|
|
151
|
+
with Client() as client:
|
|
152
|
+
try:
|
|
153
|
+
product = client.get_product("9999999999999")
|
|
154
|
+
except NotFoundError as e:
|
|
155
|
+
print(f"Unknown barcode: {e.message}")
|
|
156
|
+
except JaquetteException as e:
|
|
157
|
+
print(f"Request failed: {e}")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Put the most specific `except` first.
|
|
161
|
+
|
|
162
|
+
## Retries
|
|
163
|
+
|
|
164
|
+
Network errors, HTTP `429` and `502`/`503`/`504` are retried automatically, 2 times by
|
|
165
|
+
default. The client waits for the `Retry-After` header when the server sends one
|
|
166
|
+
(capped at 30 s), and otherwise waits 0.5 s, 1 s, 2 s... Other errors (404, 400...) are
|
|
167
|
+
never retried.
|
|
168
|
+
|
|
169
|
+
Use `Client(max_retries=0)` to disable retries.
|
|
170
|
+
|
|
171
|
+
## Design notes
|
|
172
|
+
|
|
173
|
+
- **One logic, two clients**: validation, error mapping, parsing and retry delays are plain
|
|
174
|
+
functions shared by `Client` and `AsyncClient`; only the network call differs.
|
|
175
|
+
- **Offline tests**: the suite runs against `httpx.MockTransport`, never the real API.
|
|
176
|
+
- **Bring your own `httpx` client**: `Client(client=my_httpx_client)` for proxies or
|
|
177
|
+
custom transports.
|
|
178
|
+
|
|
179
|
+
## Documentation
|
|
180
|
+
|
|
181
|
+
Full API reference: [**https://mtouzot.github.io/jaquette/**](https://mtouzot.github.io/jaquette/)
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
uv sync
|
|
187
|
+
uv run pytest
|
|
188
|
+
uv run prek run --all-files
|
|
189
|
+
uv run mkdocs serve # documentation preview
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
Released under the [PolyForm Noncommercial License 1.0.0](https://github.com/mtouzot/jaquette/blob/HEAD/LICENSE).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "jaquette"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Unofficial Python client for the public MyBluray API (cover art and title search)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "PolyForm-Noncommercial-1.0.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"httpx>=0.28.1",
|
|
11
|
+
"pydantic>=2.13.5",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[project.authors]]
|
|
15
|
+
name = "Martin TOUZOT"
|
|
16
|
+
email = "mtouzot@proton.me"
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
jaquette = "jaquette:main"
|
|
20
|
+
|
|
21
|
+
[build-system]
|
|
22
|
+
requires = ["uv_build>=0.12.3,<0.13.0"]
|
|
23
|
+
build-backend = "uv_build"
|
|
24
|
+
|
|
25
|
+
[tool.commitizen]
|
|
26
|
+
name = "cz_conventional_commits"
|
|
27
|
+
version_provider = "pep621"
|
|
28
|
+
tag_format = "v$version"
|
|
29
|
+
update_changelog_on_bump = true
|
|
30
|
+
|
|
31
|
+
[tool.ty.environment]
|
|
32
|
+
python = ".venv"
|
|
33
|
+
|
|
34
|
+
[tool.typos.default.extend-words]
|
|
35
|
+
categorie = "categorie"
|
|
36
|
+
|
|
37
|
+
[tool.pytest.ini_options]
|
|
38
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
39
|
+
asyncio_mode = "auto"
|
|
40
|
+
testpaths = ["tests"]
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = [
|
|
44
|
+
"commitizen>=4.20.1",
|
|
45
|
+
"pre-commit>=4.7.0",
|
|
46
|
+
"pytest>=9.2.0",
|
|
47
|
+
"pytest-asyncio>=1.5.0",
|
|
48
|
+
"pytest-cov>=7.1.0",
|
|
49
|
+
"ruff>=0.17.6",
|
|
50
|
+
"ty>=0.0.110",
|
|
51
|
+
]
|
|
52
|
+
docs = [
|
|
53
|
+
"griffe-pydantic>=1.3.2",
|
|
54
|
+
"mkdocstrings[python]>=1.0.8",
|
|
55
|
+
"zensical>=0.1.4",
|
|
56
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "jaquette"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Unofficial Python client for the public MyBluray API (cover art and title search)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "PolyForm-Noncommercial-1.0.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Martin TOUZOT", email = "mtouzot@proton.me" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"httpx>=0.28.1",
|
|
14
|
+
"pydantic>=2.13.5",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.scripts]
|
|
18
|
+
jaquette = "jaquette:main"
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["uv_build>=0.12.3,<0.13.0"]
|
|
22
|
+
build-backend = "uv_build"
|
|
23
|
+
|
|
24
|
+
[tool.commitizen]
|
|
25
|
+
name = "cz_conventional_commits"
|
|
26
|
+
version_provider = "pep621"
|
|
27
|
+
tag_format = "v$version"
|
|
28
|
+
update_changelog_on_bump = true
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[tool.ty.environment]
|
|
32
|
+
python = ".venv"
|
|
33
|
+
|
|
34
|
+
[tool.typos.default.extend-words]
|
|
35
|
+
categorie = "categorie"
|
|
36
|
+
|
|
37
|
+
[tool.pytest.ini_options]
|
|
38
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
39
|
+
asyncio_mode = "auto"
|
|
40
|
+
testpaths = ["tests"]
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = [
|
|
44
|
+
"commitizen>=4.20.1",
|
|
45
|
+
"pre-commit>=4.7.0",
|
|
46
|
+
"pytest>=9.2.0",
|
|
47
|
+
"pytest-asyncio>=1.5.0",
|
|
48
|
+
"pytest-cov>=7.1.0",
|
|
49
|
+
"ruff>=0.17.6",
|
|
50
|
+
"ty>=0.0.110",
|
|
51
|
+
]
|
|
52
|
+
docs = [
|
|
53
|
+
"griffe-pydantic>=1.3.2",
|
|
54
|
+
"mkdocstrings[python]>=1.0.8",
|
|
55
|
+
"zensical>=0.1.4",
|
|
56
|
+
]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
2
|
+
|
|
3
|
+
from .cli import main
|
|
4
|
+
from .clients import AsyncClient, Client
|
|
5
|
+
from .exceptions import (
|
|
6
|
+
APIError,
|
|
7
|
+
BadRequestError,
|
|
8
|
+
InvalidISBNError,
|
|
9
|
+
InvalidQueryError,
|
|
10
|
+
InvalidResponseError,
|
|
11
|
+
JaquetteException,
|
|
12
|
+
NetworkError,
|
|
13
|
+
NotFoundError,
|
|
14
|
+
RateLimitError,
|
|
15
|
+
ServerError,
|
|
16
|
+
)
|
|
17
|
+
from .models import ProductResponse, SearchItem, SearchResponse
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
__version__ = version("jaquette")
|
|
21
|
+
except PackageNotFoundError:
|
|
22
|
+
__version__ = "unknown"
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"APIError",
|
|
26
|
+
"AsyncClient",
|
|
27
|
+
"BadRequestError",
|
|
28
|
+
"Client",
|
|
29
|
+
"InvalidISBNError",
|
|
30
|
+
"InvalidQueryError",
|
|
31
|
+
"InvalidResponseError",
|
|
32
|
+
"JaquetteException",
|
|
33
|
+
"NetworkError",
|
|
34
|
+
"NotFoundError",
|
|
35
|
+
"ProductResponse",
|
|
36
|
+
"RateLimitError",
|
|
37
|
+
"SearchItem",
|
|
38
|
+
"SearchResponse",
|
|
39
|
+
"ServerError",
|
|
40
|
+
"__version__",
|
|
41
|
+
"main",
|
|
42
|
+
]
|