Improve collection lookup; fix PKC caching wrong url
This commit is contained in:
parent
75994bff47
commit
80acc668ec
1 changed files with 21 additions and 17 deletions
|
@ -1021,15 +1021,15 @@ class API(object):
|
||||||
name = entry.get('name', entry.get('title'))
|
name = entry.get('name', entry.get('title'))
|
||||||
# lookup external tmdb_id and perform artwork lookup on fanart.tv
|
# lookup external tmdb_id and perform artwork lookup on fanart.tv
|
||||||
parameters = {'api_key': api_key}
|
parameters = {'api_key': api_key}
|
||||||
|
if media_type == 'movie':
|
||||||
|
url = 'https://api.themoviedb.org/3/movie/%s' % tmdb_id
|
||||||
|
parameters['append_to_response'] = 'videos'
|
||||||
|
elif media_type == 'tv':
|
||||||
|
url = 'https://api.themoviedb.org/3/tv/%s' % tmdb_id
|
||||||
|
parameters['append_to_response'] = 'external_ids,videos'
|
||||||
media_id, poster, background = None, None, None
|
media_id, poster, background = None, None, None
|
||||||
for language in [v.KODILANGUAGE, 'en']:
|
for language in [v.KODILANGUAGE, 'en']:
|
||||||
parameters['language'] = language
|
parameters['language'] = language
|
||||||
if media_type == 'movie':
|
|
||||||
url = 'https://api.themoviedb.org/3/movie/%s' % tmdb_id
|
|
||||||
parameters['append_to_response'] = 'videos'
|
|
||||||
elif media_type == 'tv':
|
|
||||||
url = 'https://api.themoviedb.org/3/tv/%s' % tmdb_id
|
|
||||||
parameters['append_to_response'] = 'external_ids,videos'
|
|
||||||
data = DU().downloadUrl(url,
|
data = DU().downloadUrl(url,
|
||||||
authenticate=False,
|
authenticate=False,
|
||||||
parameters=parameters,
|
parameters=parameters,
|
||||||
|
@ -1037,20 +1037,24 @@ class API(object):
|
||||||
try:
|
try:
|
||||||
data.get('test')
|
data.get('test')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
LOG.error('Could not download %s with parameters %s',
|
LOG.warning('Could not download %s with parameters %s',
|
||||||
url, parameters)
|
url, parameters)
|
||||||
continue
|
continue
|
||||||
if collection is False:
|
if collection is False:
|
||||||
if data.get('imdb_id') is not None:
|
if data.get('imdb_id'):
|
||||||
media_id = str(data.get('imdb_id'))
|
media_id = str(data.get('imdb_id'))
|
||||||
break
|
break
|
||||||
if data.get('external_ids') is not None:
|
if (data.get('external_ids') and
|
||||||
media_id = str(data['external_ids'].get('tvdb_id'))
|
data['external_ids'].get('tvdb_id')):
|
||||||
|
media_id = str(data['external_ids']['tvdb_id'])
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if data.get('belongs_to_collection') is None:
|
if not data.get('belongs_to_collection'):
|
||||||
continue
|
continue
|
||||||
media_id = str(data.get('belongs_to_collection').get('id'))
|
media_id = data.get('belongs_to_collection').get('id')
|
||||||
|
if not media_id:
|
||||||
|
continue
|
||||||
|
media_id = str(media_id)
|
||||||
LOG.debug('Retrieved collections tmdb id %s for %s',
|
LOG.debug('Retrieved collections tmdb id %s for %s',
|
||||||
media_id, title)
|
media_id, title)
|
||||||
url = 'https://api.themoviedb.org/3/collection/%s' % media_id
|
url = 'https://api.themoviedb.org/3/collection/%s' % media_id
|
||||||
|
@ -1061,15 +1065,15 @@ class API(object):
|
||||||
try:
|
try:
|
||||||
data.get('poster_path')
|
data.get('poster_path')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
LOG.info('Could not find TheMovieDB poster paths for %s in '
|
LOG.debug('Could not find TheMovieDB poster paths for %s in '
|
||||||
'the language %s', title, language)
|
'the language %s', title, language)
|
||||||
continue
|
continue
|
||||||
else:
|
if not poster and data.get('poster_path'):
|
||||||
poster = ('https://image.tmdb.org/t/p/original%s' %
|
poster = ('https://image.tmdb.org/t/p/original%s' %
|
||||||
data.get('poster_path'))
|
data.get('poster_path'))
|
||||||
|
if not background and data.get('backdrop_path'):
|
||||||
background = ('https://image.tmdb.org/t/p/original%s' %
|
background = ('https://image.tmdb.org/t/p/original%s' %
|
||||||
data.get('backdrop_path'))
|
data.get('backdrop_path'))
|
||||||
break
|
|
||||||
return media_id, poster, background
|
return media_id, poster, background
|
||||||
|
|
||||||
def lookup_fanart_tv(self, media_id, artworks):
|
def lookup_fanart_tv(self, media_id, artworks):
|
||||||
|
|
Loading…
Reference in a new issue