Skip to content

Commit ede5685

Browse files
Include titles without JW URL in search/popular
Add "'includeTitlesWithoutUrl': True" to search/popular filters. This will include entries without dedicated JW page (and its URL). Other data (like offers) seems OK. "MediaEntry.url" marked as optional to accomodate.
1 parent 79072f0 commit ede5685

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/simplejustwatchapi/query.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def prepare_search_request(
8585
"searchTitlesFilter": {
8686
"searchQuery": title,
8787
"packages": providers,
88-
**_list_variables(min_release_year, max_release_year, object_types),
88+
**_filter_variables(min_release_year, max_release_year, object_types),
8989
},
9090
**_common_variables(best_only),
9191
**_locale_variables(country, language),
@@ -168,7 +168,7 @@ def prepare_popular_request(
168168
"first": count,
169169
"popularTitlesFilter": {
170170
"packages": providers,
171-
**_list_variables(min_release_year, max_release_year, object_types),
171+
**_filter_variables(min_release_year, max_release_year, object_types),
172172
},
173173
**_common_variables(best_only),
174174
**_locale_variables(country, language),
@@ -528,13 +528,14 @@ def _locale_variables(country: str, language: str) -> dict[str, str]:
528528
return {"country": country.upper(), "language": language}
529529

530530

531-
def _list_variables(
531+
def _filter_variables(
532532
min_release_year: int | None,
533533
max_release_year: int | None,
534534
object_types: list[str] | str | None,
535535
) -> dict[str, Any]:
536536
"""Return dict with variables related to looking up lists of titles."""
537537
return {
538+
"includeTitlesWithoutUrl": True,
538539
"objectTypes": object_types,
539540
"releaseYear": {"min": min_release_year, "max": max_release_year},
540541
}

src/simplejustwatchapi/tuples.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ class MediaEntry(NamedTuple):
222222
object_id (int): Object ID, the numeric part of full entry ID.
223223
object_type (str): Type of entry, e.g. `MOVIE`, `SHOW`.
224224
title (str): Full title.
225-
url (str): URL to JustWatch with details for this entry.
225+
url (str | None): URL to JustWatch with details for this entry. Some entries
226+
are missing dedicated JustWatch pages, for them this field is `None`.
226227
release_year (int): Release year as a number.
227228
release_date (str): Full release date as a string, e.g. `2013-12-16`.
228229
runtime_minutes (int): Runtime in minutes.
@@ -255,7 +256,7 @@ class MediaEntry(NamedTuple):
255256
object_id: int
256257
object_type: str
257258
title: str
258-
url: str
259+
url: str | None
259260
release_year: int
260261
release_date: str
261262
runtime_minutes: int

test/simplejustwatchapi/test_request.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ def locale_variables(country, language):
3939
}
4040

4141

42-
def list_variables(min_release_year, max_release_year, object_types):
42+
def filter_variables(min_release_year, max_release_year, object_types):
4343
return {
44+
"includeTitlesWithoutUrl": True,
4445
"objectTypes": object_types,
4546
"releaseYear": {"min": min_release_year, "max": max_release_year},
4647
}
@@ -109,7 +110,7 @@ def test_prepare_search_request(
109110
"searchTitlesFilter": {
110111
"searchQuery": title,
111112
"packages": providers,
112-
**list_variables(min_release_year, max_release_year, object_types),
113+
**filter_variables(min_release_year, max_release_year, object_types),
113114
},
114115
**common_variables(best_only),
115116
**locale_variables(country, language),
@@ -170,7 +171,7 @@ def test_prepare_popular_request(
170171
"first": count,
171172
"popularTitlesFilter": {
172173
"packages": providers,
173-
**list_variables(min_release_year, max_release_year, object_types),
174+
**filter_variables(min_release_year, max_release_year, object_types),
174175
},
175176
**common_variables(best_only),
176177
**locale_variables(country, language),

0 commit comments

Comments
 (0)