Skip to content

Commit da143a3

Browse files
Add "monetization_types" to OfferPackage
Return all available monetization types for the given provider.
1 parent eee5968 commit da143a3

5 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/simplejustwatchapi/graphql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@
307307
technicalName
308308
shortName
309309
slug
310+
monetizationTypes
310311
icon(profile: S100, format: $formatOfferIcon)
311312
__typename
312313
}

src/simplejustwatchapi/query.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,5 +711,14 @@ def _parse_package(json: Any) -> OfferPackage:
711711
name = json.get("clearName")
712712
technical_name = json.get("technicalName")
713713
short_name = json.get("shortName")
714+
monetization_types = json.get("monetizationTypes", [])
714715
icon = _IMAGES_URL + icon if (icon := json.get("icon")) else ""
715-
return OfferPackage(platform_id, package_id, name, technical_name, short_name, icon)
716+
return OfferPackage(
717+
platform_id,
718+
package_id,
719+
name,
720+
technical_name,
721+
short_name,
722+
monetization_types,
723+
icon,
724+
)

src/simplejustwatchapi/tuples.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class OfferPackage(NamedTuple):
3030
technical_name (str): Technical name of the platform,
3131
usually all lowercase with no whitespaces.
3232
short_name (str): 3-letter provider name.
33+
monetization_types (list[str]): List of monetization types available for this
34+
provider (e.g., `ADS`, `FLATRATE` (streaming), `RENT`).
3335
icon (str): Platform icon URL.
3436
3537
"""
@@ -39,6 +41,7 @@ class OfferPackage(NamedTuple):
3941
name: str
4042
technical_name: str
4143
short_name: str
44+
monetization_types: list[str]
4245
icon: str
4346

4447

test/simplejustwatchapi/test_graphql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
technicalName
305305
shortName
306306
slug
307+
monetizationTypes
307308
icon(profile: S100, format: $formatOfferIcon)
308309
__typename
309310
}

test/simplejustwatchapi/test_parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"clearName": "Service 1",
3030
"technicalName": "service1",
3131
"shortName": "sr1",
32+
"monetizationTypes": ["MON_TYPE_1", "MON_TYPE_2"],
3233
"icon": "/icon/url/service1",
3334
}
3435
PARSED_PACKAGE_1 = OfferPackage(
@@ -37,6 +38,7 @@
3738
"Service 1",
3839
"service1",
3940
"sr1",
41+
["MON_TYPE_1", "MON_TYPE_2"],
4042
IMAGES_URL + "/icon/url/service1",
4143
)
4244

@@ -46,6 +48,7 @@
4648
"clearName": "Service 2",
4749
"technicalName": "service2",
4850
"shortName": "sr2",
51+
"monetizationTypes": ["MON_TYPE_3"],
4952
"icon": "/icon/url/service2",
5053
}
5154
PARSED_PACKAGE_2 = OfferPackage(
@@ -54,6 +57,7 @@
5457
"Service 2",
5558
"service2",
5659
"sr2",
60+
["MON_TYPE_3"],
5761
IMAGES_URL + "/icon/url/service2",
5862
)
5963

@@ -71,6 +75,7 @@
7175
"Service 3",
7276
"service3",
7377
"sr3",
78+
[],
7479
IMAGES_URL + "/icon/url/service3",
7580
)
7681

0 commit comments

Comments
 (0)