1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04: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 the thread is dead then the current item should be finished
if self.currentItem != None:
if self.currentItem:
self.currentItem.finish()
self.currentItem = None

View File

@ -223,6 +223,9 @@ def retrieve_exceptions():
existing_exceptions = [x["show_name"] for x in
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]:
cur_exception, curSeason = cur_exception_dict.items()[0]

View File

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

View File

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