Skip to content

Commit 5e71d88

Browse files
stu247Electronic-Mango
authored andcommitted
add tmdbId
1 parent 62aa42c commit 5e71d88

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/simplejustwatchapi/query.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
}
9393
externalIds {
9494
imdbId
95+
tmdbId
9596
__typename
9697
}
9798
posterUrl(profile: $profile, format: $formatPoster)
@@ -259,6 +260,9 @@ class MediaEntry(NamedTuple):
259260
imdb_id: str | None
260261
"""ID of this entry in IMDB."""
261262

263+
tmdb_id: str | None
264+
"""ID of this entry in TMDB."""
265+
262266
poster: str | None
263267
"""URL to poster for this ID."""
264268

@@ -469,6 +473,7 @@ def _parse_entry(json: any) -> MediaEntry:
469473
genres = [node.get("shortName") for node in content.get("genres", []) if node]
470474
external_ids = content.get("externalIds")
471475
imdb_id = external_ids.get("imdbId") if external_ids else None
476+
tmdb_id = external_ids.get("tmdbId") if external_ids else None
472477
poster_url_field = content.get("posterUrl")
473478
poster = _IMAGES_URL + poster_url_field if poster_url_field else None
474479
backdrops = [_IMAGES_URL + bd.get("backdropUrl") for bd in content.get("backdrops", []) if bd]
@@ -485,6 +490,7 @@ def _parse_entry(json: any) -> MediaEntry:
485490
short_description,
486491
genres,
487492
imdb_id,
493+
tmdb_id,
488494
poster,
489495
backdrops,
490496
offers,

test/simplejustwatchapi/test_parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"runtime": 123,
2525
"shortDescription": "Movie 1 description",
2626
"genres": [{"shortName": "gen1"}, {"shortName": "gen2"}],
27-
"externalIds": {"imdbId": "imdbId1"},
27+
"externalIds": {"imdbId": "imdbId1", "tmdbId": "tmdbId1"},
2828
"posterUrl": "/poster/url/1.jpg",
2929
"backdrops": [
3030
{"backdropUrl": "/back/drop/url/1.jpg"},
@@ -96,6 +96,7 @@
9696
"Movie 1 description",
9797
["gen1", "gen2"],
9898
"imdbId1",
99+
"tmdbId1",
99100
IMAGES_URL + "/poster/url/1.jpg",
100101
[IMAGES_URL + "/back/drop/url/1.jpg", IMAGES_URL + "/back/drop/url/2.jpg"],
101102
[
@@ -164,7 +165,7 @@
164165
"runtime": 456,
165166
"shortDescription": "TV show 2 description",
166167
"genres": [{"shortName": "gen2"}, {"shortName": "gen3"}],
167-
"externalIds": {"imdbId": "imdbId2"},
168+
"externalIds": {"imdbId": "imdbId1", "tmdbId": "tmdbId1"},
168169
"posterUrl": "/poster/url/2.jpg",
169170
"backdrops": [
170171
{"backdropUrl": "/back/drop/url/3.jpg"},
@@ -210,6 +211,7 @@
210211
"TV show 2 description",
211212
["gen2", "gen3"],
212213
"imdbId2",
214+
"tmdbId2",
213215
IMAGES_URL + "/poster/url/2.jpg",
214216
[IMAGES_URL + "/back/drop/url/3.jpg"],
215217
[
@@ -265,6 +267,7 @@
265267
None,
266268
[],
267269
None,
270+
None,
268271
IMAGES_URL + "/poster/url/3.jpg",
269272
[],
270273
[],

test/simplejustwatchapi/test_request.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
}
9393
externalIds {
9494
imdbId
95+
tmdbId
9596
__typename
9697
}
9798
posterUrl(profile: $profile, format: $formatPoster)

0 commit comments

Comments
 (0)