Skip to content

Commit eaaa3a8

Browse files
Update documentation with new filtering options
1 parent 77824a4 commit eaaa3a8

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

docs/caveats.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,20 @@ popular_results = popular("US", providers=list(name_to_code_dict.values()))
296296
!!! tip "When this actually might be useful"
297297
This only makes sense if you are already using other functions. To get **just** the
298298
codes use the [`providers`](#providers-function) function instead.
299+
300+
301+
302+
## Filtering by type
303+
304+
Functions [`search`](#search-for-a-title) and [`popular`](#popular-titles) allow for
305+
filtering of returned entries by "types". The types are list of strings (or just a single
306+
string), like `SHOW`, `MOVIE`. You can check
307+
[`examples/`](https://github.com/Electronic-Mango/simple-justwatch-python-api/tree/main/examples)
308+
for field `object_type`, however the only "useful" ones seem `SHOW` and `MOVIE`. You can
309+
use types like `SHOW_EPISODE`, or `SHOW_SEASON`, however they seem to default to "TV
310+
shows" - the same as for type `SHOW`.
311+
312+
!!! warning "Types are not enforced, but must be valid"
313+
While possible types are not enforced by functions in this API, they still **must**
314+
be valid types in JustWatch API. Using unexpected type will result in HTTP error with
315+
code 422.

docs/usage.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,29 @@ while results := popular(count=page, offset=i):
502502
this method. Check
503503
[Maximum number of entries](caveats.md#maximum-number-of-entries) page for more
504504
details.
505+
506+
507+
508+
### Additional filtering in [`search`](#search-for-a-title) and [`popular`](#popular-titles)
509+
510+
[`search`](#search-for-a-title) and [`popular`](#popular-titles) functions allow for
511+
additional filtering of returned entries.
512+
513+
| Field | Description |
514+
| ------| ----------- |
515+
| `object_types` | Types like `SHOW` or `MOVIE`. Values are not enforced, but types like `SHOW_EPISODE` or `SHOW_SEASON` return shows anyway; like `SHOW`. While not enforced they **must** be valid types. It can be either a list of strings, or a single string. |
516+
| `min_year` | Minimum release year. |
517+
| `max_year` | Maximum release year. |
518+
519+
All filters are optional; when not configured (or set to `None`) the filtering is disabled.
520+
521+
```python
522+
from simplejustwatchapi import popular, search
523+
524+
# Get only currently popular TV shows:
525+
popular_shows = popular(object_types=["SHOW"])
526+
527+
# Search for movies between 1990 and 2010:
528+
movies = search("The Matrix", min_year=1990, max_year=2010, object_types="MOVIE")
529+
# object_types with single element can be either a list, or just a string.
530+
```

src/simplejustwatchapi/justwatch.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@
3434
| `providers` | Providers (like Netflix, Amazon Prime Video) for which offers should \
3535
returned. Requires 3-letter "short name". Check \
3636
[`providers`][simplejustwatchapi.justwatch.providers] for an example \
37-
of how you can get that value.
37+
of how you can get that value. |
38+
| `min_year` | Minimum release year of returned titles. |
39+
| `max_year` | Maximum release year of returned titles. |
40+
| `object_types` | Types of objects to filter for, it seems that only `SHOW` and \
41+
`MOVIE` are useful, but it's not strictly enforced. Types like \
42+
`SHOW_EPISODE`, or `SHOW_SEASON` can be used but they seem to \
43+
return shows, the same as `SHOW` type. |
3844
3945
Each function can raise two exceptions:
4046

0 commit comments

Comments
 (0)