(WIP) Started intergrating xem
This commit is contained in:
1 parent
906a54ef09
commit
314016e1fa
4 files changed
+51
-27
No files matched your search
@@ -82,16 +82,6 @@ class ShowBase(MediaBase):
|
|||||||
|
|
||||||
def add(self, params = {}, force_readd = True, search_after = True, update_library = False, status_id = None):
|
def add(self, params = {}, force_readd = True, search_after = True, update_library = False, status_id = None):
|
||||||
"""
|
"""
|
||||||
1. Add Show
|
|
||||||
2. Add All Episodes
|
|
||||||
3. Add All Seasons
|
|
||||||
|
|
||||||
Notes, not to forget:
|
|
||||||
- relate parent and children, possible grandparent to grandchild so episodes know it belong to show, etc
|
|
||||||
- looks like we dont send info to library; it comes later
|
|
||||||
- change references to plot to description
|
|
||||||
- change Model to Media
|
|
||||||
|
|
||||||
params
|
params
|
||||||
{'category_id': u'-1',
|
{'category_id': u'-1',
|
||||||
'identifier': u'tt1519931',
|
'identifier': u'tt1519931',
|
||||||
@@ -102,10 +92,21 @@ class ShowBase(MediaBase):
|
|||||||
log.debug("show.add")
|
log.debug("show.add")
|
||||||
|
|
||||||
# Add show parent to db first; need to update library so maps will be in place (if any)
|
# 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')
|
parent = self.addToDatabase(params = params, update_library = True, type = 'show')
|
||||||
|
|
||||||
|
# TODO: add by airdate
|
||||||
|
|
||||||
|
# Add by Season/Episode numbers
|
||||||
|
self.addBySeasonEpisode(parent,
|
||||||
|
params = params,
|
||||||
|
force_readd = force_readd,
|
||||||
|
search_after = search_after,
|
||||||
|
update_library = update_library,
|
||||||
|
status_id = status_id
|
||||||
|
)
|
||||||
|
|
||||||
|
def addBySeasonEpisode(self, parent, params = {}, force_readd = True, search_after = True, update_library = False, status_id = None):
|
||||||
identifier = params.get('id')
|
identifier = params.get('id')
|
||||||
|
|
||||||
|
|
||||||
# 'tvdb' will always be the master for our purpose. All mapped data can be mapped
|
# '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
|
# 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
|
# when renamed so media can be used in media players that use tvdb for info provider
|
||||||
@@ -113,12 +114,15 @@ class ShowBase(MediaBase):
|
|||||||
# This currently means the episode must actually exist in tvdb in order to be found but
|
# This currently means the episode must actually exist in tvdb in order to be found but
|
||||||
# the numbering can be different
|
# the numbering can be different
|
||||||
|
|
||||||
# XXX:
|
|
||||||
# Map Notes:
|
|
||||||
# (in progress...)
|
|
||||||
# map = parent['library']['info']['map']
|
|
||||||
#master = 'tvdb'
|
#master = 'tvdb'
|
||||||
#destination = 'scene'
|
#destination = 'scene'
|
||||||
|
#destination = 'anidb'
|
||||||
|
#destination = 'rage'
|
||||||
|
#destination = 'trakt'
|
||||||
|
# TODO: auto mode. if anime exists use it. if scene exists use it else use tvdb
|
||||||
|
|
||||||
|
# XXX: We should abort adding show, etc if either tvdb or xem is down or we will have incorrent mappings
|
||||||
|
# I think if tvdb gets error we wont have anydata anyway, but we must make sure XEM returns!!!!
|
||||||
|
|
||||||
# Only the master should return results here; all other info providers should just return False
|
# 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.
|
# since we are just interested in the structure at this point.
|
||||||
@@ -131,14 +135,16 @@ class ShowBase(MediaBase):
|
|||||||
season_id = season.get('id', None)
|
season_id = season.get('id', None)
|
||||||
if season_id is None: continue
|
if season_id is None: continue
|
||||||
|
|
||||||
|
season_params = {'season_identifier': season_id}
|
||||||
# Calling all info providers; merge your info now for individual season
|
# 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 = fireEvent('season.info', merge = True, identifier = identifier, params = season_params)
|
||||||
single_season['title'] = single_season.get('original_title', None)
|
single_season['title'] = single_season.get('original_title', None)
|
||||||
single_season['identifier'] = season_id
|
single_season['identifier'] = season_id
|
||||||
single_season['parent_identifier'] = identifier
|
single_season['parent_identifier'] = identifier
|
||||||
s = self.addToDatabase(params = single_season, type = "season")
|
s = self.addToDatabase(params = single_season, type = "season")
|
||||||
|
|
||||||
episodes = fireEvent('episode.info', merge = True, identifier = identifier, season_identifier = season_id)
|
episode_params = {'season_identifier': season_id}
|
||||||
|
episodes = fireEvent('episode.info', merge = True, identifier = identifier, params = episode_params)
|
||||||
if episodes is not None:
|
if episodes is not None:
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
# Make sure we are only dealing with 'tvdb' responses at this point
|
# Make sure we are only dealing with 'tvdb' responses at this point
|
||||||
@@ -146,10 +152,22 @@ class ShowBase(MediaBase):
|
|||||||
continue
|
continue
|
||||||
episode_id = episode.get('id', None)
|
episode_id = episode.get('id', None)
|
||||||
if episode_id is None: continue
|
if episode_id is None: continue
|
||||||
|
try:
|
||||||
|
episode_number = int(episode.get('episodenumber', None))
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
absolute_number = int(episode.get('absolute_number', None))
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
absolute_number = None
|
||||||
|
|
||||||
|
episode_params = {'season_identifier': season_id,
|
||||||
|
'episode_identifier': episode_id,
|
||||||
|
'episode': episode_number}
|
||||||
|
if absolute_number:
|
||||||
|
episode_params['absolute'] = absolute_number
|
||||||
# Calling all info providers; merge your info now for individual episode
|
# Calling all info providers; merge your info now for individual episode
|
||||||
single_episode = fireEvent('episode.info', merge = True, identifier = identifier,
|
single_episode = fireEvent('episode.info', merge = True, identifier = identifier, params = episode_params)
|
||||||
season_identifier = season_id, episode_identifier = episode_id)
|
|
||||||
single_episode['title'] = single_episode.get('original_title', None)
|
single_episode['title'] = single_episode.get('original_title', None)
|
||||||
single_episode['identifier'] = episode_id
|
single_episode['identifier'] = episode_id
|
||||||
single_episode['parent_identifier'] = single_season['identifier']
|
single_episode['parent_identifier'] = single_season['identifier']
|
||||||
|
|||||||
@@ -88,8 +88,9 @@ class EpisodeLibraryPlugin(LibraryBase):
|
|||||||
if library.status_id == done_status.get('id') and not force:
|
if library.status_id == done_status.get('id') and not force:
|
||||||
do_update = False
|
do_update = False
|
||||||
|
|
||||||
info = fireEvent('episode.info', merge = True, season_identifier = parent_identifier, \
|
episode_params = {'season_identifier': parent_identifier,
|
||||||
episode_identifier = identifier)
|
'episode_identifier': identifier}
|
||||||
|
info = fireEvent('episode.info', merge = True, params = episode_params)
|
||||||
|
|
||||||
# Don't need those here
|
# Don't need those here
|
||||||
try: del info['in_wanted']
|
try: del info['in_wanted']
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class SeasonLibraryPlugin(LibraryBase):
|
|||||||
if library.status_id == done_status.get('id') and not force:
|
if library.status_id == done_status.get('id') and not force:
|
||||||
do_update = False
|
do_update = False
|
||||||
|
|
||||||
info = fireEvent('season.info', merge = True, identifier = parent_identifier, \
|
season_params = {'season_identifier': identifier}
|
||||||
season_identifier = identifier)
|
info = fireEvent('season.info', merge = True, identifier = parent_identifier, params = season_params)
|
||||||
|
|
||||||
# Don't need those here
|
# Don't need those here
|
||||||
try: del info['in_wanted']
|
try: del info['in_wanted']
|
||||||
|
|||||||
@@ -110,13 +110,15 @@ class TheTVDb(ShowProvider):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getSeasonInfo(self, identifier=None, season_identifier=None):
|
def getSeasonInfo(self, identifier = None, params = {}):
|
||||||
"""Either return a list of all seasons or a single season by number.
|
"""Either return a list of all seasons or a single season by number.
|
||||||
identifier is the show 'id'
|
identifier is the show 'id'
|
||||||
"""
|
"""
|
||||||
if not identifier:
|
if not identifier:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
season_identifier = params.get('season_identifier', None)
|
||||||
|
|
||||||
# season_identifier must contain the 'show id : season number' since there is no tvdb id
|
# season_identifier must contain the 'show id : season number' since there is no tvdb id
|
||||||
# for season and we need a reference to both the show id and season number
|
# for season and we need a reference to both the show id and season number
|
||||||
if season_identifier:
|
if season_identifier:
|
||||||
@@ -147,10 +149,13 @@ class TheTVDb(ShowProvider):
|
|||||||
self.setCache(cache_key, result)
|
self.setCache(cache_key, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getEpisodeInfo(self, identifier=None, season_identifier=None, episode_identifier=None):
|
def getEpisodeInfo(self, identifier = None, params = {}):
|
||||||
"""Either return a list of all episodes or a single episode.
|
"""Either return a list of all episodes or a single episode.
|
||||||
If episode_identifer contains an episode number to search for
|
If episode_identifer contains an episode number to search for
|
||||||
"""
|
"""
|
||||||
|
season_identifier = params.get('season_identifier', None)
|
||||||
|
episode_identifier = params.get('episode_identifier', None)
|
||||||
|
|
||||||
if not identifier and season_identifier is None:
|
if not identifier and season_identifier is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user