Skip to content

Commit 13cce3b

Browse files
authored
Merge pull request #577 from rmrector/metadata.themoviedb.org.python@nexus
[metadata.themoviedb.org.python@nexus] 3.1.3
2 parents 350ad6c + 53af380 commit 13cce3b

5 files changed

Lines changed: 39 additions & 23 deletions

File tree

metadata.themoviedb.org.python/addon.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="metadata.themoviedb.org.python"
33
name="The Movie Database Python"
4-
version="3.1.2"
4+
version="3.1.3"
55
provider-name="Team Kodi">
66
<requires>
77
<import addon="xbmc.metadata" version="2.1.0"/>
@@ -11,7 +11,10 @@
1111
library="python/scraper.py"/>
1212
<extension point="xbmc.addon.metadata">
1313
<reuselanguageinvoker>true</reuselanguageinvoker>
14-
<news>v3.1.2 (2025-10-05)
14+
<news>v3.1.3 (2025-10-12)
15+
- fix missing fanart from TMDB either way
16+
17+
v3.1.2 (2025-10-05)
1518
- fix missing fanart from TMDB
1619

1720
v3.0.0 (2024-04-17)

metadata.themoviedb.org.python/changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v3.1.3 (2025-10-12)
2+
- fix missing fanart from TMDB either way
3+
14
v3.1.2 (2025-10-05)
25
- fix missing fanart from TMDB
36

metadata.themoviedb.org.python/python/lib/tmdbscraper/api_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def load_info(url, params=None, default=None, resp_type = 'json'):
6666
url = url + '?' + urlencode(params)
6767
if xbmc:
6868
xbmc.log('Calling URL "{}"'.format(url), xbmc.LOGDEBUG)
69-
if HEADERS:
70-
xbmc.log(str(HEADERS), xbmc.LOGDEBUG)
69+
if HEADERS:
70+
xbmc.log(str(HEADERS), xbmc.LOGDEBUG)
7171
req = Request(url, headers=HEADERS)
7272
try:
7373
response = urlopen(req)

metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdb.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,39 +186,42 @@ def _parse_artwork(movie, collection, urlbases, language):
186186
fanart = []
187187

188188
if 'images' in movie:
189-
posters = _get_images_with_fallback(movie['images']['posters'], urlbases, language)
190-
landscape = _get_images_with_fallback(movie['images']['backdrops'], urlbases, language)
191-
logos = _get_images_with_fallback(movie['images']['logos'], urlbases, language)
192-
fanart = _get_images(movie['images']['backdrops'], urlbases, 'xx')
189+
posters = _build_image_list_with_fallback(movie['images']['posters'], urlbases, language)
190+
landscape = _build_image_list_with_fallback(movie['images']['backdrops'], urlbases, language)
191+
logos = _build_image_list_with_fallback(movie['images']['logos'], urlbases, language)
192+
fanart = _build_fanart_list(movie['images']['backdrops'], urlbases)
193193

194194
setposters = []
195195
setlandscape = []
196196
setfanart = []
197197
if collection and 'images' in collection:
198-
setposters = _get_images_with_fallback(collection['images']['posters'], urlbases, language)
199-
setlandscape = _get_images_with_fallback(collection['images']['backdrops'], urlbases, language)
200-
setfanart = _get_images(collection['images']['backdrops'], urlbases, 'xx')
198+
setposters = _build_image_list_with_fallback(collection['images']['posters'], urlbases, language)
199+
setlandscape = _build_image_list_with_fallback(collection['images']['backdrops'], urlbases, language)
200+
setfanart = _build_fanart_list(collection['images']['backdrops'], urlbases)
201201

202202
return {'poster': posters, 'landscape': landscape, 'fanart': fanart,
203203
'set.poster': setposters, 'set.landscape': setlandscape, 'set.fanart': setfanart, 'clearlogo': logos}
204204

205-
def _get_images_with_fallback(imagelist, urlbases, language, language_fallback='en'):
206-
images = _get_images(imagelist, urlbases, language)
205+
def _build_image_list_with_fallback(imagelist, urlbases, language, language_fallback='en'):
206+
images = _build_image_list(imagelist, urlbases, [language])
207207

208208
# Add backup images
209209
if language != language_fallback:
210-
images.extend(_get_images(imagelist, urlbases, language_fallback))
210+
images.extend(_build_image_list(imagelist, urlbases, [language_fallback]))
211211

212212
# Add any images if nothing set so far
213213
if not images:
214-
images = _get_images(imagelist, urlbases)
214+
images = _build_image_list(imagelist, urlbases)
215215

216216
return images
217217

218-
def _get_images(imagelist, urlbases, language='_any'):
218+
def _build_fanart_list(imagelist, urlbases):
219+
return _build_image_list(imagelist, urlbases, ['xx', None])
220+
221+
def _build_image_list(imagelist, urlbases, languages=[]):
219222
result = []
220223
for img in imagelist:
221-
if language != '_any' and img['iso_639_1'] != language:
224+
if languages and img['iso_639_1'] not in languages:
222225
continue
223226
if img['file_path'].endswith('.svg'):
224227
continue

metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdbapi.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020

2121
import unicodedata
2222
from . import api_utils
23-
import xbmc
23+
try:
24+
import xbmc
25+
except ModuleNotFoundError:
26+
# only used for logging HTTP calls, not available nor needed for testing
27+
xbmc = None
2428
try:
2529
from typing import Optional, Text, Dict, List, Any # pylint: disable=unused-import
2630
InfoType = Dict[Text, Any] # pylint: disable=invalid-name
@@ -41,6 +45,9 @@
4145
COLLECTION_URL = BASE_URL.format('collection/{}')
4246
CONFIG_URL = BASE_URL.format('configuration')
4347

48+
def log(message):
49+
if xbmc:
50+
xbmc.log(message, xbmc.LOGDEBUG)
4451

4552
def search_movie(query, year=None, language=None, page=None):
4653
# type: (Text) -> List[InfoType]
@@ -54,7 +61,7 @@ def search_movie(query, year=None, language=None, page=None):
5461
:return: a list with found movies
5562
"""
5663
query = unicodedata.normalize('NFC', query)
57-
xbmc.log('using title of %s to find movie' % query, xbmc.LOGDEBUG)
64+
log('using title of %s to find movie' % query)
5865
theurl = SEARCH_URL
5966
params = _set_params(None, language)
6067
params['query'] = query
@@ -75,7 +82,7 @@ def find_movie_by_external_id(external_id, language=None):
7582
:param language: the language filter for TMDb (optional)
7683
:return: the movie or error
7784
"""
78-
xbmc.log('using external id of %s to find movie' % external_id, xbmc.LOGDEBUG)
85+
log('using external id of %s to find movie' % external_id)
7986
theurl = FIND_URL.format(external_id)
8087
params = _set_params(None, language)
8188
params['external_source'] = 'imdb_id'
@@ -94,7 +101,7 @@ def get_movie(mid, language=None, append_to_response=None):
94101
:append_to_response: the additional data to get from TMDb (optional)
95102
:return: the movie or error
96103
"""
97-
xbmc.log('using movie id of %s to get movie details' % mid, xbmc.LOGDEBUG)
104+
log('using movie id of %s to get movie details' % mid)
98105
theurl = MOVIE_URL.format(mid)
99106
api_utils.set_headers(dict(HEADERS))
100107
return api_utils.load_info(theurl, params=_set_params(append_to_response, language))
@@ -110,7 +117,7 @@ def get_collection(collection_id, language=None, append_to_response=None):
110117
:append_to_response: the additional data to get from TMDb (optional)
111118
:return: the movie or error
112119
"""
113-
xbmc.log('using collection id of %s to get collection details' % collection_id, xbmc.LOGDEBUG)
120+
log('using collection id of %s to get collection details' % collection_id)
114121
theurl = COLLECTION_URL.format(collection_id)
115122
api_utils.set_headers(dict(HEADERS))
116123
return api_utils.load_info(theurl, params=_set_params(append_to_response, language))
@@ -123,7 +130,7 @@ def get_configuration():
123130
124131
:return: configuration details or error
125132
"""
126-
xbmc.log('getting configuration details', xbmc.LOGDEBUG)
133+
log('getting configuration details')
127134
api_utils.set_headers(dict(HEADERS))
128135
return api_utils.load_info(CONFIG_URL, params=TMDB_PARAMS.copy())
129136

0 commit comments

Comments
 (0)