Skip to content

Commit eeef411

Browse files
Tweak docstrings
1 parent 2b42785 commit eeef411

2 files changed

Lines changed: 94 additions & 125 deletions

File tree

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ icon: lucide/circle-play
88
This documentation is currently under development and might not be fully up-to-date.
99
However, the main functionality should be (more or less) correct.
1010

11-
A simple unofficial JustWatch Python API which uses [`GraphQL`](https://graphql.org/)
11+
A simple *unofficial* JustWatch Python API which uses [`GraphQL`](https://graphql.org/)
1212
to access [JustWatch](https://www.justwatch.com/) data, built with
1313
[`httpx`](https://www.python-httpx.org/) and available for Python `3.11+`.
1414

src/simplejustwatchapi/justwatch.py

Lines changed: 93 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,26 @@
1111
1212
| Name | Description |
1313
|-------------|-------------|
14-
| `country` | 2-letter country code for which offers will be returned, e.g., `US`, \
15-
`GB`, `DE`. |
16-
| `language` | Language code for responses' language. It can be just basic 2-letter \
17-
code or with a IETF BCP 47 suffix (e.g., `en-US`, `de-CH1901`). |
14+
| `country` | 2-letter country code for which offers are selected, (e.g., `US`, \
15+
`GB`, `DE`). |
16+
| `language` | Code for language in responses. It consists of 2 lowercase letters \
17+
with optional uppercase alphanumeric suffix (e.g., `en`, `en-US`, \
18+
`de`, `de-CH1901`). |
1819
| `best_only` | Whether to return only "best" offers for each provider instead of, \
1920
e.g., separate offer for SD, HD, and 4K. |
2021
2122
Functions returning data for multiple titles
2223
([`search`][simplejustwatchapi.justwatch.search],
23-
[`details`][simplejustwatchapi.justwatch.details])
24+
[`popular`][simplejustwatchapi.justwatch.popular])
2425
also allow for specifying number of elements, basic pagination, and filtering for
2526
specific providers:
2627
2728
| Name | Description |
2829
|-------------|-------------|
2930
| `count` | How many entries should be returned. |
30-
| `offset` | Basic "pagination", how many first elements should be skipped. \
31-
Everything is handled on API side, this library isn't doing any \
32-
filtering. |
31+
| `offset` | Basic "pagination". Offset for the first returned result, i.e. how \
32+
many first entries should be skipped. Everything is handled on API \
33+
side, this library isn't doing any filtering. |
3334
| `providers` | Providers (like Netflix, Amazon Prime Video) for which offers should \
3435
returned. Requires 3-letter "short name". Check \
3536
[`providers`][simplejustwatchapi.justwatch.providers] for an example \
@@ -42,8 +43,8 @@
4243
| [`JustWatchHttpError`][simplejustwatchapi.exceptions.JustWatchHttpError] | \
4344
JustWatch API responded with non-`2xx` code. |
4445
| [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError] | \
45-
JSON response from JustWatch API contains errors. If this exception is raised, \
46-
then API responded with `2xx` code. |
46+
JSON response from JustWatch API contains errors (e.g., due to invalid language or \
47+
country code). If this exception is raised, then API responded with `2xx` code. |
4748
"""
4849

4950
from httpx import post
@@ -90,29 +91,26 @@ def search(
9091
9192
JustWatch API won't allow for getting more than 1999 responses, either through
9293
`count`, or when `count + offset` is equal or greater than 2000 - it will return an
93-
empty list instead (**always** an empty list, it won't include entries up to 1999).
94+
empty list instead (**always** an empty list, it won't include entries up to
95+
1999th).
9496
9597
Args:
96-
title (str): Title to search. Not stripped, passed to the API as-is.
97-
98-
country (str): 2-letter country code for which offers are selected.
98+
title (str): Title to search.
9999
100-
It should be uppercase, however it will be normalized to uppercase
101-
automatically.
100+
Not stripped, passed to the API as-is.
102101
103-
It **must** be 2-letters long and seems to be **ISO 3166-1 alpha-2** code,
104-
however the API doesn't specify exact standard. If unexpected code is used,
105-
then [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]
106-
exception is raised, as the API will respond with internal error.
102+
country (str): 2-letter country code for which offers are selected.
107103
108-
language (str): Code for language in response (e.g., description, title).
104+
It seems to be **ISO 3166-1 alpha-2** standard (e.g., `EN`, `FR`, `DE`),
105+
however the API doesn't specify it directly. It should be uppercase, however
106+
it's normalized to uppercase automatically.
109107
110-
In most basic form it's 2 lowercase letters (e.g., `en`, `de`).
111-
It can also contain alphanumeric (in uppercase) suffix after `-` symbol,
112-
most likely used for regional variants (e.g., `en-US`, `de-CH1901`).
108+
language (str): Code for language in responses (e.g., description, title).
113109
114-
It looks like a variant of **IETF BCP 47**, however the suffix can contain
115-
only uppercase letters and numbers.
110+
It consists of 2 lowercase letters with optional uppercase alphanumeric
111+
suffix after `-` symbol (e.g., `en`, `en-US`, `de`, `de-CH1901`). Similar to
112+
**IETF BCP 47** standard, however the suffix can contain only uppercase
113+
letters and numbers.
116114
117115
Its value isn't normalized and **must** be provided in expected format,
118116
including letter case.
@@ -139,22 +137,23 @@ def search(
139137
repeats.
140138
141139
providers (list[str] | str | None): Selection of 3-letter service identifiers
142-
(e.g, `nfx` for "Netflix"), only entries which are available for given
143-
providers will be returned.
140+
(e.g, `nfx` for "Netflix") to filter for.
144141
145142
For single provider you can either pass a single string, or a list of one
146-
string. For `None` (the default value) entries for all providers will be
147-
looked up.
143+
string. For `None` (the default value) no filtering is done.
144+
145+
Invalid codes will be ignored, however if all are invalid, then no filtering
146+
is done.
148147
149-
Invalid names will be ignored, however if all are invalid, then no filtering
150-
will be done. You can look up values through [`providers`]
148+
You can look up values through [`providers`]
151149
[simplejustwatchapi.justwatch.providers] function.
152150
153151
Returns:
154152
(list[MediaEntry]): List of tuples with details of search results.
155153
156154
Raises:
157-
exceptions.JustWatchApiError: JSON response from API has internal errors.
155+
exceptions.JustWatchApiError: JSON response from API has internal errors, e.g.,
156+
due to invalid language or country code.
158157
exceptions.JustWatchHttpError: JustWatch API didn't respond with `2xx` code.
159158
160159
"""
@@ -186,22 +185,16 @@ def popular(
186185
Args:
187186
country (str): 2-letter country code for which offers are selected.
188187
189-
It should be uppercase, however it will be normalized to uppercase
190-
automatically.
188+
It seems to be **ISO 3166-1 alpha-2** standard (e.g., `EN`, `FR`, `DE`),
189+
however the API doesn't specify it directly. It should be uppercase, however
190+
it's normalized to uppercase automatically.
191191
192-
It **must** be 2-letters long and seems to be **ISO 3166-1 alpha-2** code,
193-
however the API doesn't specify exact standard. If unexpected code is used,
194-
then [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]
195-
exception is raised, as the API will respond with internal error.
192+
language (str): Code for language in responses (e.g., description, title).
196193
197-
language (str): Code for language in response (e.g., description, title).
198-
199-
In most basic form it's 2 lowercase letters (e.g., `en`, `de`).
200-
It can also contain alphanumeric (in uppercase) suffix after `-` symbol,
201-
most likely used for regional variants (e.g., `en-US`, `de-CH1901`).
202-
203-
It looks like a variant of **IETF BCP 47**, however the suffix can contain
204-
only uppercase letters and numbers.
194+
It consists of 2 lowercase letters with optional uppercase alphanumeric
195+
suffix after `-` symbol (e.g., `en`, `en-US`, `de`, `de-CH1901`). Similar to
196+
**IETF BCP 47** standard, however the suffix can contain only uppercase
197+
letters and numbers.
205198
206199
Its value isn't normalized and **must** be provided in expected format,
207200
including letter case.
@@ -228,22 +221,23 @@ def popular(
228221
repeats.
229222
230223
providers (list[str] | str | None): Selection of 3-letter service identifiers
231-
(e.g, `nfx` for "Netflix"), only entries which are available for given
232-
providers will be returned.
224+
(e.g, `nfx` for "Netflix") to filter for.
233225
234226
For single provider you can either pass a single string, or a list of one
235-
string. For `None` (the default value) entries for all providers will be
236-
looked up.
227+
string. For `None` (the default value) no filtering is done.
237228
238-
Invalid names will be ignored, however if all are invalid, then no filtering
239-
will be done. You can look up values through [`providers`]
229+
Invalid codes will be ignored, however if all are invalid, then no filtering
230+
is done.
231+
232+
You can look up values through [`providers`]
240233
[simplejustwatchapi.justwatch.providers] function.
241234
242235
Returns:
243236
(list[MediaEntry]): List of tuples with details of popular titles.
244237
245238
Raises:
246-
exceptions.JustWatchApiError: JSON response from API has internal errors.
239+
exceptions.JustWatchApiError: JSON response from API has internal errors, e.g.,
240+
due to invalid language or country code.
247241
exceptions.JustWatchHttpError: JustWatch API didn't respond with `2xx` code.
248242
249243
"""
@@ -287,22 +281,16 @@ def details(
287281
288282
country (str): 2-letter country code for which offers are selected.
289283
290-
It should be uppercase, however it will be normalized to uppercase
291-
automatically.
292-
293-
It **must** be 2-letters long and seems to be **ISO 3166-1 alpha-2** code,
294-
however the API doesn't specify exact standard. If unexpected code is used,
295-
then [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]
296-
exception is raised, as the API will respond with internal error.
284+
It seems to be **ISO 3166-1 alpha-2** standard (e.g., `EN`, `FR`, `DE`),
285+
however the API doesn't specify it directly. It should be uppercase, however
286+
it's normalized to uppercase automatically.
297287
298-
language (str): Code for language in response (e.g., description, title).
288+
language (str): Code for language in responses (e.g., description, title).
299289
300-
In most basic form it's 2 lowercase letters (e.g., `en`, `de`).
301-
It can also contain alphanumeric (in uppercase) suffix after `-` symbol,
302-
most likely used for regional variants (e.g., `en-US`, `de-CH1901`).
303-
304-
It looks like a variant of **IETF BCP 47**, however the suffix can contain
305-
only uppercase letters and numbers.
290+
It consists of 2 lowercase letters with optional uppercase alphanumeric
291+
suffix after `-` symbol (e.g., `en`, `en-US`, `de`, `de-CH1901`). Similar to
292+
**IETF BCP 47** standard, however the suffix can contain only uppercase
293+
letters and numbers.
306294
307295
Its value isn't normalized and **must** be provided in expected format,
308296
including letter case.
@@ -317,7 +305,8 @@ def details(
317305
(MediaEntry): Tuple with data about requested entry.
318306
319307
Raises:
320-
exceptions.JustWatchApiError: JSON response from API has internal errors.
308+
exceptions.JustWatchApiError: JSON response from API has internal errors, e.g.,
309+
due to invalid language or country code.
321310
exceptions.JustWatchHttpError: JustWatch API didn't respond with `2xx` code.
322311
323312
"""
@@ -340,22 +329,16 @@ def seasons(
340329
341330
country (str): 2-letter country code for which offers are selected.
342331
343-
It should be uppercase, however it will be normalized to uppercase
344-
automatically.
345-
346-
It **must** be 2-letters long and seems to be **ISO 3166-1 alpha-2** code,
347-
however the API doesn't specify exact standard. If unexpected code is used,
348-
then [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]
349-
exception is raised, as the API will respond with internal error.
350-
351-
language (str): Code for language in response (e.g., description, title).
332+
It seems to be **ISO 3166-1 alpha-2** standard (e.g., `EN`, `FR`, `DE`),
333+
however the API doesn't specify it directly. It should be uppercase, however
334+
it's normalized to uppercase automatically.
352335
353-
In most basic form it's 2 lowercase letters (e.g., `en`, `de`).
354-
It can also contain alphanumeric (in uppercase) suffix after `-` symbol,
355-
most likely used for regional variants (e.g., `en-US`, `de-CH1901`).
336+
language (str): Code for language in responses (e.g., description, title).
356337
357-
It looks like a variant of **IETF BCP 47**, however the suffix can contain
358-
only uppercase letters and numbers.
338+
It consists of 2 lowercase letters with optional uppercase alphanumeric
339+
suffix after `-` symbol (e.g., `en`, `en-US`, `de`, `de-CH1901`). Similar to
340+
**IETF BCP 47** standard, however the suffix can contain only uppercase
341+
letters and numbers.
359342
360343
Its value isn't normalized and **must** be provided in expected format,
361344
including letter case.
@@ -370,7 +353,8 @@ def seasons(
370353
(list[MediaEntry]): List of tuples with seasons data about requested show.
371354
372355
Raises:
373-
exceptions.JustWatchApiError: JSON response from API has internal errors.
356+
exceptions.JustWatchApiError: JSON response from API has internal errors, e.g.,
357+
due to invalid language or country code.
374358
exceptions.JustWatchHttpError: JustWatch API didn't respond with `2xx` code.
375359
376360
"""
@@ -394,22 +378,16 @@ def episodes(
394378
395379
country (str): 2-letter country code for which offers are selected.
396380
397-
It should be uppercase, however it will be normalized to uppercase
398-
automatically.
399-
400-
It **must** be 2-letters long and seems to be **ISO 3166-1 alpha-2** code,
401-
however the API doesn't specify exact standard. If unexpected code is used,
402-
then [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]
403-
exception is raised, as the API will respond with internal error.
404-
405-
language (str): Code for language in response (e.g., description, title).
381+
It seems to be **ISO 3166-1 alpha-2** standard (e.g., `EN`, `FR`, `DE`),
382+
however the API doesn't specify it directly. It should be uppercase, however
383+
it's normalized to uppercase automatically.
406384
407-
In most basic form it's 2 lowercase letters (e.g., `en`, `de`).
408-
It can also contain alphanumeric (in uppercase) suffix after `-` symbol,
409-
most likely used for regional variants (e.g., `en-US`, `de-CH1901`).
385+
language (str): Code for language in responses (e.g., description, title).
410386
411-
It looks like a variant of **IETF BCP 47**, however the suffix can contain
412-
only uppercase letters and numbers.
387+
It consists of 2 lowercase letters with optional uppercase alphanumeric
388+
suffix after `-` symbol (e.g., `en`, `en-US`, `de`, `de-CH1901`). Similar to
389+
**IETF BCP 47** standard, however the suffix can contain only uppercase
390+
letters and numbers.
413391
414392
Its value isn't normalized and **must** be provided in expected format,
415393
including letter case.
@@ -424,7 +402,8 @@ def episodes(
424402
(list[Episode]): List of tuples with episode data about requested season.
425403
426404
Raises:
427-
exceptions.JustWatchApiError: JSON response from API has internal errors.
405+
exceptions.JustWatchApiError: JSON response from API has internal errors, e.g.,
406+
due to invalid language or country code.
428407
exceptions.JustWatchHttpError: JustWatch API didn't respond with `2xx` code.
429408
430409
"""
@@ -466,24 +445,16 @@ def offers_for_countries(
466445
467446
countries (set[str]): 2-letter country codes for which offers are selected.
468447
469-
They should be uppercase, however tthey will be normalized to uppercase
470-
automatically.
448+
They seem to match **ISO 3166-1 alpha-2** standard (e.g., `EN`, `FR`, `DE`),
449+
however the API doesn't specify it directly. They should be uppercase,
450+
however they're normalized to uppercase automatically.
471451
472-
They **must** be 2-letters long and seem to be **ISO 3166-1 alpha-2** code,
473-
however the API doesn't specify exact standard.
452+
language (str): Code for language in responses (e.g., description, title).
474453
475-
If unexpected code is used, then [`JustWatchApiError`]
476-
[simplejustwatchapi.exceptions.JustWatchApiError] exception is raised,
477-
as the API will respond with internal error.
478-
479-
language (str): Code for language in response (e.g., description, title).
480-
481-
In most basic form it's 2 lowercase letters (e.g., `en`, `de`).
482-
It can also contain alphanumeric (in uppercase) suffix after `-` symbol,
483-
most likely used for regional variants (e.g., `en-US`, `de-CH1901`).
484-
485-
It looks like a variant of **IETF BCP 47**, however the suffix can contain
486-
only uppercase letters and numbers.
454+
It consists of 2 lowercase letters with optional uppercase alphanumeric
455+
suffix after `-` symbol (e.g., `en`, `en-US`, `de`, `de-CH1901`). Similar to
456+
**IETF BCP 47** standard, however the suffix can contain only uppercase
457+
letters and numbers.
487458
488459
Its value isn't normalized and **must** be provided in expected format,
489460
including letter case.
@@ -499,7 +470,8 @@ def offers_for_countries(
499470
found offers for their respective countries.
500471
501472
Raises:
502-
exceptions.JustWatchApiError: JSON response from API has internal errors.
473+
exceptions.JustWatchApiError: JSON response from API has internal errors, e.g.,
474+
due to invalid language or country code.
503475
exceptions.JustWatchHttpError: JustWatch API didn't respond with `2xx` code.
504476
505477
"""
@@ -519,13 +491,9 @@ def providers(country: str = "US") -> list[OfferPackage]:
519491
Args:
520492
country (str): 2-letter country code for which offers are selected.
521493
522-
It should be uppercase, however it will be normalized to uppercase
523-
automatically.
524-
525-
It **must** be 2-letters long and seems to be **ISO 3166-1 alpha-2** code,
526-
however the API doesn't specify exact standard. If unexpected code is used,
527-
then [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]
528-
exception is raised, as the API will respond with internal error.
494+
It seems to be **ISO 3166-1 alpha-2** standard (e.g., `EN`, `FR`, `DE`),
495+
however the API doesn't specify it directly. It should be uppercase, however
496+
it's normalized to uppercase automatically.
529497
530498
Returns:
531499
(list[OfferPackage]): List of all found providers.
@@ -536,7 +504,8 @@ def providers(country: str = "US") -> list[OfferPackage]:
536504
structure is the same, so the same tuple is reused.
537505
538506
Raises:
539-
exceptions.JustWatchApiError: JSON response from API has internal errors.
507+
exceptions.JustWatchApiError: JSON response from API has internal errors, e.g.,
508+
due to invalid language or country code.
540509
exceptions.JustWatchHttpError: JustWatch API didn't respond with `2xx` code.
541510
542511
"""

0 commit comments

Comments
 (0)