mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-22 09:33:37 +00:00
Change add role deduplication, and tidy up
This commit is contained in:
parent
b59084d27d
commit
5a11b23121
2 changed files with 40 additions and 36 deletions
|
@ -290,11 +290,20 @@ class TvdbAPIv4(TVInfoBase):
|
|||
# type: (Dict, Dict, bool) -> List[TVInfoPerson]
|
||||
ch, ids = [], ids or {}
|
||||
p_types = ([3], [3, 4])[include_guests]
|
||||
dedupe = {}
|
||||
for cur_c in sorted(filter(
|
||||
lambda a: (a['type'] in p_types or 'Actor' == a['peopleType'])
|
||||
and a['seriesId'] and ((not a.get('episodeId') and a['name']) or include_guests),
|
||||
p.get('characters') or []),
|
||||
key=lambda a: (not a['isFeatured'], a['sort'])):
|
||||
role_name = clean_data(cur_c['name'] or '')
|
||||
role_name_lc = role_name.lower()
|
||||
sid = cur_c.get('seriesId')
|
||||
if sid and sid == dedupe.get(role_name_lc):
|
||||
continue
|
||||
if role_name: # skip dedupe of records that are name ''
|
||||
dedupe[role_name_lc] = sid
|
||||
|
||||
ti_show = TVInfoShow()
|
||||
ti_show.id = clean_data(cur_c['seriesId'])
|
||||
ti_show.ids = TVInfoIDs(ids={TVINFO_TVDB: ti_show.id})
|
||||
|
@ -304,7 +313,7 @@ class TvdbAPIv4(TVInfoBase):
|
|||
ti_show.firstaired = self._get_first_aired(('series' in cur_c and cur_c['series']))
|
||||
ch.append(TVInfoCharacter(
|
||||
id=cur_c['id'], ids=TVInfoIDs(ids={TVINFO_TVDB: cur_c['id']}),
|
||||
name=clean_data(cur_c['name'] or ''),
|
||||
name=role_name,
|
||||
image=self._sanitise_image_uri(cur_c.get('image')),
|
||||
regular=cur_c['isFeatured'],
|
||||
ti_show=ti_show
|
||||
|
|
|
@ -6218,43 +6218,38 @@ class AddShows(Home):
|
|||
|
||||
def tvi_get_showinfo(self, tvid_prodid=None, oldest_dt=9999999, newest_dt=0):
|
||||
result = {}
|
||||
if isinstance(tvid_prodid, str):
|
||||
if tvid_prodid.startswith('tvmaze'):
|
||||
tvid = TVINFO_TVMAZE
|
||||
prod_id = int(tvid_prodid.replace('tvmaze:',''))
|
||||
elif tvid_prodid.startswith('tvdb'):
|
||||
if isinstance(tvid_prodid, str) and (tvid_prodid.startswith('tvmaze') or tvid_prodid.startswith('tvdb')):
|
||||
tvid = TVINFO_TVMAZE
|
||||
if tvid_prodid.startswith('tvdb'):
|
||||
tvid = TVINFO_TVDB
|
||||
prod_id = int(tvid_prodid.replace('tvdb:', ''))
|
||||
else:
|
||||
tvid = None
|
||||
if tvid:
|
||||
tvinfo_config = sickgear.TVInfoAPI(tvid).api_params.copy()
|
||||
t = sickgear.TVInfoAPI(tvid).setup(**tvinfo_config) # type: Union[TvmazeIndexer, TVInfoBase]
|
||||
show_info = t.get_show(prod_id, load_episodes=False)
|
||||
|
||||
oldest_dt, newest_dt = int(oldest_dt), int(newest_dt)
|
||||
ord_premiered, str_premiered, started_past, old_dt, new_dt, oldest, newest, \
|
||||
ok_returning, ord_returning, str_returning, return_past \
|
||||
= self.sanitise_dates(show_info.firstaired, oldest_dt, newest_dt, None, None)
|
||||
result = dict(
|
||||
ord_premiered=ord_premiered,
|
||||
str_premiered=str_premiered,
|
||||
#ord_returning=ord_returning,
|
||||
#str_returning=str_returning,
|
||||
started_past=started_past,
|
||||
#return_past=return_past,
|
||||
genres=((show_info.genre or '')
|
||||
or ', '.join(show_info.genre_list)
|
||||
or ', '.join(show_info.show_type) or '').strip('|').replace('|', ', ').lower(),
|
||||
overview=self.clean_overview(show_info),
|
||||
network=show_info.network or ', '.join(show_info.networks) or '',
|
||||
)
|
||||
if old_dt < oldest_dt:
|
||||
result['oldest_dt'] = old_dt
|
||||
result['oldest'] = oldest
|
||||
elif new_dt > newest_dt:
|
||||
result['newest_dt'] = old_dt
|
||||
result['newest'] = newest,
|
||||
tvinfo_config = sickgear.TVInfoAPI(tvid).api_params.copy()
|
||||
t = sickgear.TVInfoAPI(tvid).setup(**tvinfo_config) # type: Union[TvmazeIndexer, TVInfoBase]
|
||||
show_info = t.get_show(int(re.sub('^[a-z]+?:', '', tvid_prodid)), load_episodes=False)
|
||||
|
||||
oldest_dt, newest_dt = int(oldest_dt), int(newest_dt)
|
||||
ord_premiered, str_premiered, started_past, old_dt, new_dt, oldest, newest, \
|
||||
ok_returning, ord_returning, str_returning, return_past \
|
||||
= self.sanitise_dates(show_info.firstaired, oldest_dt, newest_dt, None, None)
|
||||
result = dict(
|
||||
ord_premiered=ord_premiered,
|
||||
str_premiered=str_premiered,
|
||||
#ord_returning=ord_returning,
|
||||
#str_returning=str_returning,
|
||||
started_past=started_past,
|
||||
#return_past=return_past,
|
||||
genres=((show_info.genre or '')
|
||||
or ', '.join(show_info.genre_list)
|
||||
or ', '.join(show_info.show_type) or '').strip('|').replace('|', ', ').lower(),
|
||||
overview=self.clean_overview(show_info),
|
||||
network=show_info.network or ', '.join(show_info.networks) or '',
|
||||
)
|
||||
if old_dt < oldest_dt:
|
||||
result['oldest_dt'] = old_dt
|
||||
result['oldest'] = oldest
|
||||
elif new_dt > newest_dt:
|
||||
result['newest_dt'] = old_dt
|
||||
result['newest'] = newest,
|
||||
|
||||
return json_dumps(result)
|
||||
|
||||
|
|
Loading…
Reference in a new issue