You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -92,7 +93,7 @@ If JustWatch GraphQL API returns fewer entries, then this function will also ret
92
93
`best_only` determines whether similar offers, but lower quality should be included in response.
93
94
If a platform offers streaming for a given entry in 4K, HD and SD, then `best_only = True` will return only the 4K offer, `best_only = False` will return all three.
94
95
95
-
`offset` allows for very basic pagination, letting you get more data without running into [request complexity](#request-complexity).
96
+
`offset` allows for very basic pagination, letting you get more data without running into [operation complexity](caveats.md#operation-complexity).
96
97
It simply skips `offset` number of first entries (on the API side, nothing is done inside the library).
97
98
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
98
99
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
@@ -107,7 +108,7 @@ or check [Provider codes](#provider-codes) for more details.
107
108
108
109
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
109
110
110
-
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
111
+
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [operation complexity](caveats.md#operation-complexity).
111
112
112
113
Example function call and its output is in [`examples/search_output.py`](examples/search_output.py).
113
114
@@ -146,7 +147,7 @@ If JustWatch GraphQL API returns fewer entries, then this function will also ret
146
147
`best_only` determines whether similar offers, but lower quality should be included in response.
147
148
If a platform offers streaming for a given entry in 4K, HD and SD, then `best_only = True` will return only the 4K offer, `best_only = False` will return all three.
148
149
149
-
`offset` allows for very basic pagination letting you get more data without running into [request complexity](#request-complexity).
150
+
`offset` allows for very basic pagination letting you get more data without running into [operation complexity](caveats.md#operation-complexity).
150
151
It simply skips first entries (on the API side, nothing is done inside the library).
151
152
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
152
153
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
@@ -161,7 +162,7 @@ or check [Provider codes](#provider-codes) for more details.
161
162
162
163
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
163
164
164
-
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
165
+
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [operation complexity](caveats.md#operation-complexity).
165
166
166
167
Example function call and its output is in [`examples/popular_output.py`](examples/popular_output.py).
167
168
@@ -323,11 +324,98 @@ Example function call and its output is in [`examples/providers_output.py`](exam
|[`JustWatchHttpError`][simplejustwatchapi.exceptions.JustWatchHttpError]| JustWatch API responded with non-`2xx` code. |
329
-
|[`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]| JSON response from JustWatch API contains errors. If this exception is raised, then API responded with `2xx` code. |
330
+
|[`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]| JSON response from JustWatch API contains errors,<br>even though the API responded with a `2xx` status code. |
330
331
332
+
You can check [Exceptions](API Reference/exceptions.md) page for more details.
333
+
334
+
### HTTP errors
335
+
336
+
Non-`2xx` response status codes can happen when trying to use incorrect type for
337
+
parameters, e.g., trying to use a non-numeric string for `count`:
338
+
339
+
```python
340
+
from simplejustwatchapi import search, JustWatchHttpError
341
+
342
+
try:
343
+
results = search("The Matrix", count="five")
344
+
except JustWatchHttpError as e:
345
+
print(e.code, e.message)
346
+
# In this case "e.message" is a JSON, but handled as a regular string.
347
+
```
348
+
349
+
!!! note "Numeric strings instead of `int`"
350
+
Since requests are send as a JSON you can use strings for `int` arguments, as long
351
+
as they are numeric strings, like `5`, instead of `five`:
352
+
353
+
```python
354
+
from simplejustwatchapi import search
355
+
356
+
results = search("The Matrix", count="5")
357
+
# No exception is raised.
358
+
```
359
+
360
+
361
+
### API errors
362
+
363
+
API errors can occur for invalid country code:
364
+
```python
365
+
from simplejustwatchapi import search, JustWatchApiError
366
+
367
+
try:
368
+
# Country code matches 2-letter pattern, but isn't a valid code for any country.
369
+
results = search("The Matrix", country="xx")
370
+
except JustWatchApiError as e:
371
+
# Print all error messages.
372
+
error_messages = [error.get("message") for error in e.errors]
373
+
print(",".join(error_messages))
374
+
```
375
+
376
+
It can occur for language codes not matching expected pattern:
377
+
```python
378
+
from simplejustwatchapi import search, JustWatchApiError
379
+
380
+
try:
381
+
# Language code "xx" also isn't valid for any languages, but since it matches the
382
+
# pattern it would default to english.
383
+
results = search("The Matrix", language="xxx")
384
+
except JustWatchApiError as e:
385
+
# Print only error codes.
386
+
# Codes are collected to a set, as the API will return an error for each place,
387
+
# where language code is used, in all offers, descriptions, etc.
388
+
error_codes = {error["extensions"]["code"] for error in e.errors}
389
+
print(",".join(error_codes))
390
+
```
391
+
392
+
Using title, instead of ID in [`details`][simplejustwatchapi.justwatch.details]
393
+
function:
394
+
395
+
```python
396
+
from simplejustwatchapi import details, JustWatchError
397
+
398
+
try:
399
+
# "details" expects an ID, not a title.
400
+
results = details("The Matrix")
401
+
except JustWatchError as e:
402
+
# JustWatchError will catch both API and HTTP exceptions.
403
+
print(e.errors)
404
+
```
405
+
406
+
Too high operation complexity due to too large `count`:
407
+
408
+
```python
409
+
from simplejustwatchapi import search, JustWatchApiError
410
+
411
+
try:
412
+
results = search("The Matrix", count=500)
413
+
except JustWatchApiError as e:
414
+
error_messages = [error.get("message") for error in e.errors]
415
+
print(",".join(error_messages))
416
+
```
417
+
418
+
And, probably, many other, similar, cases as well.
0 commit comments