Skip to content

Commit b925866

Browse files
committed
Improve robustness in case of missing tmdb ids in the db
1 parent 39b2f86 commit b925866

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

addon.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<addon id="plugin.video.jlom" version="0.1.8" name="Just Lists Of Movies" provider-name="lbnt">
2+
<addon id="plugin.video.jlom" version="0.1.9" name="Just Lists Of Movies" provider-name="lbnt">
33
<requires>
44
<import addon="xbmc.python" version="3.0.1"/>
55
<import addon="script.module.requests"/>
@@ -19,6 +19,6 @@
1919
<icon>resources/images/icon.png</icon>
2020
<screenshot>resources/images/screenshot.jpg</screenshot>
2121
</assets>
22-
<news>0.1.8 New matching implementation between lists and local media, new sorting options</news>
22+
<news>0.1.9 Improve robustness in case of missing tmdb ids</news>
2323
</extension>
2424
</addon>

main.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,25 @@ def build_tmdbid_to_dbid_index():
123123
result = json.loads(response)
124124

125125
"""Build a dict {tmdb: movieid}."""
126+
nbmissingids = 0
126127
index = {}
127-
for movie in result["result"]["movies"]:
128-
tmdb = movie["uniqueid"].get("tmdb")
129-
if tmdb is not None:
130-
index[tmdb] = movie["movieid"]
128+
for movie in result.get("result", {}).get("movies", []):
129+
uniqueid = movie.get("uniqueid")
130+
if not isinstance(uniqueid, dict): # uniqueid is missing or not a dict
131+
nbmissingids += 1
132+
continue
133+
134+
tmdbid = uniqueid.get("tmdb")
135+
if tmdbid is None: # tmdb id is missing
136+
nbmissingids += 1
137+
continue
138+
139+
movieid = movie.get("movieid")
140+
if movieid is not None:
141+
index[tmdbid] = movieid
142+
143+
if nbmissingids > 0:
144+
xbmcgui.Dialog().notification('jlom', f'{nbmissingids} movies don\'t have a tmdb id\n and won\'t be found in the lists!', xbmcgui.NOTIFICATION_WARNING, 10000)
131145

132146
return index
133147

0 commit comments

Comments
 (0)