Merge pull request #657 from JackDandy/feature/ChangeUpdateShows

Change during update set shows with newly added airdate to wanted and…
This commit is contained in:
JackDandy 2016-03-06 00:48:00 +00:00
commit 644385e346
5 changed files with 417 additions and 433 deletions

View file

@ -37,6 +37,7 @@
Mass Update, Add with Browse and from Existing views Mass Update, Add with Browse and from Existing views
* Add Emby notifier to config/Notifications * Add Emby notifier to config/Notifications
* Fix alternative unicode show names from breaking search * Fix alternative unicode show names from breaking search
* Change show update, set shows with newly added airdate or existing episodes with future or never dates, to "Wanted"
### 0.11.6 (2016-02-18 23:10:00 UTC) ### 0.11.6 (2016-02-18 23:10:00 UTC)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 784 B

View file

@ -138,7 +138,7 @@ class ShowQueue(generic_queue.GenericQueue):
if ((not after_update and self.isBeingUpdated(show)) or self.isInUpdateQueue(show)) and not force: if ((not after_update and self.isBeingUpdated(show)) or self.isInUpdateQueue(show)) and not force:
logger.log( logger.log(
u'Skipping this refresh as there is already an update queued or in progress and a refresh is done at the end of an update anyway.', 'Skipping this refresh as there is already an update queued or in progress and a refresh is done at the end of an update anyway.',
logger.DEBUG) logger.DEBUG)
return return
@ -276,7 +276,7 @@ class QueueItemAdd(ShowQueueItem):
ShowQueueItem.run(self) ShowQueueItem.run(self)
logger.log(u'Starting to add show ' + self.showDir) logger.log('Starting to add show %s' % self.showDir)
# make sure the Indexer IDs are valid # make sure the Indexer IDs are valid
try: try:
@ -291,29 +291,27 @@ class QueueItemAdd(ShowQueueItem):
# this usually only happens if they have an NFO in their show dir which gave us a Indexer ID that has no proper english version of the show # this usually only happens if they have an NFO in their show dir which gave us a Indexer ID that has no proper english version of the show
if getattr(s, 'seriesname', None) is None: if getattr(s, 'seriesname', None) is None:
logger.log(u'Show in ' + self.showDir + ' has no name on ' + str( logger.log('Show in %s has no name on %s, probably the wrong language used to search with.' %
sickbeard.indexerApi(self.indexer).name) + ', probably the wrong language used to search with.', (self.showDir, sickbeard.indexerApi(self.indexer).name), logger.ERROR)
logger.ERROR)
ui.notifications.error('Unable to add show', ui.notifications.error('Unable to add show',
'Show in ' + self.showDir + ' has no name on ' + str(sickbeard.indexerApi( 'Show in %s has no name on %s, probably the wrong language. Delete .nfo and add manually in the correct language.' %
self.indexer).name) + ', probably the wrong language. Delete .nfo and add manually in the correct language.') (self.showDir, sickbeard.indexerApi(self.indexer).name))
self._finishEarly() self._finishEarly()
return return
# if the show has no episodes/seasons # if the show has no episodes/seasons
if not sickbeard.ALLOW_INCOMPLETE_SHOWDATA and not s: if not sickbeard.ALLOW_INCOMPLETE_SHOWDATA and not s:
msg = u'Show %s is on %s but contains no season/episode data. Only the show folder was created.'\ msg = 'Show %s is on %s but contains no season/episode data. Only the show folder was created.'\
% (s['seriesname'], sickbeard.indexerApi(self.indexer).name) % (s['seriesname'], sickbeard.indexerApi(self.indexer).name)
logger.log(msg, logger.ERROR) logger.log(msg, logger.ERROR)
ui.notifications.error('Unable to add show', msg) ui.notifications.error('Unable to add show', msg)
self._finishEarly() self._finishEarly()
return return
except Exception as e: except Exception as e:
logger.log(u'Unable to find show ID:' + str(self.indexer_id) + ' on Indexer: ' + str( logger.log('Unable to find show ID:%s on Indexer: %s' % (self.indexer_id, sickbeard.indexerApi(self.indexer).name),
sickbeard.indexerApi(self.indexer).name), logger.ERROR) logger.ERROR)
ui.notifications.error('Unable to add show', ui.notifications.error('Unable to add show',
'Unable to look up the show in ' + self.showDir + ' on ' + str(sickbeard.indexerApi( 'Unable to look up the show in %s on %s using ID %s, not using the NFO. Delete .nfo and try adding manually again.' %
self.indexer).name) + ' using ID ' + str( (self.showDir, sickbeard.indexerApi(self.indexer).name, self.indexer_id))
self.indexer_id) + ', not using the NFO. Delete .nfo and try adding manually again.')
self._finishEarly() self._finishEarly()
return return
@ -350,26 +348,25 @@ class QueueItemAdd(ShowQueueItem):
except sickbeard.indexer_exception as e: except sickbeard.indexer_exception as e:
logger.log( logger.log(
u'Unable to add show due to an error with ' + sickbeard.indexerApi(self.indexer).name + ': ' + ex(e), 'Unable to add show due to an error with %s: %s' % (sickbeard.indexerApi(self.indexer).name, ex(e)),
logger.ERROR) logger.ERROR)
if self.show: if self.show:
ui.notifications.error( ui.notifications.error(
'Unable to add ' + str(self.show.name) + ' due to an error with ' + sickbeard.indexerApi( 'Unable to add %s due to an error with %s' % (self.show.name, sickbeard.indexerApi(self.indexer).name))
self.indexer).name + '')
else: else:
ui.notifications.error( ui.notifications.error(
'Unable to add show due to an error with ' + sickbeard.indexerApi(self.indexer).name + '') 'Unable to add show due to an error with %s' % sickbeard.indexerApi(self.indexer).name)
self._finishEarly() self._finishEarly()
return return
except exceptions.MultipleShowObjectsException: except exceptions.MultipleShowObjectsException:
logger.log(u'The show in ' + self.showDir + ' is already in your show list, skipping', logger.ERROR) logger.log('The show in %s is already in your show list, skipping' % self.showDir, logger.ERROR)
ui.notifications.error('Show skipped', 'The show in ' + self.showDir + ' is already in your show list') ui.notifications.error('Show skipped', 'The show in %s is already in your show list' % self.showDir)
self._finishEarly() self._finishEarly()
return return
except Exception as e: except Exception as e:
logger.log(u'Error trying to add show: ' + ex(e), logger.ERROR) logger.log('Error trying to add show: %s' % ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
self._finishEarly() self._finishEarly()
raise raise
@ -379,7 +376,7 @@ class QueueItemAdd(ShowQueueItem):
try: try:
self.show.saveToDB() self.show.saveToDB()
except Exception as e: except Exception as e:
logger.log(u'Error saving the show to the database: ' + ex(e), logger.ERROR) logger.log('Error saving the show to the database: %s' % ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
self._finishEarly() self._finishEarly()
raise raise
@ -391,20 +388,20 @@ class QueueItemAdd(ShowQueueItem):
self.show.loadEpisodesFromIndexer() self.show.loadEpisodesFromIndexer()
except Exception as e: except Exception as e:
logger.log( logger.log(
u'Error with ' + sickbeard.indexerApi(self.show.indexer).name + ', not creating episode list: ' + ex(e), 'Error with %s, not creating episode list: %s' % (sickbeard.indexerApi(self.show.indexer).name, ex(e)),
logger.ERROR) logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
try: try:
self.show.loadEpisodesFromDir() self.show.loadEpisodesFromDir()
except Exception as e: except Exception as e:
logger.log(u'Error searching directory for episodes: ' + ex(e), logger.ERROR) logger.log('Error searching directory for episodes: %s' % ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
# if they gave a custom status then change all the eps to it # if they gave a custom status then change all the eps to it
my_db = db.DBConnection() my_db = db.DBConnection()
if self.default_status != SKIPPED: if self.default_status != SKIPPED:
logger.log(u'Setting all episodes to the specified default status: ' + str(self.default_status)) logger.log('Setting all episodes to the specified default status: %s' % sickbeard.common.statusStrings[self.default_status])
my_db.action('UPDATE tv_episodes SET status = ? WHERE status = ? AND showid = ? AND season != 0', my_db.action('UPDATE tv_episodes SET status = ? WHERE status = ? AND showid = ? AND season != 0',
[self.default_status, SKIPPED, self.show.indexerid]) [self.default_status, SKIPPED, self.show.indexerid])
@ -447,7 +444,7 @@ class QueueItemAdd(ShowQueueItem):
msg = ' the specified show into ' + self.showDir msg = ' the specified show into ' + self.showDir
# if started with WANTED eps then run the backlog # if started with WANTED eps then run the backlog
if WANTED == self.default_status or items_wanted: if WANTED == self.default_status or items_wanted:
logger.log(u'Launching backlog for this show since episodes are WANTED') logger.log('Launching backlog for this show since episodes are WANTED')
sickbeard.backlogSearchScheduler.action.search_backlog([self.show]) #@UndefinedVariable sickbeard.backlogSearchScheduler.action.search_backlog([self.show]) #@UndefinedVariable
ui.notifications.message('Show added/search', 'Adding and searching for episodes of' + msg) ui.notifications.message('Show added/search', 'Adding and searching for episodes of' + msg)
else: else:
@ -471,7 +468,7 @@ class QueueItemAdd(ShowQueueItem):
sickbeard.scene_numbering.xem_refresh(self.show.indexerid, self.show.indexer, force=True) sickbeard.scene_numbering.xem_refresh(self.show.indexerid, self.show.indexer, force=True)
# check if show has XEM mapping and if user disabled scene numbering during add show, output availability to log # check if show has XEM mapping and if user disabled scene numbering during add show, output availability to log
if not self.scene and self.show.indexerid in sickbeard.scene_exceptions.xem_ids_list[self.show.indexer]: if not self.scene and self.show.indexerid in sickbeard.scene_exceptions.xem_ids_list[self.show.indexer]:
logger.log(u'Alternative scene episode numbers were disabled during add show. Edit show to enable them for searching.') logger.log('Alternative scene episode numbers were disabled during add show. Edit show to enable them for searching.')
# update internal name cache # update internal name cache
name_cache.buildNameCache(self.show) name_cache.buildNameCache(self.show)
@ -521,12 +518,12 @@ class QueueItemRename(ShowQueueItem):
ShowQueueItem.run(self) ShowQueueItem.run(self)
logger.log(u'Performing rename on ' + self.show.name) logger.log('Performing rename on %s' % self.show.name)
try: try:
show_loc = self.show.location show_loc = self.show.location
except exceptions.ShowDirNotFoundException: except exceptions.ShowDirNotFoundException:
logger.log(u'Can\'t perform rename on ' + self.show.name + ' when the show directory is missing.', logger.WARNING) logger.log('Can\'t perform rename on %s when the show directory is missing.' % self.show.name, logger.WARNING)
return return
ep_obj_rename_list = [] ep_obj_rename_list = []
@ -561,7 +558,7 @@ class QueueItemSubtitle(ShowQueueItem):
def run(self): def run(self):
ShowQueueItem.run(self) ShowQueueItem.run(self)
logger.log(u'Downloading subtitles for ' + self.show.name) logger.log('Downloading subtitles for %s' % self.show.name)
self.show.downloadSubtitles() self.show.downloadSubtitles()
@ -579,24 +576,24 @@ class QueueItemUpdate(ShowQueueItem):
ShowQueueItem.run(self) ShowQueueItem.run(self)
if not sickbeard.indexerApi(self.show.indexer).config['active']: if not sickbeard.indexerApi(self.show.indexer).config['active']:
logger.log(u'Indexer %s is marked inactive, aborting update for show %s and continue with refresh.' % (sickbeard.indexerApi(self.show.indexer).config['name'], self.show.name)) logger.log('Indexer %s is marked inactive, aborting update for show %s and continue with refresh.' % (sickbeard.indexerApi(self.show.indexer).config['name'], self.show.name))
sickbeard.showQueueScheduler.action.refreshShow(self.show, self.force, self.scheduled_update, after_update=True) sickbeard.showQueueScheduler.action.refreshShow(self.show, self.force, self.scheduled_update, after_update=True)
return return
logger.log(u'Beginning update of ' + self.show.name) logger.log('Beginning update of %s' % self.show.name)
logger.log(u'Retrieving show info from ' + sickbeard.indexerApi(self.show.indexer).name + '', logger.DEBUG) logger.log('Retrieving show info from %s' % sickbeard.indexerApi(self.show.indexer).name, logger.DEBUG)
try: try:
result = self.show.loadFromIndexer(cache=not self.force) result = self.show.loadFromIndexer(cache=not self.force)
if None is not result: if None is not result:
return return
except sickbeard.indexer_error as e: except sickbeard.indexer_error as e:
logger.log(u'Unable to contact ' + sickbeard.indexerApi(self.show.indexer).name + ', aborting: ' + ex(e), logger.log('Unable to contact %s, aborting: %s' % (sickbeard.indexerApi(self.show.indexer).name, ex(e)),
logger.WARNING) logger.WARNING)
return return
except sickbeard.indexer_attributenotfound as e: except sickbeard.indexer_attributenotfound as e:
logger.log(u'Data retrieved from ' + sickbeard.indexerApi( logger.log('Data retrieved from %s was incomplete, aborting: %s' %
self.show.indexer).name + ' was incomplete, aborting: ' + ex(e), logger.ERROR) (sickbeard.indexerApi(self.show.indexer).name, ex(e)), logger.ERROR)
return return
if self.force_web: if self.force_web:
@ -605,39 +602,38 @@ class QueueItemUpdate(ShowQueueItem):
try: try:
self.show.saveToDB() self.show.saveToDB()
except Exception as e: except Exception as e:
logger.log(u'Error saving the episode to the database: ' + ex(e), logger.ERROR) logger.log('Error saving the episode to the database: %s' % ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
# get episode list from DB # get episode list from DB
logger.log(u'Loading all episodes from the database', logger.DEBUG) logger.log('Loading all episodes from the database', logger.DEBUG)
DBEpList = self.show.loadEpisodesFromDB() DBEpList = self.show.loadEpisodesFromDB(update=True)
# get episode list from TVDB # get episode list from TVDB
logger.log(u'Loading all episodes from ' + sickbeard.indexerApi(self.show.indexer).name + '', logger.DEBUG) logger.log('Loading all episodes from %s' % sickbeard.indexerApi(self.show.indexer).name, logger.DEBUG)
try: try:
IndexerEpList = self.show.loadEpisodesFromIndexer(cache=not self.force) IndexerEpList = self.show.loadEpisodesFromIndexer(cache=not self.force, update=True)
except sickbeard.indexer_exception as e: except sickbeard.indexer_exception as e:
logger.log(u'Unable to get info from ' + sickbeard.indexerApi( logger.log('Unable to get info from %s, the show info will not be refreshed: %s' %
self.show.indexer).name + ', the show info will not be refreshed: ' + ex(e), logger.ERROR) (sickbeard.indexerApi(self.show.indexer).name, ex(e)), logger.ERROR)
IndexerEpList = None IndexerEpList = None
if IndexerEpList == None: if IndexerEpList == None:
logger.log(u'No data returned from ' + sickbeard.indexerApi( logger.log('No data returned from %s, unable to update this show' %
self.show.indexer).name + ', unable to update this show', logger.ERROR) sickbeard.indexerApi(self.show.indexer).name, logger.ERROR)
else: else:
# for each ep we found on TVDB delete it from the DB list # for each ep we found on TVDB delete it from the DB list
for curSeason in IndexerEpList: for curSeason in IndexerEpList:
for curEpisode in IndexerEpList[curSeason]: for curEpisode in IndexerEpList[curSeason]:
logger.log(u'Removing ' + str(curSeason) + 'x' + str(curEpisode) + ' from the DB list', logger.log('Removing %sx%s from the DB list' % (curSeason, curEpisode), logger.DEBUG)
logger.DEBUG)
if curSeason in DBEpList and curEpisode in DBEpList[curSeason]: if curSeason in DBEpList and curEpisode in DBEpList[curSeason]:
del DBEpList[curSeason][curEpisode] del DBEpList[curSeason][curEpisode]
# for the remaining episodes in the DB list just delete them from the DB # for the remaining episodes in the DB list just delete them from the DB
for curSeason in DBEpList: for curSeason in DBEpList:
for curEpisode in DBEpList[curSeason]: for curEpisode in DBEpList[curSeason]:
logger.log(u'Permanently deleting episode ' + str(curSeason) + 'x' + str( logger.log('Permanently deleting episode %sx%s from the database' %
curEpisode) + ' from the database', logger.MESSAGE) (curSeason, curEpisode), logger.MESSAGE)
curEp = self.show.getEpisode(curSeason, curEpisode) curEp = self.show.getEpisode(curSeason, curEpisode)
try: try:
curEp.deleteEpisode() curEp.deleteEpisode()

File diff suppressed because it is too large Load diff