Skip to content

Commit a7299b0

Browse files
Update README.me
Add information about new functions. Add section on request complexity. Describe type-specific fields in "MediaEntry".
1 parent bfce8f5 commit a7299b0

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ If a platform offers streaming for a given entry in 4K, HD and SD, then `best_on
8181

8282
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
8383

84+
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
85+
8486
Example command and its output is in [`examples/search_output.py`](examples/search_output.py).
8587

8688

@@ -111,9 +113,72 @@ General usage of these arguments matches the [`search`](#search) command.
111113

112114
Returned value is a single [`MediaEntry`](#return-data-structures) object.
113115

116+
This function can be used for all types of media - shows, movies, episodes, seasons (the last two having their dedicated functions described below),
117+
for all types the result is a single [`MediaEntry`](#return-data-structures) object.
118+
Some fields are specific for one of the media types and will be `None` for others - e.g.:
119+
- `total_episode_count` is only present for seasons
120+
- `season_number` is present for seasons and episodes
121+
- `episode_number` is present only for episodes
122+
- `age_certification` is present only for movies and shows
123+
124+
For episodes specifically most of the fields will be empty (which is why [`episodes`](#episodes) command returns different structure).
125+
114126
Example command and its output is in [`examples/details_output.py`](examples/details_output.py).
115127

116128

129+
### Seasons
130+
131+
Seasons function allows for looking up all seasons of a show via its node ID.
132+
Node/show ID can be taken from output of the [`search`](#search) command.
133+
It's also the same ID as input for [`details`](#details) command.
134+
135+
Each season contains similar data to the [`details`](#details) command, with additional season number and number of episodes.
136+
137+
Usage also matches [`details`](#details) command:
138+
```python
139+
from simplejustwatchapi.justwatch import seasons
140+
141+
results = seasons("nodeID", "US", "en", False)
142+
```
143+
144+
Only the first argument is required - the node ID of element to look up details for.
145+
146+
| | Argument | Type | Required | Default value | Description |
147+
|---|-------------|--------|----------|---------------|--------------------------------------------------------|
148+
| 1 | `show_id` | `str` | **YES** | - | Node/show ID to look up |
149+
| 2 | `country` | `str` | NO | `"US"` | Country to search for offers |
150+
| 3 | `language` | `str` | NO | `"en"` | Language of responses |
151+
| 5 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
152+
153+
Returned value is a list of [`MediaEntry`](#return-data-structures) objects, each describing a single season.
154+
155+
156+
### Episodes
157+
158+
Episodes function allows for looking up all episodes of a season via season's node ID.
159+
Node/season ID can be taken from output of the [`seasons`](#seasons) command.
160+
161+
Usage matches [`details`](#details) command:
162+
```python
163+
from simplejustwatchapi.justwatch import seasons
164+
165+
results = seasons("nodeID", "US", "en", False)
166+
```
167+
168+
Only the first argument is required - the node ID of element to look up details for.
169+
170+
| | Argument | Type | Required | Default value | Description |
171+
|---|-------------|--------|----------|---------------|--------------------------------------------------------|
172+
| 1 | `season_id` | `str` | **YES** | - | Node/season ID to look up |
173+
| 2 | `country` | `str` | NO | `"US"` | Country to search for offers |
174+
| 3 | `language` | `str` | NO | `"en"` | Language of responses |
175+
| 5 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
176+
177+
Returned value is a list of [`Episode`](#return-data-structures) objects, each describing a single episode.
178+
Each contains only a small subset of fields from the [`MediaEntry`](#return-data-structures) object,
179+
JustWatch API doesn't return "full" data.
180+
181+
117182
### Offers for countries
118183

119184
This function allows looking up offers for entry by given node ID.
@@ -147,6 +212,17 @@ Example command and its output is in [`examples/offers_for_countries_output.py`]
147212

148213
Detailed descriptions of all used data structures are available in the [documentation](https://electronic-mango.github.io/simple-justwatch-python-api/simplejustwatchapi.html#module-simplejustwatchapi.query).
149214

215+
The main structure `MediaEntry` contains fields for all media types - movies, shows, seasons, episodes.
216+
Some fields are specific for one of the media types and will be `None` for others - e.g.:
217+
- `total_episode_count` is only present for seasons
218+
- `season_number` is present for seasons and episodes
219+
- `episode_number` is present only for episodes
220+
- `age_certification` is present only for movies and shows
221+
222+
For episodes specifically most of the fields will be empty (which is why [`episodes`](#episodes) command returns different structure).
223+
224+
As [`search`](#search) function can return only movies and shows the episode-specific and season-specific fields will always be `None`,
225+
but are included in `MediaEntry` so they will be present in output from [`details`](#details) function.
150226

151227

152228
## Locale, language, country
@@ -165,6 +241,20 @@ If you provide unsupported language JustWatch API should default to english.
165241

166242

167243

244+
## Request complexity
245+
246+
JustWatch API will respond with error on too high request/response complexity - essentially when returned graph would be too large.
247+
It's the reason for why seasons/episodes data isn't available directly in [`search`](#search), or [`details`](#details) function
248+
(mostly the former).
249+
250+
This issue can still occur for [`search`](#search) with too high `count` value.
251+
In my tests the limit is around 100 (in the worst case with `best_only=False`).
252+
It's a lot, but keep it in mind.
253+
254+
Using `best_only=True` should alleviate the issue somewhat, so for very large requests I recommend using its default `True` value.
255+
256+
257+
168258
## Disclaimer
169259

170260
This API is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with JustWatch.

0 commit comments

Comments
 (0)