Prettify
This commit is contained in:
parent
7b7ee9fa8d
commit
75994bff47
1 changed files with 25 additions and 25 deletions
|
@ -948,9 +948,9 @@ class API(object):
|
||||||
try:
|
try:
|
||||||
data.get('test')
|
data.get('test')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
LOG.error('Could not download data from FanartTV')
|
LOG.warning('Could not download data from FanartTV')
|
||||||
return
|
return
|
||||||
if data.get('results') is None:
|
if not data.get('results'):
|
||||||
LOG.info('No match found on themoviedb for type: %s, title: %s',
|
LOG.info('No match found on themoviedb for type: %s, title: %s',
|
||||||
media_type, title)
|
media_type, title)
|
||||||
return
|
return
|
||||||
|
@ -958,12 +958,12 @@ class API(object):
|
||||||
year = item.get('year')
|
year = item.get('year')
|
||||||
match_found = None
|
match_found = None
|
||||||
# find year match
|
# find year match
|
||||||
if year is not None:
|
if year:
|
||||||
for entry in data["results"]:
|
for entry in data['results']:
|
||||||
if year in entry.get("first_air_date", ""):
|
if year in entry.get('first_air_date', ''):
|
||||||
match_found = entry
|
match_found = entry
|
||||||
break
|
break
|
||||||
elif year in entry.get("release_date", ""):
|
elif year in entry.get('release_date', ''):
|
||||||
match_found = entry
|
match_found = entry
|
||||||
break
|
break
|
||||||
# find exact match based on title, if we haven't found a year match
|
# find exact match based on title, if we haven't found a year match
|
||||||
|
@ -977,9 +977,9 @@ class API(object):
|
||||||
':',
|
':',
|
||||||
';'
|
';'
|
||||||
)
|
)
|
||||||
for entry in data["results"]:
|
for entry in data['results']:
|
||||||
name = entry.get("name", entry.get("title", ""))
|
name = entry.get('name', entry.get('title', ''))
|
||||||
original_name = entry.get("original_name", "")
|
original_name = entry.get('original_name', '')
|
||||||
title_alt = title.lower()
|
title_alt = title.lower()
|
||||||
name_alt = name.lower()
|
name_alt = name.lower()
|
||||||
org_name_alt = original_name.lower()
|
org_name_alt = original_name.lower()
|
||||||
|
@ -991,16 +991,16 @@ class API(object):
|
||||||
# match found for exact title name
|
# match found for exact title name
|
||||||
match_found = entry
|
match_found = entry
|
||||||
break
|
break
|
||||||
elif (name.split(" (")[0] == title or title_alt == name_alt
|
elif (name.split(' (')[0] == title or title_alt == name_alt
|
||||||
or title_alt == org_name_alt):
|
or title_alt == org_name_alt):
|
||||||
# match found with substituting some stuff
|
# match found with substituting some stuff
|
||||||
match_found = entry
|
match_found = entry
|
||||||
break
|
break
|
||||||
|
|
||||||
# if a match was not found, we accept the closest match from TMDB
|
# if a match was not found, we accept the closest match from TMDB
|
||||||
if match_found is None and data.get("results"):
|
if match_found is None and data.get('results'):
|
||||||
LOG.info('Using very first match from themoviedb')
|
LOG.info('Using very first match from themoviedb')
|
||||||
match_found = entry = data.get("results")[0]
|
match_found = entry = data.get('results')[0]
|
||||||
|
|
||||||
if match_found is None:
|
if match_found is None:
|
||||||
LOG.info('Still no themoviedb match for type: %s, title: %s, '
|
LOG.info('Still no themoviedb match for type: %s, title: %s, '
|
||||||
|
@ -1011,23 +1011,23 @@ class API(object):
|
||||||
LOG.info('Found themoviedb match for %s: %s',
|
LOG.info('Found themoviedb match for %s: %s',
|
||||||
item.get('title'), match_found)
|
item.get('title'), match_found)
|
||||||
|
|
||||||
tmdb_id = str(entry.get("id", ""))
|
tmdb_id = str(entry.get('id', ''))
|
||||||
if tmdb_id == '':
|
if tmdb_id == '':
|
||||||
LOG.error('No themoviedb ID found, aborting')
|
LOG.error('No themoviedb ID found, aborting')
|
||||||
return
|
return
|
||||||
|
|
||||||
if media_type == "multi" and entry.get("media_type"):
|
if media_type == 'multi' and entry.get('media_type'):
|
||||||
media_type = entry.get("media_type")
|
media_type = entry.get('media_type')
|
||||||
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}
|
||||||
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":
|
if media_type == 'movie':
|
||||||
url = 'https://api.themoviedb.org/3/movie/%s' % tmdb_id
|
url = 'https://api.themoviedb.org/3/movie/%s' % tmdb_id
|
||||||
parameters['append_to_response'] = 'videos'
|
parameters['append_to_response'] = 'videos'
|
||||||
elif media_type == "tv":
|
elif media_type == 'tv':
|
||||||
url = 'https://api.themoviedb.org/3/tv/%s' % tmdb_id
|
url = 'https://api.themoviedb.org/3/tv/%s' % tmdb_id
|
||||||
parameters['append_to_response'] = 'external_ids,videos'
|
parameters['append_to_response'] = 'external_ids,videos'
|
||||||
data = DU().downloadUrl(url,
|
data = DU().downloadUrl(url,
|
||||||
|
@ -1041,16 +1041,16 @@ class API(object):
|
||||||
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') is not None:
|
||||||
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') is not None:
|
||||||
media_id = str(data["external_ids"].get("tvdb_id"))
|
media_id = str(data['external_ids'].get('tvdb_id'))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if data.get("belongs_to_collection") is None:
|
if data.get('belongs_to_collection') is None:
|
||||||
continue
|
continue
|
||||||
media_id = str(data.get("belongs_to_collection").get("id"))
|
media_id = str(data.get('belongs_to_collection').get('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
|
||||||
|
|
Loading…
Reference in a new issue