1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 11:32:20 -05:00

Fixed errors in scene exceptions when retrieving list of exceptions.

Fixed trakt.tv errors when updating/syncing show lists.
This commit is contained in:
echel0n 2014-07-17 18:06:42 -07:00
parent 7f20f5e27f
commit 70c2a2d130
4 changed files with 57 additions and 47 deletions

View File

@ -62,7 +62,7 @@ class GenericQueue(object):
if self.queueItem is None or not self.queueItem.isAlive(): if self.queueItem is None or not self.queueItem.isAlive():
# if the thread is dead then the current item should be finished # if the thread is dead then the current item should be finished
if self.currentItem != None: if self.currentItem:
self.currentItem.finish() self.currentItem.finish()
self.currentItem = None self.currentItem = None

View File

@ -223,6 +223,9 @@ def retrieve_exceptions():
existing_exceptions = [x["show_name"] for x in existing_exceptions = [x["show_name"] for x in
myDB.select("SELECT * FROM scene_exceptions WHERE indexer_id = ?", [cur_indexer_id])] myDB.select("SELECT * FROM scene_exceptions WHERE indexer_id = ?", [cur_indexer_id])]
if not cur_indexer_id in exception_dict:
continue
for cur_exception_dict in exception_dict[cur_indexer_id]: for cur_exception_dict in exception_dict[cur_indexer_id]:
cur_exception, curSeason = cur_exception_dict.items()[0] cur_exception, curSeason = cur_exception_dict.items()[0]

View File

@ -97,27 +97,31 @@ class DailySearchQueueItem(generic_queue.QueueItem):
self.segment = segment self.segment = segment
def run(self): def run(self):
generic_queue.QueueItem.run(self) generic_queue.QueueItem.run(self)
logger.log("Beginning daily search for [" + self.show.name + "]") try:
foundResults = search.searchForNeededEpisodes(self.show, self.segment)
# reset thread back to original name logger.log("Beginning daily search for [" + self.show.name + "]")
threading.currentThread().name = self.name foundResults = search.searchForNeededEpisodes(self.show, self.segment)
if not len(foundResults): # reset thread back to original name
logger.log(u"No needed episodes found during daily search for [" + self.show.name + "]") threading.currentThread().name = self.name
else:
for result in foundResults:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break if not len(foundResults):
time.sleep(common.cpu_presets[sickbeard.CPU_PRESET]) logger.log(u"No needed episodes found during daily search for [" + self.show.name + "]")
else:
for result in foundResults:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
generic_queue.QueueItem.finish(self) # give the CPU a break
time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])
generic_queue.QueueItem.finish(self)
except Exception:
logger.log(traceback.format_exc(), logger.DEBUG)
class ManualSearchQueueItem(generic_queue.QueueItem): class ManualSearchQueueItem(generic_queue.QueueItem):
def __init__(self, show, segment): def __init__(self, show, segment):
@ -161,7 +165,6 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
self.success = False self.success = False
generic_queue.QueueItem.finish(self) generic_queue.QueueItem.finish(self)
class BacklogQueueItem(generic_queue.QueueItem): class BacklogQueueItem(generic_queue.QueueItem):
def __init__(self, show, segment): def __init__(self, show, segment):
generic_queue.QueueItem.__init__(self, 'Backlog', BACKLOG_SEARCH) generic_queue.QueueItem.__init__(self, 'Backlog', BACKLOG_SEARCH)
@ -217,20 +220,20 @@ class FailedQueueItem(generic_queue.QueueItem):
def run(self): def run(self):
generic_queue.QueueItem.run(self) generic_queue.QueueItem.run(self)
for season, episodes in self.segment.items(): try:
for epObj in episodes: for season, episodes in self.segment.items():
logger.log(u"Marking episode as bad: [" + epObj.prettyName() + "]") for epObj in episodes:
failed_history.markFailed(epObj) logger.log(u"Marking episode as bad: [" + epObj.prettyName() + "]")
failed_history.markFailed(epObj)
(release, provider) = failed_history.findRelease(epObj) (release, provider) = failed_history.findRelease(epObj)
if release: if release:
failed_history.logFailed(release) failed_history.logFailed(release)
history.logFailed(epObj, release, provider) history.logFailed(epObj, release, provider)
failed_history.revertEpisode(epObj) failed_history.revertEpisode(epObj)
logger.log("Beginning failed download search for [" + epObj.prettyName() + "]") logger.log("Beginning failed download search for [" + epObj.prettyName() + "]")
try:
searchResult = search.searchProviders(self.show, season, [epObj], True) searchResult = search.searchProviders(self.show, season, [epObj], True)
# reset thread back to original name # reset thread back to original name
@ -247,7 +250,7 @@ class FailedQueueItem(generic_queue.QueueItem):
else: else:
logger.log(u"No valid episode found to retry for [" + epObj.prettyName() + "]") logger.log(u"No valid episode found to retry for [" + epObj.prettyName() + "]")
except Exception, e: except Exception:
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
self.finish() self.finish()

View File

@ -17,6 +17,7 @@
# along with SickRage. If not, see <http://www.gnu.org/licenses/>. # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
import time import time
import os import os
import traceback
import sickbeard import sickbeard
from sickbeard import encodingKludge as ek from sickbeard import encodingKludge as ek
@ -33,22 +34,22 @@ class TraktChecker():
self.todoWanted = [] self.todoWanted = []
self.todoBacklog = [] self.todoBacklog = []
def __del__(self):
pass
def run(self, force=False): def run(self, force=False):
# add shows from trakt.tv watchlist try:
if sickbeard.TRAKT_USE_WATCHLIST: # add shows from trakt.tv watchlist
self.todoWanted = [] # its about to all get re-added if sickbeard.TRAKT_USE_WATCHLIST:
if len(sickbeard.ROOT_DIRS.split('|')) < 2: self.todoWanted = [] # its about to all get re-added
logger.log(u"No default root directory", logger.ERROR) if len(sickbeard.ROOT_DIRS.split('|')) < 2:
return logger.log(u"No default root directory", logger.ERROR)
self.updateShows() return
self.updateEpisodes() self.updateShows()
self.updateEpisodes()
# sync trakt.tv library with sickrage library # sync trakt.tv library with sickrage library
if sickbeard.TRAKT_SYNC: if sickbeard.TRAKT_SYNC:
self.syncLibrary() self.syncLibrary()
except Exception:
logger.log(traceback.format_exc(), logger.DEBUG)
def findShow(self, indexerid): def findShow(self, indexerid):
library = TraktCall("user/library/shows/all.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, library = TraktCall("user/library/shows/all.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API,
@ -62,8 +63,9 @@ class TraktChecker():
def syncLibrary(self): def syncLibrary(self):
logger.log(u"Syncing library to trakt.tv show library", logger.DEBUG) logger.log(u"Syncing library to trakt.tv show library", logger.DEBUG)
for myShow in sickbeard.showList: if sickbeard.showList:
self.addShowToTraktLibrary(myShow) for myShow in sickbeard.showList:
self.addShowToTraktLibrary(myShow)
def removeShowFromTraktLibrary(self, show_obj): def removeShowFromTraktLibrary(self, show_obj):
if not self.findShow(show_obj.indexerid): if not self.findShow(show_obj.indexerid):
@ -107,9 +109,10 @@ class TraktChecker():
logger.log(u"Starting trakt show watchlist check", logger.DEBUG) logger.log(u"Starting trakt show watchlist check", logger.DEBUG)
watchlist = TraktCall("user/watchlist/shows.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, watchlist = TraktCall("user/watchlist/shows.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API,
sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD) sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
if watchlist is None: if not watchlist:
logger.log(u"Could not connect to trakt service, aborting watchlist update", logger.ERROR) logger.log(u"Could not connect to trakt service, aborting watchlist update", logger.ERROR)
return return
for show in watchlist: for show in watchlist:
if int(sickbeard.TRAKT_METHOD_ADD) != 2: if int(sickbeard.TRAKT_METHOD_ADD) != 2:
self.addDefaultShow(show["tvdb_id"], show["title"], SKIPPED) self.addDefaultShow(show["tvdb_id"], show["title"], SKIPPED)
@ -132,9 +135,10 @@ class TraktChecker():
logger.log(u"Starting trakt episode watchlist check", logger.DEBUG) logger.log(u"Starting trakt episode watchlist check", logger.DEBUG)
watchlist = TraktCall("user/watchlist/episodes.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, watchlist = TraktCall("user/watchlist/episodes.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API,
sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD) sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
if watchlist is None: if not watchlist:
logger.log(u"Could not connect to trakt service, aborting watchlist update", logger.ERROR) logger.log(u"Could not connect to trakt service, aborting watchlist update", logger.ERROR)
return return
for show in watchlist: for show in watchlist:
self.addDefaultShow(int(show["tvdb_id"]), show["title"], SKIPPED) self.addDefaultShow(int(show["tvdb_id"]), show["title"], SKIPPED)
newShow = helpers.findCertainShow(sickbeard.showList, int(show["tvdb_id"])) newShow = helpers.findCertainShow(sickbeard.showList, int(show["tvdb_id"]))