|
8 | 8 | [](https://coveralls.io/github/Electronic-Mango/simple-justwatch-python-api?branch=main) |
9 | 9 | [](https://pypi.org/project/simple-justwatch-python-api/) |
10 | 10 |
|
11 | | -A simple unofficial JustWatch Python API which uses [`GraphQL`](https://graphql.org/) to access JustWatch data. |
| 11 | +A simple unofficial JustWatch Python API which uses [`GraphQL`](https://graphql.org/) to access JustWatch data, built with [`httpx`](https://www.python-httpx.org/) and `Python3.11`. |
12 | 12 |
|
13 | | -Built with [`httpx`](https://www.python-httpx.org/) and `Python3.11`. |
| 13 | + |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +Project is available in [PyPi](https://pypi.org/project/simple-justwatch-python-api/): |
| 18 | +```bash |
| 19 | +pip install simple-justwatch-python-api |
| 20 | +``` |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +Currently, there's only one function available - search JustWatch: |
| 27 | +```python |
| 28 | +from simplejustwatchpythonapi.justwatch import search |
| 29 | + |
| 30 | +results = search("title", "US", "en", 5, True) |
| 31 | +``` |
| 32 | + |
| 33 | +Only the first argument is required, it specifies a title to search. |
| 34 | + |
| 35 | +Other arguments in order are: |
| 36 | +1. `str` country code to search for offers, have to be a 2-letter code, e.g. `US`, `GB`, `FR`, etc. |
| 37 | +It should be uppercase, however lowercase codes are automatically converted to uppercase. By default `US` is used. |
| 38 | +2. `str` language code, usually 2-letter lowercase code, e.g. `en`, `fr`, etc. By default `en` is used. |
| 39 | +3. `int` how many results should be returned. Actual response can contain fewer entries if fewer are found. |
| 40 | +By default `4` is used. |
| 41 | +4. `bool` specify if only best offers should be returned (`True`) or all offers (`False`). |
| 42 | +By default `True` is used. |
| 43 | + |
| 44 | +Returned value is a list of `MediaEntry` objects: |
| 45 | +```python |
| 46 | +class MediaEntry(NamedTuple): |
| 47 | + entry_id: str |
| 48 | + object_id: int |
| 49 | + object_type: str |
| 50 | + title: str |
| 51 | + url: str |
| 52 | + release_year: int |
| 53 | + release_date: str |
| 54 | + genres: list[str] |
| 55 | + imdb_id: str | None |
| 56 | + poster: str |
| 57 | + backdrops: list[str] |
| 58 | + offers: list[Offer] |
| 59 | + |
| 60 | +class Offer(NamedTuple): |
| 61 | + monetization_type: str |
| 62 | + presentation_type: str |
| 63 | + url: str |
| 64 | + price_string: str | None |
| 65 | + price_value: float | None |
| 66 | + price_currency: str |
| 67 | + name: str |
| 68 | + technical_name: str |
| 69 | + icon: str |
| 70 | +``` |
14 | 71 |
|
15 | 72 |
|
16 | 73 |
|
|
0 commit comments