1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fix for trakt.tv issues when adding/removing/syncing shows.

Fix for indexer mapper to return a result no matter what.
This commit is contained in:
echel0n 2014-07-30 16:33:28 -07:00
parent 281c5c333e
commit b8b5947ae6
4 changed files with 35 additions and 45 deletions

View File

@ -1139,7 +1139,11 @@ def extractZip(archive, targetDir):
def mapIndexersToShow(showObj):
mapped = {showObj.indexer: showObj.indexerid}
mapped = {}
# init mapped indexers object
for indexer in sickbeard.indexerApi().indexers:
mapped[indexer] = showObj.indexerid if int(indexer) == int(showObj.indexer) else 0
myDB = db.DBConnection()
sqlResults = myDB.select(

View File

@ -98,9 +98,9 @@ class NewznabProvider(generic.NZBProvider):
cur_params['season'] = str(ep_obj.scene_season)
# search
mindexers = helpers.mapIndexersToShow(ep_obj.show)
if 2 in mindexers:
cur_params['rid'] = mindexers[2]
rid = helpers.mapIndexersToShow(ep_obj.show)[2]
if rid:
cur_params['rid'] = rid
to_return.append(cur_params)
else:
# add new query strings for exceptions
@ -131,9 +131,9 @@ class NewznabProvider(generic.NZBProvider):
params['ep'] = ep_obj.scene_episode
# search
mindexers = helpers.mapIndexersToShow(ep_obj.show)
if 2 in mindexers:
params['rid'] = mindexers[2]
rid = helpers.mapIndexersToShow(ep_obj.show)[2]
if rid:
params['rid'] = rid
to_return.append(params)
else:
# add new query strings for exceptions

View File

@ -60,29 +60,23 @@ class TraktChecker():
return filter(lambda x: int(indexerid) in [int(x['tvdb_id']) or 0, int(x['tvrage_id'])] or 0, library)
def syncLibrary(self):
logger.log(u"Syncing library to Trakt.tv show library", logger.DEBUG)
if sickbeard.showList:
for myShow in sickbeard.showList:
self.addShowToTraktLibrary(myShow)
logger.log(u"Syncing Trakt.tv show library", logger.DEBUG)
for myShow in sickbeard.showList:
self.addShowToTraktLibrary(myShow)
def removeShowFromTraktLibrary(self, show_obj):
data = {}
if self.findShow(show_obj.indexer, show_obj.indexerid):
# URL parameters
data = {}
if show_obj.indexer == 1:
data['tvdb_id'] = show_obj.indexerid
data['title'] = show_obj.name
data['year'] = show_obj.startyear
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
data['title'] = show_obj.name
data['year'] = show_obj.startyear
elif show_obj.indexer == 2:
data['tvrage_id'] = show_obj.indexerid
data['title'] = show_obj.name
data['year'] = show_obj.startyear
if data is not None:
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
TraktCall("show/unlibrary/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
data)
if len(data):
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
TraktCall("show/unlibrary/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
data)
def addShowToTraktLibrary(self, show_obj):
"""
@ -91,23 +85,18 @@ class TraktChecker():
show_obj: The TVShow object to add to trakt
"""
data = {}
if not self.findShow(show_obj.indexer, show_obj.indexerid):
# URL parameters
data = {}
if show_obj.indexer == 1:
data['tvdb_id'] = show_obj.indexerid
data['title'] = show_obj.name
data['year'] = show_obj.startyear
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
data['title'] = show_obj.name
data['year'] = show_obj.startyear
elif show_obj.indexer == 2:
data['tvrage_id'] = show_obj.indexerid
data['title'] = show_obj.name
data['year'] = show_obj.startyear
if data:
logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG)
TraktCall("show/library/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
data)
if len(data):
logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG)
TraktCall("show/library/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
data)
def updateShows(self):
logger.log(u"Starting trakt show watchlist check", logger.DEBUG)

View File

@ -1720,8 +1720,6 @@ class CMD_Show(ApiCall):
if not showObj:
return _responds(RESULT_FAILURE, msg="Show not found")
mindexers = helpers.mapIndexersToShow(showObj)
showDict = {}
showDict["season_list"] = CMD_ShowSeasonList(self.handler, (), {"indexerid": self.indexerid}).run()["data"]
showDict["cache"] = CMD_ShowCache(self.handler, (), {"indexerid": self.indexerid}).run()["data"]
@ -1752,7 +1750,7 @@ class CMD_Show(ApiCall):
showDict["anime"] = showObj.anime
#clean up tvdb horrible airs field
showDict["airs"] = str(showObj.airs).replace('am', ' AM').replace('pm', ' PM').replace(' ', ' ')
showDict["tvrage_id"] = mindexers[2] if 2 in mindexers else 0
showDict["tvrage_id"] = helpers.mapIndexersToShow(showObj)[2]
showDict["tvrage_name"] = showObj.name
showDict["network"] = showObj.network
if not showDict["network"]:
@ -2521,7 +2519,6 @@ class CMD_Shows(ApiCall):
if self.paused != None and bool(self.paused) != bool(curShow.paused):
continue
mindexers = helpers.mapIndexersToShow(curShow)
showDict = {
"paused": curShow.paused,
"quality": _get_quality_string(curShow.quality),
@ -2530,8 +2527,8 @@ class CMD_Shows(ApiCall):
"sports": curShow.sports,
"anime": curShow.anime,
"indexerid": curShow.indexerid,
"tvdbid": mindexers[1] if 1 in mindexers else 0,
"tvrage_id": mindexers[2] if 2 in mindexers else 0,
"tvdbid": helpers.mapIndexersToShow(curShow)[1],
"tvrage_id": helpers.mapIndexersToShow(curShow)[2],
"tvrage_name": curShow.name,
"network": curShow.network,
"show_name": curShow.name,