simple-justwatch-python-api 0.17.1__tar.gz → 0.18.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/PKG-INFO +239 -24
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/README.md +238 -23
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/pyproject.toml +2 -1
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/src/simplejustwatchapi/__init__.py +4 -0
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/src/simplejustwatchapi/graphql.py +127 -15
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/src/simplejustwatchapi/justwatch.py +110 -4
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/src/simplejustwatchapi/query.py +128 -2
- simple_justwatch_python_api-0.18.1/src/simplejustwatchapi/tuples.py +242 -0
- simple_justwatch_python_api-0.17.1/src/simplejustwatchapi/tuples.py +0 -262
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.1}/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: simple-justwatch-python-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.1
|
|
4
4
|
Summary: A simple JustWatch Python API
|
|
5
5
|
Keywords: justwatch,api,graphql
|
|
6
6
|
Author: Electronic Mango
|
|
@@ -713,14 +713,24 @@ This project is managed by [uv](https://docs.astral.sh/uv/).
|
|
|
713
713
|
|
|
714
714
|
## Table of contents
|
|
715
715
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
716
|
+
- [Installation](#installation)
|
|
717
|
+
- [Usage](#usage)
|
|
718
|
+
- [Search](#search)
|
|
719
|
+
- [Popular](#popular)
|
|
720
|
+
- [Details](#details)
|
|
721
|
+
- [Seasons](#seasons)
|
|
722
|
+
- [Episodes](#episodes)
|
|
723
|
+
- [Offers for countries](#offers-for-countries)
|
|
724
|
+
- [Providers](#providers)
|
|
725
|
+
- [Data structures](#data-structures)
|
|
726
|
+
- [Locale, language, country](#locale-language-country)
|
|
727
|
+
- [Request complexity](#request-complexity)
|
|
728
|
+
- [Maximum number of entries](#maximum-number-of-entries)
|
|
729
|
+
- [Provider codes](#provider-codes)
|
|
730
|
+
- [`providers` function](#providers-function)
|
|
731
|
+
- [Query parameters from JustWatch](#query-parameters-from-justwatch)
|
|
732
|
+
- [Stored output from other functions with offers](#stored-output-from-other-functions-with-offers)
|
|
733
|
+
- [Disclaimer](#disclaimer)
|
|
724
734
|
|
|
725
735
|
|
|
726
736
|
## Installation
|
|
@@ -750,20 +760,28 @@ Example outputs from all functions are in [`examples/`](examples/) directory.
|
|
|
750
760
|
Search functions allows for searching entries based on a given title.
|
|
751
761
|
|
|
752
762
|
```python
|
|
753
|
-
from simplejustwatchapi
|
|
763
|
+
from simplejustwatchapi import search
|
|
754
764
|
|
|
755
|
-
results = search("title", "US", "en", 5, True)
|
|
765
|
+
results = search("title", "US", "en", 5, True, 0, {"nfx", "apv"})
|
|
756
766
|
```
|
|
757
767
|
|
|
758
|
-
|
|
768
|
+
No arguments are required.
|
|
759
769
|
|
|
760
|
-
| | Argument | Type | Required | Default value
|
|
761
|
-
|
|
762
|
-
| 1 | `title` | `str` |
|
|
763
|
-
| 2 | `country` | `str` | NO | `"US"`
|
|
764
|
-
| 3 | `language` | `str` | NO | `"en"`
|
|
765
|
-
| 4 | `count` | `int` | NO | `4`
|
|
766
|
-
| 5 | `best_only` | `bool` | NO | `True`
|
|
770
|
+
| | Argument | Type | Required | Default value | Description |
|
|
771
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
772
|
+
| 1 | `title` | `str` | NO | - | Title to look up |
|
|
773
|
+
| 2 | `country` | `str` | NO | `"US"` | Country to search for offers |
|
|
774
|
+
| 3 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
775
|
+
| 4 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
776
|
+
| 5 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
777
|
+
| 6 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
778
|
+
| 7 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
779
|
+
|
|
780
|
+
`title` is just a string to look up. If empty, or not provided, you'll get a selection of popular titles,
|
|
781
|
+
similar to [`popular`](#popular) function.
|
|
782
|
+
|
|
783
|
+
> **Note**: value of `title` isn't stripped, so passing a string
|
|
784
|
+
with multiple spaces will look them up. For more than 1 space it will (probably) always return an empty list.
|
|
767
785
|
|
|
768
786
|
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
769
787
|
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
@@ -776,6 +794,19 @@ If JustWatch GraphQL API returns fewer entries, then this function will also ret
|
|
|
776
794
|
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
777
795
|
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.
|
|
778
796
|
|
|
797
|
+
`offset` allows for very basic pagination, letting you get more data without running into [request complexity](#request-complexity).
|
|
798
|
+
It simply skips `offset` number of first entries (on the API side, nothing is done inside the library).
|
|
799
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
800
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
801
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
802
|
+
only up to 1999, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
803
|
+
|
|
804
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
805
|
+
It can be either a list, or (for single providers) a string.
|
|
806
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
807
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
808
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
809
|
+
|
|
779
810
|
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
780
811
|
|
|
781
812
|
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
@@ -783,6 +814,57 @@ For very large searches (high `count` value) I recommend using default `best_onl
|
|
|
783
814
|
Example function call and its output is in [`examples/search_output.py`](examples/search_output.py).
|
|
784
815
|
|
|
785
816
|
|
|
817
|
+
### Popular
|
|
818
|
+
Look up all currently popular titles.
|
|
819
|
+
The usage and output will be similar to [`search`](#search), function without any titles specified.
|
|
820
|
+
|
|
821
|
+
```python
|
|
822
|
+
from simplejustwatchapi import popular
|
|
823
|
+
|
|
824
|
+
results = popular("US", "en", 5, True, 0, {"nfx", "apv"})
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
No arguments are required.
|
|
828
|
+
|
|
829
|
+
| | Argument | Type | Required | Default value | Description |
|
|
830
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
831
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for titles |
|
|
832
|
+
| 2 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
833
|
+
| 3 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
834
|
+
| 4 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
835
|
+
| 5 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
836
|
+
| 6 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
837
|
+
|
|
838
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
839
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
840
|
+
|
|
841
|
+
`language` is a **ISO 639-1** (usually) 2-letter code, lowercase, e.g. `en`, `fr`.
|
|
842
|
+
|
|
843
|
+
`count` determines **up to** how many entries should be returned.
|
|
844
|
+
If JustWatch GraphQL API returns fewer entries, then this function will also return fewer values.
|
|
845
|
+
|
|
846
|
+
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
847
|
+
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.
|
|
848
|
+
|
|
849
|
+
`offset` allows for very basic pagination letting you get more data without running into [request complexity](#request-complexity).
|
|
850
|
+
It simply skips first entries (on the API side, nothing is done inside the library).
|
|
851
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
852
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
853
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
854
|
+
only up to 2000, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
855
|
+
|
|
856
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
857
|
+
It can be either a list, or (for single providers) a string.
|
|
858
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
859
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
860
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
861
|
+
|
|
862
|
+
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
863
|
+
|
|
864
|
+
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
865
|
+
|
|
866
|
+
Example function call and its output is in [`examples/popular_output.py`](examples/popular_output.py).
|
|
867
|
+
|
|
786
868
|
### Details
|
|
787
869
|
|
|
788
870
|
Details function allows for looking up details for a single entry via its node ID.
|
|
@@ -796,7 +878,7 @@ If you want to get seasons/episodes you can use the ID from [`search`](#search)
|
|
|
796
878
|
|
|
797
879
|
Usage is similar to [`search`](#search) function, just without `count` argument:
|
|
798
880
|
```python
|
|
799
|
-
from simplejustwatchapi
|
|
881
|
+
from simplejustwatchapi import details
|
|
800
882
|
|
|
801
883
|
results = details("nodeID", "US", "en", False)
|
|
802
884
|
```
|
|
@@ -837,7 +919,7 @@ Each season contains similar data to the [`details`](#details) function, with ad
|
|
|
837
919
|
|
|
838
920
|
Usage also matches [`details`](#details) function:
|
|
839
921
|
```python
|
|
840
|
-
from simplejustwatchapi
|
|
922
|
+
from simplejustwatchapi import seasons
|
|
841
923
|
|
|
842
924
|
results = seasons("nodeID", "US", "en", False)
|
|
843
925
|
```
|
|
@@ -861,7 +943,7 @@ Node/season ID can be taken from output of the [`seasons`](#seasons) function.
|
|
|
861
943
|
|
|
862
944
|
Usage matches [`details`](#details) function:
|
|
863
945
|
```python
|
|
864
|
-
from simplejustwatchapi
|
|
946
|
+
from simplejustwatchapi import seasons
|
|
865
947
|
|
|
866
948
|
results = seasons("nodeID", "US", "en", False)
|
|
867
949
|
```
|
|
@@ -887,7 +969,7 @@ It allows specifying a set of countries, instead of a single one.
|
|
|
887
969
|
This way you can simultaneously look up offers for multiple countries.
|
|
888
970
|
|
|
889
971
|
```python
|
|
890
|
-
from simplejustwatchapi
|
|
972
|
+
from simplejustwatchapi import offers_for_countries
|
|
891
973
|
|
|
892
974
|
results = offers_for_countries("nodeID", {"US", "UK", "CA"}, "en", True)
|
|
893
975
|
```
|
|
@@ -908,8 +990,35 @@ Returned value `dict[str, list[Offer]]`, where key is country given as argument
|
|
|
908
990
|
Example function call and its output is in [`examples/offers_for_countries_output.py`](examples/offers_for_countries_output.py).
|
|
909
991
|
|
|
910
992
|
|
|
993
|
+
### Providers
|
|
994
|
+
|
|
995
|
+
Get all available service providers ("Netflix", "Amazon Prime Video, etc.) for a given country.
|
|
911
996
|
|
|
912
|
-
|
|
997
|
+
```python
|
|
998
|
+
from simplejustwatchapi import providers
|
|
999
|
+
|
|
1000
|
+
results = providers("US")
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
| | Argument | Type | Required | Default value | Description |
|
|
1004
|
+
|---|-------------|--------|----------|---------------|---------------------------------|
|
|
1005
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for providers |
|
|
1006
|
+
|
|
1007
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
1008
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
1009
|
+
|
|
1010
|
+
Returned value is a list of `OfferPackage` tuples.
|
|
1011
|
+
Initially they were meant to be used for `Offer` in `MediaEntry`/`Episode`, however the data structure
|
|
1012
|
+
matches output here, so it's reused.
|
|
1013
|
+
|
|
1014
|
+
You can use this function to get values for providers for [`search`](#search) and [`popular`](#popular) functions,
|
|
1015
|
+
the `short_name` field in returned `OfferPackage` tuples is the exact 3-letter code needed there.
|
|
1016
|
+
|
|
1017
|
+
Example function call and its output is in [`examples/providers_output.py`](examples/providers_output.py).
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
## Data structures
|
|
913
1022
|
|
|
914
1023
|
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).
|
|
915
1024
|
|
|
@@ -956,6 +1065,112 @@ Using `best_only=True` should alleviate the issue somewhat, so for very large re
|
|
|
956
1065
|
|
|
957
1066
|
|
|
958
1067
|
|
|
1068
|
+
## Maximum number of entries
|
|
1069
|
+
|
|
1070
|
+
The JustWatch API itself won't allow for getting more than 1999 entries, through `count` and `offset`, regardless of request complexity.
|
|
1071
|
+
If you try to get the 2000th entry the API (and functions in this libary) will return an empty list.
|
|
1072
|
+
|
|
1073
|
+
**If you try to access over the 1999th entry you won't get *up to* 1999 entries, you'll get an empty list.**
|
|
1074
|
+
|
|
1075
|
+
For example, this will get you entries 1990 - 1999 - a 9 element list of `MediaEntry`, as expected:
|
|
1076
|
+
|
|
1077
|
+
```python
|
|
1078
|
+
from simplejustwatchapi import search
|
|
1079
|
+
|
|
1080
|
+
results = search("title", count=9, offset=1990)
|
|
1081
|
+
# len(results) == 9, as expected
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
But trying to get 1990 - 2000 will result in an empty list:
|
|
1085
|
+
|
|
1086
|
+
```python
|
|
1087
|
+
from simplejustwatchapi import search
|
|
1088
|
+
|
|
1089
|
+
results = search("title", count=10, offset=1990)
|
|
1090
|
+
# len(results) == 0, API responded with empty list
|
|
1091
|
+
```
|
|
1092
|
+
|
|
1093
|
+
Overshooting will also result in an empty list:
|
|
1094
|
+
|
|
1095
|
+
```python
|
|
1096
|
+
from simplejustwatchapi import search
|
|
1097
|
+
|
|
1098
|
+
results = search("title", count=100, offset=1950)
|
|
1099
|
+
# len(results) == 0, API responded with empty list
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
Interestingly, you'll still hit [too high request complexity](#request-complexity)
|
|
1103
|
+
for too high values of `count`, even though you'd get an empty list anyway:
|
|
1104
|
+
|
|
1105
|
+
```python
|
|
1106
|
+
from simplejustwatchapi import search
|
|
1107
|
+
|
|
1108
|
+
results = search("title", count=200, offset=1950)
|
|
1109
|
+
# Errors out due to complexity
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
## Provider codes
|
|
1115
|
+
|
|
1116
|
+
One note to keep in mind - the codes can be different for different countries.
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
### [`providers`](#providers) function
|
|
1120
|
+
|
|
1121
|
+
The easiest way of getting all provider codes for filtering in [`search`](#search) and [`popular`](#popular) functions
|
|
1122
|
+
is through [`providers`](#providers) function, for example:
|
|
1123
|
+
|
|
1124
|
+
```python
|
|
1125
|
+
from simplejustwatchapi import popular, providers
|
|
1126
|
+
|
|
1127
|
+
codes = [
|
|
1128
|
+
package.short_name
|
|
1129
|
+
for package
|
|
1130
|
+
in providers("GB") # Look up all providers in the UK.
|
|
1131
|
+
if package.name in ("Netflix", "Amazon Prime Video") # Only get codes for specific providers
|
|
1132
|
+
]
|
|
1133
|
+
|
|
1134
|
+
# codes == ["nfx", "amp"]
|
|
1135
|
+
|
|
1136
|
+
# Get popular titles only for selected providers:
|
|
1137
|
+
popular_netflix_amazon = popular(providers=codes)
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
### Query parameters from JustWatch
|
|
1142
|
+
|
|
1143
|
+
You can also get them by going to [JustWatch main page](https://www.justwatch.com/)
|
|
1144
|
+
and selecting **at least 2** of available services.
|
|
1145
|
+
**You need 2**, for 1 you'll get its full name.
|
|
1146
|
+
Only for multiple you'll get the needed codes as `?providers=<code1>+<code2>+...` query parameter,
|
|
1147
|
+
for example on US version the URL when selecting "Netflix" and "Amazon Prime Video" is:
|
|
1148
|
+
|
|
1149
|
+
```url
|
|
1150
|
+
https://www.justwatch.com/us?providers=nfx,prv
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
So the codes for them are `nfx` and `prv` for the US.
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
### Stored output from other functions with offers
|
|
1157
|
+
|
|
1158
|
+
The codes are also returned when looking up offers (through pretty much any function aside from `providers`) through `OfferPackage` and its `short_name` field.
|
|
1159
|
+
For example, to get a `dict` "**full name**": "**code**" you can:
|
|
1160
|
+
|
|
1161
|
+
```python
|
|
1162
|
+
from simplejustwatchapi import search
|
|
1163
|
+
|
|
1164
|
+
results = search("title", "US", "en", 5, True)
|
|
1165
|
+
name_to_code_dict = {
|
|
1166
|
+
offer.package.name: offer.package.short_name # Get name and short_name/code from packages
|
|
1167
|
+
for entry in results # Iterate all entries
|
|
1168
|
+
for offer in entry.offers # Iterate all offers per entry
|
|
1169
|
+
}
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
959
1174
|
## Disclaimer
|
|
960
1175
|
|
|
961
1176
|
This API is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with JustWatch.
|
|
@@ -16,14 +16,24 @@ This project is managed by [uv](https://docs.astral.sh/uv/).
|
|
|
16
16
|
|
|
17
17
|
## Table of contents
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
- [Installation](#installation)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [Search](#search)
|
|
22
|
+
- [Popular](#popular)
|
|
23
|
+
- [Details](#details)
|
|
24
|
+
- [Seasons](#seasons)
|
|
25
|
+
- [Episodes](#episodes)
|
|
26
|
+
- [Offers for countries](#offers-for-countries)
|
|
27
|
+
- [Providers](#providers)
|
|
28
|
+
- [Data structures](#data-structures)
|
|
29
|
+
- [Locale, language, country](#locale-language-country)
|
|
30
|
+
- [Request complexity](#request-complexity)
|
|
31
|
+
- [Maximum number of entries](#maximum-number-of-entries)
|
|
32
|
+
- [Provider codes](#provider-codes)
|
|
33
|
+
- [`providers` function](#providers-function)
|
|
34
|
+
- [Query parameters from JustWatch](#query-parameters-from-justwatch)
|
|
35
|
+
- [Stored output from other functions with offers](#stored-output-from-other-functions-with-offers)
|
|
36
|
+
- [Disclaimer](#disclaimer)
|
|
27
37
|
|
|
28
38
|
|
|
29
39
|
## Installation
|
|
@@ -53,20 +63,28 @@ Example outputs from all functions are in [`examples/`](examples/) directory.
|
|
|
53
63
|
Search functions allows for searching entries based on a given title.
|
|
54
64
|
|
|
55
65
|
```python
|
|
56
|
-
from simplejustwatchapi
|
|
66
|
+
from simplejustwatchapi import search
|
|
57
67
|
|
|
58
|
-
results = search("title", "US", "en", 5, True)
|
|
68
|
+
results = search("title", "US", "en", 5, True, 0, {"nfx", "apv"})
|
|
59
69
|
```
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
No arguments are required.
|
|
62
72
|
|
|
63
|
-
| | Argument | Type | Required | Default value
|
|
64
|
-
|
|
65
|
-
| 1 | `title` | `str` |
|
|
66
|
-
| 2 | `country` | `str` | NO | `"US"`
|
|
67
|
-
| 3 | `language` | `str` | NO | `"en"`
|
|
68
|
-
| 4 | `count` | `int` | NO | `4`
|
|
69
|
-
| 5 | `best_only` | `bool` | NO | `True`
|
|
73
|
+
| | Argument | Type | Required | Default value | Description |
|
|
74
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
75
|
+
| 1 | `title` | `str` | NO | - | Title to look up |
|
|
76
|
+
| 2 | `country` | `str` | NO | `"US"` | Country to search for offers |
|
|
77
|
+
| 3 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
78
|
+
| 4 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
79
|
+
| 5 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
80
|
+
| 6 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
81
|
+
| 7 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
82
|
+
|
|
83
|
+
`title` is just a string to look up. If empty, or not provided, you'll get a selection of popular titles,
|
|
84
|
+
similar to [`popular`](#popular) function.
|
|
85
|
+
|
|
86
|
+
> **Note**: value of `title` isn't stripped, so passing a string
|
|
87
|
+
with multiple spaces will look them up. For more than 1 space it will (probably) always return an empty list.
|
|
70
88
|
|
|
71
89
|
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
72
90
|
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
@@ -79,6 +97,19 @@ If JustWatch GraphQL API returns fewer entries, then this function will also ret
|
|
|
79
97
|
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
80
98
|
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.
|
|
81
99
|
|
|
100
|
+
`offset` allows for very basic pagination, letting you get more data without running into [request complexity](#request-complexity).
|
|
101
|
+
It simply skips `offset` number of first entries (on the API side, nothing is done inside the library).
|
|
102
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
103
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
104
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
105
|
+
only up to 1999, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
106
|
+
|
|
107
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
108
|
+
It can be either a list, or (for single providers) a string.
|
|
109
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
110
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
111
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
112
|
+
|
|
82
113
|
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
83
114
|
|
|
84
115
|
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
@@ -86,6 +117,57 @@ For very large searches (high `count` value) I recommend using default `best_onl
|
|
|
86
117
|
Example function call and its output is in [`examples/search_output.py`](examples/search_output.py).
|
|
87
118
|
|
|
88
119
|
|
|
120
|
+
### Popular
|
|
121
|
+
Look up all currently popular titles.
|
|
122
|
+
The usage and output will be similar to [`search`](#search), function without any titles specified.
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from simplejustwatchapi import popular
|
|
126
|
+
|
|
127
|
+
results = popular("US", "en", 5, True, 0, {"nfx", "apv"})
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
No arguments are required.
|
|
131
|
+
|
|
132
|
+
| | Argument | Type | Required | Default value | Description |
|
|
133
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
134
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for titles |
|
|
135
|
+
| 2 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
136
|
+
| 3 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
137
|
+
| 4 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
138
|
+
| 5 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
139
|
+
| 6 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
140
|
+
|
|
141
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
142
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
143
|
+
|
|
144
|
+
`language` is a **ISO 639-1** (usually) 2-letter code, lowercase, e.g. `en`, `fr`.
|
|
145
|
+
|
|
146
|
+
`count` determines **up to** how many entries should be returned.
|
|
147
|
+
If JustWatch GraphQL API returns fewer entries, then this function will also return fewer values.
|
|
148
|
+
|
|
149
|
+
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
150
|
+
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.
|
|
151
|
+
|
|
152
|
+
`offset` allows for very basic pagination letting you get more data without running into [request complexity](#request-complexity).
|
|
153
|
+
It simply skips first entries (on the API side, nothing is done inside the library).
|
|
154
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
155
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
156
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
157
|
+
only up to 2000, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
158
|
+
|
|
159
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
160
|
+
It can be either a list, or (for single providers) a string.
|
|
161
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
162
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
163
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
164
|
+
|
|
165
|
+
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
166
|
+
|
|
167
|
+
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
168
|
+
|
|
169
|
+
Example function call and its output is in [`examples/popular_output.py`](examples/popular_output.py).
|
|
170
|
+
|
|
89
171
|
### Details
|
|
90
172
|
|
|
91
173
|
Details function allows for looking up details for a single entry via its node ID.
|
|
@@ -99,7 +181,7 @@ If you want to get seasons/episodes you can use the ID from [`search`](#search)
|
|
|
99
181
|
|
|
100
182
|
Usage is similar to [`search`](#search) function, just without `count` argument:
|
|
101
183
|
```python
|
|
102
|
-
from simplejustwatchapi
|
|
184
|
+
from simplejustwatchapi import details
|
|
103
185
|
|
|
104
186
|
results = details("nodeID", "US", "en", False)
|
|
105
187
|
```
|
|
@@ -140,7 +222,7 @@ Each season contains similar data to the [`details`](#details) function, with ad
|
|
|
140
222
|
|
|
141
223
|
Usage also matches [`details`](#details) function:
|
|
142
224
|
```python
|
|
143
|
-
from simplejustwatchapi
|
|
225
|
+
from simplejustwatchapi import seasons
|
|
144
226
|
|
|
145
227
|
results = seasons("nodeID", "US", "en", False)
|
|
146
228
|
```
|
|
@@ -164,7 +246,7 @@ Node/season ID can be taken from output of the [`seasons`](#seasons) function.
|
|
|
164
246
|
|
|
165
247
|
Usage matches [`details`](#details) function:
|
|
166
248
|
```python
|
|
167
|
-
from simplejustwatchapi
|
|
249
|
+
from simplejustwatchapi import seasons
|
|
168
250
|
|
|
169
251
|
results = seasons("nodeID", "US", "en", False)
|
|
170
252
|
```
|
|
@@ -190,7 +272,7 @@ It allows specifying a set of countries, instead of a single one.
|
|
|
190
272
|
This way you can simultaneously look up offers for multiple countries.
|
|
191
273
|
|
|
192
274
|
```python
|
|
193
|
-
from simplejustwatchapi
|
|
275
|
+
from simplejustwatchapi import offers_for_countries
|
|
194
276
|
|
|
195
277
|
results = offers_for_countries("nodeID", {"US", "UK", "CA"}, "en", True)
|
|
196
278
|
```
|
|
@@ -211,8 +293,35 @@ Returned value `dict[str, list[Offer]]`, where key is country given as argument
|
|
|
211
293
|
Example function call and its output is in [`examples/offers_for_countries_output.py`](examples/offers_for_countries_output.py).
|
|
212
294
|
|
|
213
295
|
|
|
296
|
+
### Providers
|
|
297
|
+
|
|
298
|
+
Get all available service providers ("Netflix", "Amazon Prime Video, etc.) for a given country.
|
|
214
299
|
|
|
215
|
-
|
|
300
|
+
```python
|
|
301
|
+
from simplejustwatchapi import providers
|
|
302
|
+
|
|
303
|
+
results = providers("US")
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
| | Argument | Type | Required | Default value | Description |
|
|
307
|
+
|---|-------------|--------|----------|---------------|---------------------------------|
|
|
308
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for providers |
|
|
309
|
+
|
|
310
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
311
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
312
|
+
|
|
313
|
+
Returned value is a list of `OfferPackage` tuples.
|
|
314
|
+
Initially they were meant to be used for `Offer` in `MediaEntry`/`Episode`, however the data structure
|
|
315
|
+
matches output here, so it's reused.
|
|
316
|
+
|
|
317
|
+
You can use this function to get values for providers for [`search`](#search) and [`popular`](#popular) functions,
|
|
318
|
+
the `short_name` field in returned `OfferPackage` tuples is the exact 3-letter code needed there.
|
|
319
|
+
|
|
320
|
+
Example function call and its output is in [`examples/providers_output.py`](examples/providers_output.py).
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
## Data structures
|
|
216
325
|
|
|
217
326
|
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).
|
|
218
327
|
|
|
@@ -259,6 +368,112 @@ Using `best_only=True` should alleviate the issue somewhat, so for very large re
|
|
|
259
368
|
|
|
260
369
|
|
|
261
370
|
|
|
371
|
+
## Maximum number of entries
|
|
372
|
+
|
|
373
|
+
The JustWatch API itself won't allow for getting more than 1999 entries, through `count` and `offset`, regardless of request complexity.
|
|
374
|
+
If you try to get the 2000th entry the API (and functions in this libary) will return an empty list.
|
|
375
|
+
|
|
376
|
+
**If you try to access over the 1999th entry you won't get *up to* 1999 entries, you'll get an empty list.**
|
|
377
|
+
|
|
378
|
+
For example, this will get you entries 1990 - 1999 - a 9 element list of `MediaEntry`, as expected:
|
|
379
|
+
|
|
380
|
+
```python
|
|
381
|
+
from simplejustwatchapi import search
|
|
382
|
+
|
|
383
|
+
results = search("title", count=9, offset=1990)
|
|
384
|
+
# len(results) == 9, as expected
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
But trying to get 1990 - 2000 will result in an empty list:
|
|
388
|
+
|
|
389
|
+
```python
|
|
390
|
+
from simplejustwatchapi import search
|
|
391
|
+
|
|
392
|
+
results = search("title", count=10, offset=1990)
|
|
393
|
+
# len(results) == 0, API responded with empty list
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Overshooting will also result in an empty list:
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
from simplejustwatchapi import search
|
|
400
|
+
|
|
401
|
+
results = search("title", count=100, offset=1950)
|
|
402
|
+
# len(results) == 0, API responded with empty list
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Interestingly, you'll still hit [too high request complexity](#request-complexity)
|
|
406
|
+
for too high values of `count`, even though you'd get an empty list anyway:
|
|
407
|
+
|
|
408
|
+
```python
|
|
409
|
+
from simplejustwatchapi import search
|
|
410
|
+
|
|
411
|
+
results = search("title", count=200, offset=1950)
|
|
412
|
+
# Errors out due to complexity
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
## Provider codes
|
|
418
|
+
|
|
419
|
+
One note to keep in mind - the codes can be different for different countries.
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
### [`providers`](#providers) function
|
|
423
|
+
|
|
424
|
+
The easiest way of getting all provider codes for filtering in [`search`](#search) and [`popular`](#popular) functions
|
|
425
|
+
is through [`providers`](#providers) function, for example:
|
|
426
|
+
|
|
427
|
+
```python
|
|
428
|
+
from simplejustwatchapi import popular, providers
|
|
429
|
+
|
|
430
|
+
codes = [
|
|
431
|
+
package.short_name
|
|
432
|
+
for package
|
|
433
|
+
in providers("GB") # Look up all providers in the UK.
|
|
434
|
+
if package.name in ("Netflix", "Amazon Prime Video") # Only get codes for specific providers
|
|
435
|
+
]
|
|
436
|
+
|
|
437
|
+
# codes == ["nfx", "amp"]
|
|
438
|
+
|
|
439
|
+
# Get popular titles only for selected providers:
|
|
440
|
+
popular_netflix_amazon = popular(providers=codes)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
### Query parameters from JustWatch
|
|
445
|
+
|
|
446
|
+
You can also get them by going to [JustWatch main page](https://www.justwatch.com/)
|
|
447
|
+
and selecting **at least 2** of available services.
|
|
448
|
+
**You need 2**, for 1 you'll get its full name.
|
|
449
|
+
Only for multiple you'll get the needed codes as `?providers=<code1>+<code2>+...` query parameter,
|
|
450
|
+
for example on US version the URL when selecting "Netflix" and "Amazon Prime Video" is:
|
|
451
|
+
|
|
452
|
+
```url
|
|
453
|
+
https://www.justwatch.com/us?providers=nfx,prv
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
So the codes for them are `nfx` and `prv` for the US.
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
### Stored output from other functions with offers
|
|
460
|
+
|
|
461
|
+
The codes are also returned when looking up offers (through pretty much any function aside from `providers`) through `OfferPackage` and its `short_name` field.
|
|
462
|
+
For example, to get a `dict` "**full name**": "**code**" you can:
|
|
463
|
+
|
|
464
|
+
```python
|
|
465
|
+
from simplejustwatchapi import search
|
|
466
|
+
|
|
467
|
+
results = search("title", "US", "en", 5, True)
|
|
468
|
+
name_to_code_dict = {
|
|
469
|
+
offer.package.name: offer.package.short_name # Get name and short_name/code from packages
|
|
470
|
+
for entry in results # Iterate all entries
|
|
471
|
+
for offer in entry.offers # Iterate all offers per entry
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
262
477
|
## Disclaimer
|
|
263
478
|
|
|
264
479
|
This API is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with JustWatch.
|