simple-justwatch-python-api 0.17.1__tar.gz → 0.18.0__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.0}/PKG-INFO +221 -16
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.0}/README.md +220 -15
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.0}/pyproject.toml +2 -1
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.0}/src/simplejustwatchapi/__init__.py +4 -0
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.0}/src/simplejustwatchapi/graphql.py +127 -15
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.0}/src/simplejustwatchapi/justwatch.py +110 -4
- {simple_justwatch_python_api-0.17.1 → simple_justwatch_python_api-0.18.0}/src/simplejustwatchapi/query.py +128 -2
- simple_justwatch_python_api-0.18.0/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.0}/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.0
|
|
4
4
|
Summary: A simple JustWatch Python API
|
|
5
5
|
Keywords: justwatch,api,graphql
|
|
6
6
|
Author: Electronic Mango
|
|
@@ -750,20 +750,28 @@ Example outputs from all functions are in [`examples/`](examples/) directory.
|
|
|
750
750
|
Search functions allows for searching entries based on a given title.
|
|
751
751
|
|
|
752
752
|
```python
|
|
753
|
-
from simplejustwatchapi
|
|
753
|
+
from simplejustwatchapi import search
|
|
754
754
|
|
|
755
|
-
results = search("title", "US", "en", 5, True)
|
|
755
|
+
results = search("title", "US", "en", 5, True, 0, {"nfx", "apv"})
|
|
756
756
|
```
|
|
757
757
|
|
|
758
|
-
|
|
758
|
+
No arguments are required.
|
|
759
759
|
|
|
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`
|
|
760
|
+
| | Argument | Type | Required | Default value | Description |
|
|
761
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
762
|
+
| 1 | `title` | `str` | NO | - | Title to look up |
|
|
763
|
+
| 2 | `country` | `str` | NO | `"US"` | Country to search for offers |
|
|
764
|
+
| 3 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
765
|
+
| 4 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
766
|
+
| 5 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
767
|
+
| 6 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
768
|
+
| 7 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
769
|
+
|
|
770
|
+
`title` is just a string to look up. If empty, or not provided, you'll get a selection of popular titles,
|
|
771
|
+
similar to [`popular`](#popular) function.
|
|
772
|
+
|
|
773
|
+
> **Note**: value of `title` isn't stripped, so passing a string
|
|
774
|
+
with multiple spaces will look them up. For more than 1 space it will (probably) always return an empty list.
|
|
767
775
|
|
|
768
776
|
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
769
777
|
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
@@ -776,6 +784,19 @@ If JustWatch GraphQL API returns fewer entries, then this function will also ret
|
|
|
776
784
|
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
777
785
|
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
786
|
|
|
787
|
+
`offset` allows for very basic pagination, letting you get more data without running into [request complexity](#request-complexity).
|
|
788
|
+
It simply skips `offset` number of first entries (on the API side, nothing is done inside the library).
|
|
789
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
790
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
791
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
792
|
+
only up to 1999, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
793
|
+
|
|
794
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
795
|
+
It can be either a list, or (for single providers) a string.
|
|
796
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
797
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
798
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
799
|
+
|
|
779
800
|
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
780
801
|
|
|
781
802
|
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
@@ -783,6 +804,57 @@ For very large searches (high `count` value) I recommend using default `best_onl
|
|
|
783
804
|
Example function call and its output is in [`examples/search_output.py`](examples/search_output.py).
|
|
784
805
|
|
|
785
806
|
|
|
807
|
+
### Popular
|
|
808
|
+
Look up all currently popular titles.
|
|
809
|
+
The usage and output will be similar to [`search`](#search), function without any titles specified.
|
|
810
|
+
|
|
811
|
+
```python
|
|
812
|
+
from simplejustwatchapi import popular
|
|
813
|
+
|
|
814
|
+
results = popular("US", "en", 5, True, 0, {"nfx", "apv"})
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
No arguments are required.
|
|
818
|
+
|
|
819
|
+
| | Argument | Type | Required | Default value | Description |
|
|
820
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
821
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for titles |
|
|
822
|
+
| 2 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
823
|
+
| 3 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
824
|
+
| 4 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
825
|
+
| 5 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
826
|
+
| 6 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
827
|
+
|
|
828
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
829
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
830
|
+
|
|
831
|
+
`language` is a **ISO 639-1** (usually) 2-letter code, lowercase, e.g. `en`, `fr`.
|
|
832
|
+
|
|
833
|
+
`count` determines **up to** how many entries should be returned.
|
|
834
|
+
If JustWatch GraphQL API returns fewer entries, then this function will also return fewer values.
|
|
835
|
+
|
|
836
|
+
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
837
|
+
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.
|
|
838
|
+
|
|
839
|
+
`offset` allows for very basic pagination letting you get more data without running into [request complexity](#request-complexity).
|
|
840
|
+
It simply skips first entries (on the API side, nothing is done inside the library).
|
|
841
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
842
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
843
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
844
|
+
only up to 2000, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
845
|
+
|
|
846
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
847
|
+
It can be either a list, or (for single providers) a string.
|
|
848
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
849
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
850
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
851
|
+
|
|
852
|
+
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
853
|
+
|
|
854
|
+
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
855
|
+
|
|
856
|
+
Example function call and its output is in [`examples/popular_output.py`](examples/popular_output.py).
|
|
857
|
+
|
|
786
858
|
### Details
|
|
787
859
|
|
|
788
860
|
Details function allows for looking up details for a single entry via its node ID.
|
|
@@ -796,7 +868,7 @@ If you want to get seasons/episodes you can use the ID from [`search`](#search)
|
|
|
796
868
|
|
|
797
869
|
Usage is similar to [`search`](#search) function, just without `count` argument:
|
|
798
870
|
```python
|
|
799
|
-
from simplejustwatchapi
|
|
871
|
+
from simplejustwatchapi import details
|
|
800
872
|
|
|
801
873
|
results = details("nodeID", "US", "en", False)
|
|
802
874
|
```
|
|
@@ -837,7 +909,7 @@ Each season contains similar data to the [`details`](#details) function, with ad
|
|
|
837
909
|
|
|
838
910
|
Usage also matches [`details`](#details) function:
|
|
839
911
|
```python
|
|
840
|
-
from simplejustwatchapi
|
|
912
|
+
from simplejustwatchapi import seasons
|
|
841
913
|
|
|
842
914
|
results = seasons("nodeID", "US", "en", False)
|
|
843
915
|
```
|
|
@@ -861,7 +933,7 @@ Node/season ID can be taken from output of the [`seasons`](#seasons) function.
|
|
|
861
933
|
|
|
862
934
|
Usage matches [`details`](#details) function:
|
|
863
935
|
```python
|
|
864
|
-
from simplejustwatchapi
|
|
936
|
+
from simplejustwatchapi import seasons
|
|
865
937
|
|
|
866
938
|
results = seasons("nodeID", "US", "en", False)
|
|
867
939
|
```
|
|
@@ -887,7 +959,7 @@ It allows specifying a set of countries, instead of a single one.
|
|
|
887
959
|
This way you can simultaneously look up offers for multiple countries.
|
|
888
960
|
|
|
889
961
|
```python
|
|
890
|
-
from simplejustwatchapi
|
|
962
|
+
from simplejustwatchapi import offers_for_countries
|
|
891
963
|
|
|
892
964
|
results = offers_for_countries("nodeID", {"US", "UK", "CA"}, "en", True)
|
|
893
965
|
```
|
|
@@ -908,8 +980,35 @@ Returned value `dict[str, list[Offer]]`, where key is country given as argument
|
|
|
908
980
|
Example function call and its output is in [`examples/offers_for_countries_output.py`](examples/offers_for_countries_output.py).
|
|
909
981
|
|
|
910
982
|
|
|
983
|
+
### Providers
|
|
984
|
+
|
|
985
|
+
Get all available service providers ("Netflix", "Amazon Prime Video, etc.) for a given country.
|
|
911
986
|
|
|
912
|
-
|
|
987
|
+
```python
|
|
988
|
+
from simplejustwatchapi import providers
|
|
989
|
+
|
|
990
|
+
results = providers("US")
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
| | Argument | Type | Required | Default value | Description |
|
|
994
|
+
|---|-------------|--------|----------|---------------|---------------------------------|
|
|
995
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for providers |
|
|
996
|
+
|
|
997
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
998
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
999
|
+
|
|
1000
|
+
Returned value is a list of `OfferPackage` tuples.
|
|
1001
|
+
Initially they were meant to be used for `Offer` in `MediaEntry`/`Episode`, however the data structure
|
|
1002
|
+
matches output here, so it's reused.
|
|
1003
|
+
|
|
1004
|
+
You can use this function to get values for providers for [`search`](#search) and [`popular`](#popular) functions,
|
|
1005
|
+
the `short_name` field in returned `OfferPackage` tuples is the exact 3-letter code needed there.
|
|
1006
|
+
|
|
1007
|
+
Example function call and its output is in [`examples/providers_output.py`](examples/providers_output.py).
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
## Data structures
|
|
913
1012
|
|
|
914
1013
|
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
1014
|
|
|
@@ -956,6 +1055,112 @@ Using `best_only=True` should alleviate the issue somewhat, so for very large re
|
|
|
956
1055
|
|
|
957
1056
|
|
|
958
1057
|
|
|
1058
|
+
## Maximum number of entries
|
|
1059
|
+
|
|
1060
|
+
The JustWatch API itself won't allow for getting more than 1999 entries, through `count` and `offset`, regardless of request complexity.
|
|
1061
|
+
If you try to get the 2000th entry the API (and functions in this libary) will return an empty list.
|
|
1062
|
+
|
|
1063
|
+
**If you try to access over the 1999th entry you won't get *up to* 1999 entries, you'll get an empty list.**
|
|
1064
|
+
|
|
1065
|
+
For example, this will get you entries 1990 - 1999 - a 9 element list of `MediaEntry`, as expected:
|
|
1066
|
+
|
|
1067
|
+
```python
|
|
1068
|
+
from simplejustwatchapi import search
|
|
1069
|
+
|
|
1070
|
+
results = search("title", count=9, offset=1990)
|
|
1071
|
+
# len(results) == 9, as expected
|
|
1072
|
+
```
|
|
1073
|
+
|
|
1074
|
+
But trying to get 1990 - 2000 will result in an empty list:
|
|
1075
|
+
|
|
1076
|
+
```python
|
|
1077
|
+
from simplejustwatchapi import search
|
|
1078
|
+
|
|
1079
|
+
results = search("title", count=10, offset=1990)
|
|
1080
|
+
# len(results) == 0, API responded with empty list
|
|
1081
|
+
```
|
|
1082
|
+
|
|
1083
|
+
Overshooting will also result in an empty list:
|
|
1084
|
+
|
|
1085
|
+
```python
|
|
1086
|
+
from simplejustwatchapi import search
|
|
1087
|
+
|
|
1088
|
+
results = search("title", count=100, offset=1950)
|
|
1089
|
+
# len(results) == 0, API responded with empty list
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1092
|
+
Interestingly, you'll still hit [too high request complexity](#request-complexity)
|
|
1093
|
+
for too high values of `count`, even though you'd get an empty list anyway:
|
|
1094
|
+
|
|
1095
|
+
```python
|
|
1096
|
+
from simplejustwatchapi import search
|
|
1097
|
+
|
|
1098
|
+
results = search("title", count=200, offset=1950)
|
|
1099
|
+
# Errors out due to complexity
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
## Provider codes
|
|
1105
|
+
|
|
1106
|
+
One note to keep in mind - the codes can be different for different countries.
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
### [`providers`](#providers) function
|
|
1110
|
+
|
|
1111
|
+
The easiest way of getting all provider codes for filtering in [`search`](#search) and [`popular`](#popular) functions
|
|
1112
|
+
is through [`providers`](#providers) function, for example:
|
|
1113
|
+
|
|
1114
|
+
```python
|
|
1115
|
+
from simplejustwatchapi import popular, providers
|
|
1116
|
+
|
|
1117
|
+
codes = [
|
|
1118
|
+
package.short_name
|
|
1119
|
+
for package
|
|
1120
|
+
in providers("GB") # Look up all providers in the UK.
|
|
1121
|
+
if package.name in ("Netflix", "Amazon Prime Video") # Only get codes for specific providers
|
|
1122
|
+
]
|
|
1123
|
+
|
|
1124
|
+
# codes == ["nfx", "amp"]
|
|
1125
|
+
|
|
1126
|
+
# Get popular titles only for selected providers:
|
|
1127
|
+
popular_netflix_amazon = popular(providers=codes)
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
### Query parameters from JustWatch
|
|
1132
|
+
|
|
1133
|
+
You can also get them by going to [JustWatch main page](https://www.justwatch.com/)
|
|
1134
|
+
and selecting **at least 2** of available services.
|
|
1135
|
+
**You need 2**, for 1 you'll get its full name.
|
|
1136
|
+
Only for multiple you'll get the needed codes as `?providers=<code1>+<code2>+...` query parameter,
|
|
1137
|
+
for example on US version the URL when selecting "Netflix" and "Amazon Prime Video" is:
|
|
1138
|
+
|
|
1139
|
+
```url
|
|
1140
|
+
https://www.justwatch.com/us?providers=nfx,prv
|
|
1141
|
+
```
|
|
1142
|
+
|
|
1143
|
+
So the codes for them are `nfx` and `prv` for the US.
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
### Stored output from other functions with offers
|
|
1147
|
+
|
|
1148
|
+
The codes are also returned when looking up offers (through pretty much any function aside from `providers`) through `OfferPackage` and its `short_name` field.
|
|
1149
|
+
For example, to get a `dict` "**full name**": "**code**" you can:
|
|
1150
|
+
|
|
1151
|
+
```python
|
|
1152
|
+
from simplejustwatchapi import search
|
|
1153
|
+
|
|
1154
|
+
results = search("title", "US", "en", 5, True)
|
|
1155
|
+
name_to_code_dict = {
|
|
1156
|
+
offer.package.name: offer.package.short_name # Get name and short_name/code from packages
|
|
1157
|
+
for entry in results # Iterate all entries
|
|
1158
|
+
for offer in entry.offers # Iterate all offers per entry
|
|
1159
|
+
}
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
959
1164
|
## Disclaimer
|
|
960
1165
|
|
|
961
1166
|
This API is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with JustWatch.
|
|
@@ -53,20 +53,28 @@ Example outputs from all functions are in [`examples/`](examples/) directory.
|
|
|
53
53
|
Search functions allows for searching entries based on a given title.
|
|
54
54
|
|
|
55
55
|
```python
|
|
56
|
-
from simplejustwatchapi
|
|
56
|
+
from simplejustwatchapi import search
|
|
57
57
|
|
|
58
|
-
results = search("title", "US", "en", 5, True)
|
|
58
|
+
results = search("title", "US", "en", 5, True, 0, {"nfx", "apv"})
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
No arguments are required.
|
|
62
62
|
|
|
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`
|
|
63
|
+
| | Argument | Type | Required | Default value | Description |
|
|
64
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
65
|
+
| 1 | `title` | `str` | NO | - | Title to look up |
|
|
66
|
+
| 2 | `country` | `str` | NO | `"US"` | Country to search for offers |
|
|
67
|
+
| 3 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
68
|
+
| 4 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
69
|
+
| 5 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
70
|
+
| 6 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
71
|
+
| 7 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
72
|
+
|
|
73
|
+
`title` is just a string to look up. If empty, or not provided, you'll get a selection of popular titles,
|
|
74
|
+
similar to [`popular`](#popular) function.
|
|
75
|
+
|
|
76
|
+
> **Note**: value of `title` isn't stripped, so passing a string
|
|
77
|
+
with multiple spaces will look them up. For more than 1 space it will (probably) always return an empty list.
|
|
70
78
|
|
|
71
79
|
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
72
80
|
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
@@ -79,6 +87,19 @@ If JustWatch GraphQL API returns fewer entries, then this function will also ret
|
|
|
79
87
|
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
80
88
|
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
89
|
|
|
90
|
+
`offset` allows for very basic pagination, letting you get more data without running into [request complexity](#request-complexity).
|
|
91
|
+
It simply skips `offset` number of first entries (on the API side, nothing is done inside the library).
|
|
92
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
93
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
94
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
95
|
+
only up to 1999, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
96
|
+
|
|
97
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
98
|
+
It can be either a list, or (for single providers) a string.
|
|
99
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
100
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
101
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
102
|
+
|
|
82
103
|
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
83
104
|
|
|
84
105
|
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
@@ -86,6 +107,57 @@ For very large searches (high `count` value) I recommend using default `best_onl
|
|
|
86
107
|
Example function call and its output is in [`examples/search_output.py`](examples/search_output.py).
|
|
87
108
|
|
|
88
109
|
|
|
110
|
+
### Popular
|
|
111
|
+
Look up all currently popular titles.
|
|
112
|
+
The usage and output will be similar to [`search`](#search), function without any titles specified.
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from simplejustwatchapi import popular
|
|
116
|
+
|
|
117
|
+
results = popular("US", "en", 5, True, 0, {"nfx", "apv"})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
No arguments are required.
|
|
121
|
+
|
|
122
|
+
| | Argument | Type | Required | Default value | Description |
|
|
123
|
+
|---|-------------|--------|----------|---------------------|--------------------------------------------------------|
|
|
124
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for titles |
|
|
125
|
+
| 2 | `language` | `str` | NO | `"en"` | Language of responses |
|
|
126
|
+
| 3 | `count` | `int` | NO | `4` | Up to how many entries should be returned |
|
|
127
|
+
| 4 | `best_only` | `bool` | NO | `True` | Determines whether only best offers should be returned |
|
|
128
|
+
| 5 | `offset` | `int` | NO | `0` | How many titles should be skipped from the output |
|
|
129
|
+
| 6 | `providers` | `list[str] \| str \| None`| NO | `None` | Determines whether only best offers should be returned |
|
|
130
|
+
|
|
131
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
132
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
133
|
+
|
|
134
|
+
`language` is a **ISO 639-1** (usually) 2-letter code, lowercase, e.g. `en`, `fr`.
|
|
135
|
+
|
|
136
|
+
`count` determines **up to** how many entries should be returned.
|
|
137
|
+
If JustWatch GraphQL API returns fewer entries, then this function will also return fewer values.
|
|
138
|
+
|
|
139
|
+
`best_only` determines whether similar offers, but lower quality should be included in response.
|
|
140
|
+
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.
|
|
141
|
+
|
|
142
|
+
`offset` allows for very basic pagination letting you get more data without running into [request complexity](#request-complexity).
|
|
143
|
+
It simply skips first entries (on the API side, nothing is done inside the library).
|
|
144
|
+
Since there is no session there's no guarantee of results "stability" - if JustWatch decides to
|
|
145
|
+
shuffle returned values (I'm not sure what would be the reason, but in theory it's possible)
|
|
146
|
+
you might get repeats, or missing entries. It's also not possible to get **all** the data,
|
|
147
|
+
only up to 2000, check [Maximum number of entries](#maximum-number-of-entries) for details.
|
|
148
|
+
|
|
149
|
+
`providers` is a selection of (usually) **3-letter** identifiers for a service provider ("Netflix", "Amazon Prime Video", etc.).
|
|
150
|
+
It can be either a list, or (for single providers) a string.
|
|
151
|
+
`None` (used as default) turns off any filtering based on providers.
|
|
152
|
+
You can get the possible values through [`providers`](#providers) function and `short_name` field from returned `OfferPackage` NamedTuples,
|
|
153
|
+
or check [Provider codes](#provider-codes) for more details.
|
|
154
|
+
|
|
155
|
+
Returned value is a list of [`MediaEntry`](#return-data-structures) objects.
|
|
156
|
+
|
|
157
|
+
For very large searches (high `count` value) I recommend using default `best_only=True` to avoid issues with [request complexity](#request-complexity).
|
|
158
|
+
|
|
159
|
+
Example function call and its output is in [`examples/popular_output.py`](examples/popular_output.py).
|
|
160
|
+
|
|
89
161
|
### Details
|
|
90
162
|
|
|
91
163
|
Details function allows for looking up details for a single entry via its node ID.
|
|
@@ -99,7 +171,7 @@ If you want to get seasons/episodes you can use the ID from [`search`](#search)
|
|
|
99
171
|
|
|
100
172
|
Usage is similar to [`search`](#search) function, just without `count` argument:
|
|
101
173
|
```python
|
|
102
|
-
from simplejustwatchapi
|
|
174
|
+
from simplejustwatchapi import details
|
|
103
175
|
|
|
104
176
|
results = details("nodeID", "US", "en", False)
|
|
105
177
|
```
|
|
@@ -140,7 +212,7 @@ Each season contains similar data to the [`details`](#details) function, with ad
|
|
|
140
212
|
|
|
141
213
|
Usage also matches [`details`](#details) function:
|
|
142
214
|
```python
|
|
143
|
-
from simplejustwatchapi
|
|
215
|
+
from simplejustwatchapi import seasons
|
|
144
216
|
|
|
145
217
|
results = seasons("nodeID", "US", "en", False)
|
|
146
218
|
```
|
|
@@ -164,7 +236,7 @@ Node/season ID can be taken from output of the [`seasons`](#seasons) function.
|
|
|
164
236
|
|
|
165
237
|
Usage matches [`details`](#details) function:
|
|
166
238
|
```python
|
|
167
|
-
from simplejustwatchapi
|
|
239
|
+
from simplejustwatchapi import seasons
|
|
168
240
|
|
|
169
241
|
results = seasons("nodeID", "US", "en", False)
|
|
170
242
|
```
|
|
@@ -190,7 +262,7 @@ It allows specifying a set of countries, instead of a single one.
|
|
|
190
262
|
This way you can simultaneously look up offers for multiple countries.
|
|
191
263
|
|
|
192
264
|
```python
|
|
193
|
-
from simplejustwatchapi
|
|
265
|
+
from simplejustwatchapi import offers_for_countries
|
|
194
266
|
|
|
195
267
|
results = offers_for_countries("nodeID", {"US", "UK", "CA"}, "en", True)
|
|
196
268
|
```
|
|
@@ -211,8 +283,35 @@ Returned value `dict[str, list[Offer]]`, where key is country given as argument
|
|
|
211
283
|
Example function call and its output is in [`examples/offers_for_countries_output.py`](examples/offers_for_countries_output.py).
|
|
212
284
|
|
|
213
285
|
|
|
286
|
+
### Providers
|
|
287
|
+
|
|
288
|
+
Get all available service providers ("Netflix", "Amazon Prime Video, etc.) for a given country.
|
|
214
289
|
|
|
215
|
-
|
|
290
|
+
```python
|
|
291
|
+
from simplejustwatchapi import providers
|
|
292
|
+
|
|
293
|
+
results = providers("US")
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
| | Argument | Type | Required | Default value | Description |
|
|
297
|
+
|---|-------------|--------|----------|---------------|---------------------------------|
|
|
298
|
+
| 1 | `country` | `str` | NO | `"US"` | Country to search for providers |
|
|
299
|
+
|
|
300
|
+
`country` must be **ISO 3166-1 alpha-2** 2-letter code , e.g. `US`, `GB`, `FR`.
|
|
301
|
+
It should be uppercase, however lowercase codes are automatically converted to uppercase.
|
|
302
|
+
|
|
303
|
+
Returned value is a list of `OfferPackage` tuples.
|
|
304
|
+
Initially they were meant to be used for `Offer` in `MediaEntry`/`Episode`, however the data structure
|
|
305
|
+
matches output here, so it's reused.
|
|
306
|
+
|
|
307
|
+
You can use this function to get values for providers for [`search`](#search) and [`popular`](#popular) functions,
|
|
308
|
+
the `short_name` field in returned `OfferPackage` tuples is the exact 3-letter code needed there.
|
|
309
|
+
|
|
310
|
+
Example function call and its output is in [`examples/providers_output.py`](examples/providers_output.py).
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
## Data structures
|
|
216
315
|
|
|
217
316
|
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
317
|
|
|
@@ -259,6 +358,112 @@ Using `best_only=True` should alleviate the issue somewhat, so for very large re
|
|
|
259
358
|
|
|
260
359
|
|
|
261
360
|
|
|
361
|
+
## Maximum number of entries
|
|
362
|
+
|
|
363
|
+
The JustWatch API itself won't allow for getting more than 1999 entries, through `count` and `offset`, regardless of request complexity.
|
|
364
|
+
If you try to get the 2000th entry the API (and functions in this libary) will return an empty list.
|
|
365
|
+
|
|
366
|
+
**If you try to access over the 1999th entry you won't get *up to* 1999 entries, you'll get an empty list.**
|
|
367
|
+
|
|
368
|
+
For example, this will get you entries 1990 - 1999 - a 9 element list of `MediaEntry`, as expected:
|
|
369
|
+
|
|
370
|
+
```python
|
|
371
|
+
from simplejustwatchapi import search
|
|
372
|
+
|
|
373
|
+
results = search("title", count=9, offset=1990)
|
|
374
|
+
# len(results) == 9, as expected
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
But trying to get 1990 - 2000 will result in an empty list:
|
|
378
|
+
|
|
379
|
+
```python
|
|
380
|
+
from simplejustwatchapi import search
|
|
381
|
+
|
|
382
|
+
results = search("title", count=10, offset=1990)
|
|
383
|
+
# len(results) == 0, API responded with empty list
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Overshooting will also result in an empty list:
|
|
387
|
+
|
|
388
|
+
```python
|
|
389
|
+
from simplejustwatchapi import search
|
|
390
|
+
|
|
391
|
+
results = search("title", count=100, offset=1950)
|
|
392
|
+
# len(results) == 0, API responded with empty list
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Interestingly, you'll still hit [too high request complexity](#request-complexity)
|
|
396
|
+
for too high values of `count`, even though you'd get an empty list anyway:
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
from simplejustwatchapi import search
|
|
400
|
+
|
|
401
|
+
results = search("title", count=200, offset=1950)
|
|
402
|
+
# Errors out due to complexity
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
## Provider codes
|
|
408
|
+
|
|
409
|
+
One note to keep in mind - the codes can be different for different countries.
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
### [`providers`](#providers) function
|
|
413
|
+
|
|
414
|
+
The easiest way of getting all provider codes for filtering in [`search`](#search) and [`popular`](#popular) functions
|
|
415
|
+
is through [`providers`](#providers) function, for example:
|
|
416
|
+
|
|
417
|
+
```python
|
|
418
|
+
from simplejustwatchapi import popular, providers
|
|
419
|
+
|
|
420
|
+
codes = [
|
|
421
|
+
package.short_name
|
|
422
|
+
for package
|
|
423
|
+
in providers("GB") # Look up all providers in the UK.
|
|
424
|
+
if package.name in ("Netflix", "Amazon Prime Video") # Only get codes for specific providers
|
|
425
|
+
]
|
|
426
|
+
|
|
427
|
+
# codes == ["nfx", "amp"]
|
|
428
|
+
|
|
429
|
+
# Get popular titles only for selected providers:
|
|
430
|
+
popular_netflix_amazon = popular(providers=codes)
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
### Query parameters from JustWatch
|
|
435
|
+
|
|
436
|
+
You can also get them by going to [JustWatch main page](https://www.justwatch.com/)
|
|
437
|
+
and selecting **at least 2** of available services.
|
|
438
|
+
**You need 2**, for 1 you'll get its full name.
|
|
439
|
+
Only for multiple you'll get the needed codes as `?providers=<code1>+<code2>+...` query parameter,
|
|
440
|
+
for example on US version the URL when selecting "Netflix" and "Amazon Prime Video" is:
|
|
441
|
+
|
|
442
|
+
```url
|
|
443
|
+
https://www.justwatch.com/us?providers=nfx,prv
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
So the codes for them are `nfx` and `prv` for the US.
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
### Stored output from other functions with offers
|
|
450
|
+
|
|
451
|
+
The codes are also returned when looking up offers (through pretty much any function aside from `providers`) through `OfferPackage` and its `short_name` field.
|
|
452
|
+
For example, to get a `dict` "**full name**": "**code**" you can:
|
|
453
|
+
|
|
454
|
+
```python
|
|
455
|
+
from simplejustwatchapi import search
|
|
456
|
+
|
|
457
|
+
results = search("title", "US", "en", 5, True)
|
|
458
|
+
name_to_code_dict = {
|
|
459
|
+
offer.package.name: offer.package.short_name # Get name and short_name/code from packages
|
|
460
|
+
for entry in results # Iterate all entries
|
|
461
|
+
for offer in entry.offers # Iterate all offers per entry
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
262
467
|
## Disclaimer
|
|
263
468
|
|
|
264
469
|
This API is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with JustWatch.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple-justwatch-python-api"
|
|
3
3
|
authors = [{name = "Electronic Mango", email = "78230210+Electronic-Mango@users.noreply.github.com"}]
|
|
4
|
-
version = "0.
|
|
4
|
+
version = "0.18.0"
|
|
5
5
|
description="A simple JustWatch Python API"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
license = {file = "LICENSE"}
|
|
@@ -61,6 +61,7 @@ ignore = [
|
|
|
61
61
|
"D212", # Conflicts with D213
|
|
62
62
|
"FBT",
|
|
63
63
|
"FIX002",
|
|
64
|
+
"PLR0913", # I think it makes sense for functions here to have more arguments
|
|
64
65
|
"S101", # Remove once asserts are converted to exceptions
|
|
65
66
|
"TD002",
|
|
66
67
|
"TD003",
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
from simplejustwatchapi.justwatch import details as details
|
|
4
4
|
from simplejustwatchapi.justwatch import episodes as episodes
|
|
5
5
|
from simplejustwatchapi.justwatch import offers_for_countries as offers_for_countries
|
|
6
|
+
from simplejustwatchapi.justwatch import popular as popular
|
|
7
|
+
from simplejustwatchapi.justwatch import providers as providers
|
|
6
8
|
from simplejustwatchapi.justwatch import search as search
|
|
7
9
|
from simplejustwatchapi.justwatch import seasons as seasons
|
|
8
10
|
from simplejustwatchapi.tuples import Episode as Episode
|
|
@@ -24,6 +26,8 @@ __all__ = [
|
|
|
24
26
|
"details",
|
|
25
27
|
"episodes",
|
|
26
28
|
"offers_for_countries",
|
|
29
|
+
"popular",
|
|
30
|
+
"providers",
|
|
27
31
|
"search",
|
|
28
32
|
"seasons",
|
|
29
33
|
]
|