Reworked code to allow better intergration of other info providers. Initial prep for xem mapping
This commit is contained in:
@@ -101,36 +101,59 @@ class ShowBase(MediaBase):
|
||||
"""
|
||||
log.debug("show.add")
|
||||
|
||||
# Add show parent to db first
|
||||
parent = self.addToDatabase(params = params, type = 'show')
|
||||
|
||||
# Add show parent to db first; need to update library so maps will be in place (if any)
|
||||
parent = self.addToDatabase(params = params, update_library = True, type = 'show')
|
||||
identifier = params.get('id')
|
||||
|
||||
# XXX: Fix so we dont have a nested list [0] (fireEvent)
|
||||
try:
|
||||
seasons = fireEvent('season.info', identifier = identifier)[0]
|
||||
except: return None
|
||||
|
||||
# 'tvdb' will always be the master for our purpose. All mapped data can be mapped
|
||||
# to another source for downloading, but it will always be remapped back to tvdb numbering
|
||||
# when renamed so media can be used in media players that use tvdb for info provider
|
||||
#
|
||||
# This currently means the episode must actually exist in tvdb in order to be found but
|
||||
# the numbering can be different
|
||||
|
||||
# XXX:
|
||||
# Map Notes:
|
||||
# (in progress...)
|
||||
# map = parent['library']['info']['map']
|
||||
#master = 'tvdb'
|
||||
#destination = 'scene'
|
||||
|
||||
# Only the master should return results here; all other info providers should just return False
|
||||
# since we are just interested in the structure at this point.
|
||||
seasons = fireEvent('season.info', merge = True, identifier = identifier)
|
||||
if seasons is not None:
|
||||
for season in seasons:
|
||||
season['title'] = season.get('title', None)
|
||||
# Make sure we are only dealing with 'tvdb' responses at this point
|
||||
if season.get('primary_provider', None) != 'thetvdb':
|
||||
continue
|
||||
season_id = season.get('id', None)
|
||||
if season_id is None: continue
|
||||
season['identifier'] = season_id
|
||||
season['parent_identifier'] = identifier
|
||||
self.addToDatabase(params=season, type = "season")
|
||||
|
||||
# XXX: Fix so we dont have a nested list [0] (fireEvent)
|
||||
try:
|
||||
episodes = fireEvent('episode.info', identifier = identifier, season_identifier = season_id)[0]
|
||||
except: continue
|
||||
# Calling all info providers; merge your info now for individual season
|
||||
single_season = fireEvent('season.info', merge = True, identifier = identifier, season_identifier = season_id)
|
||||
single_season['title'] = single_season.get('original_title', None)
|
||||
single_season['identifier'] = season_id
|
||||
single_season['parent_identifier'] = identifier
|
||||
s = self.addToDatabase(params = single_season, type = "season")
|
||||
|
||||
episodes = fireEvent('episode.info', merge = True, identifier = identifier, season_identifier = season_id)
|
||||
if episodes is not None:
|
||||
for episode in episodes:
|
||||
episode['title'] = episode.get('titles', None)[0] # XXX. [0] will create exception. FIX!
|
||||
# Make sure we are only dealing with 'tvdb' responses at this point
|
||||
if episode.get('primary_provider', None) != 'thetvdb':
|
||||
continue
|
||||
episode_id = episode.get('id', None)
|
||||
if episode_id is None: continue
|
||||
episode['identifier'] = episode_id
|
||||
episode['parent_identifier'] = season['identifier']
|
||||
self.addToDatabase(params=episode, type = "episode")
|
||||
|
||||
# Calling all info providers; merge your info now for individual episode
|
||||
single_episode = fireEvent('episode.info', merge = True, identifier = identifier,
|
||||
season_identifier = season_id, episode_identifier = episode_id)
|
||||
single_episode['title'] = single_episode.get('original_title', None)
|
||||
single_episode['identifier'] = episode_id
|
||||
single_episode['parent_identifier'] = single_season['identifier']
|
||||
e = self.addToDatabase(params = single_episode, type = "episode")
|
||||
|
||||
return parent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user