mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05: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:
parent
281c5c333e
commit
b8b5947ae6
@ -1139,7 +1139,11 @@ def extractZip(archive, targetDir):
|
|||||||
|
|
||||||
|
|
||||||
def mapIndexersToShow(showObj):
|
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()
|
myDB = db.DBConnection()
|
||||||
sqlResults = myDB.select(
|
sqlResults = myDB.select(
|
||||||
|
@ -98,9 +98,9 @@ class NewznabProvider(generic.NZBProvider):
|
|||||||
cur_params['season'] = str(ep_obj.scene_season)
|
cur_params['season'] = str(ep_obj.scene_season)
|
||||||
|
|
||||||
# search
|
# search
|
||||||
mindexers = helpers.mapIndexersToShow(ep_obj.show)
|
rid = helpers.mapIndexersToShow(ep_obj.show)[2]
|
||||||
if 2 in mindexers:
|
if rid:
|
||||||
cur_params['rid'] = mindexers[2]
|
cur_params['rid'] = rid
|
||||||
to_return.append(cur_params)
|
to_return.append(cur_params)
|
||||||
else:
|
else:
|
||||||
# add new query strings for exceptions
|
# add new query strings for exceptions
|
||||||
@ -131,9 +131,9 @@ class NewznabProvider(generic.NZBProvider):
|
|||||||
params['ep'] = ep_obj.scene_episode
|
params['ep'] = ep_obj.scene_episode
|
||||||
|
|
||||||
# search
|
# search
|
||||||
mindexers = helpers.mapIndexersToShow(ep_obj.show)
|
rid = helpers.mapIndexersToShow(ep_obj.show)[2]
|
||||||
if 2 in mindexers:
|
if rid:
|
||||||
params['rid'] = mindexers[2]
|
params['rid'] = rid
|
||||||
to_return.append(params)
|
to_return.append(params)
|
||||||
else:
|
else:
|
||||||
# add new query strings for exceptions
|
# add new query strings for exceptions
|
||||||
|
@ -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)
|
return filter(lambda x: int(indexerid) in [int(x['tvdb_id']) or 0, int(x['tvrage_id'])] or 0, library)
|
||||||
|
|
||||||
def syncLibrary(self):
|
def syncLibrary(self):
|
||||||
logger.log(u"Syncing library to Trakt.tv show library", logger.DEBUG)
|
logger.log(u"Syncing Trakt.tv show library", logger.DEBUG)
|
||||||
if sickbeard.showList:
|
|
||||||
for myShow in sickbeard.showList:
|
for myShow in sickbeard.showList:
|
||||||
self.addShowToTraktLibrary(myShow)
|
self.addShowToTraktLibrary(myShow)
|
||||||
|
|
||||||
def removeShowFromTraktLibrary(self, show_obj):
|
def removeShowFromTraktLibrary(self, show_obj):
|
||||||
|
data = {}
|
||||||
if self.findShow(show_obj.indexer, show_obj.indexerid):
|
if self.findShow(show_obj.indexer, show_obj.indexerid):
|
||||||
# URL parameters
|
# URL parameters
|
||||||
data = {}
|
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
|
||||||
if show_obj.indexer == 1:
|
data['title'] = show_obj.name
|
||||||
data['tvdb_id'] = show_obj.indexerid
|
data['year'] = show_obj.startyear
|
||||||
data['title'] = show_obj.name
|
|
||||||
data['year'] = show_obj.startyear
|
|
||||||
|
|
||||||
elif show_obj.indexer == 2:
|
if len(data):
|
||||||
data['tvrage_id'] = show_obj.indexerid
|
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
|
||||||
data['title'] = show_obj.name
|
TraktCall("show/unlibrary/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
|
||||||
data['year'] = show_obj.startyear
|
data)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
def addShowToTraktLibrary(self, show_obj):
|
def addShowToTraktLibrary(self, show_obj):
|
||||||
"""
|
"""
|
||||||
@ -91,23 +85,18 @@ class TraktChecker():
|
|||||||
show_obj: The TVShow object to add to trakt
|
show_obj: The TVShow object to add to trakt
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
|
||||||
if not self.findShow(show_obj.indexer, show_obj.indexerid):
|
if not self.findShow(show_obj.indexer, show_obj.indexerid):
|
||||||
# URL parameters
|
# URL parameters
|
||||||
data = {}
|
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
|
||||||
if show_obj.indexer == 1:
|
data['title'] = show_obj.name
|
||||||
data['tvdb_id'] = show_obj.indexerid
|
data['year'] = show_obj.startyear
|
||||||
data['title'] = show_obj.name
|
|
||||||
data['year'] = show_obj.startyear
|
|
||||||
|
|
||||||
elif show_obj.indexer == 2:
|
if len(data):
|
||||||
data['tvrage_id'] = show_obj.indexerid
|
logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG)
|
||||||
data['title'] = show_obj.name
|
TraktCall("show/library/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
|
||||||
data['year'] = show_obj.startyear
|
data)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
def updateShows(self):
|
def updateShows(self):
|
||||||
logger.log(u"Starting trakt show watchlist check", logger.DEBUG)
|
logger.log(u"Starting trakt show watchlist check", logger.DEBUG)
|
||||||
|
@ -1720,8 +1720,6 @@ class CMD_Show(ApiCall):
|
|||||||
if not showObj:
|
if not showObj:
|
||||||
return _responds(RESULT_FAILURE, msg="Show not found")
|
return _responds(RESULT_FAILURE, msg="Show not found")
|
||||||
|
|
||||||
mindexers = helpers.mapIndexersToShow(showObj)
|
|
||||||
|
|
||||||
showDict = {}
|
showDict = {}
|
||||||
showDict["season_list"] = CMD_ShowSeasonList(self.handler, (), {"indexerid": self.indexerid}).run()["data"]
|
showDict["season_list"] = CMD_ShowSeasonList(self.handler, (), {"indexerid": self.indexerid}).run()["data"]
|
||||||
showDict["cache"] = CMD_ShowCache(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
|
showDict["anime"] = showObj.anime
|
||||||
#clean up tvdb horrible airs field
|
#clean up tvdb horrible airs field
|
||||||
showDict["airs"] = str(showObj.airs).replace('am', ' AM').replace('pm', ' PM').replace(' ', ' ')
|
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["tvrage_name"] = showObj.name
|
||||||
showDict["network"] = showObj.network
|
showDict["network"] = showObj.network
|
||||||
if not showDict["network"]:
|
if not showDict["network"]:
|
||||||
@ -2521,7 +2519,6 @@ class CMD_Shows(ApiCall):
|
|||||||
if self.paused != None and bool(self.paused) != bool(curShow.paused):
|
if self.paused != None and bool(self.paused) != bool(curShow.paused):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
mindexers = helpers.mapIndexersToShow(curShow)
|
|
||||||
showDict = {
|
showDict = {
|
||||||
"paused": curShow.paused,
|
"paused": curShow.paused,
|
||||||
"quality": _get_quality_string(curShow.quality),
|
"quality": _get_quality_string(curShow.quality),
|
||||||
@ -2530,8 +2527,8 @@ class CMD_Shows(ApiCall):
|
|||||||
"sports": curShow.sports,
|
"sports": curShow.sports,
|
||||||
"anime": curShow.anime,
|
"anime": curShow.anime,
|
||||||
"indexerid": curShow.indexerid,
|
"indexerid": curShow.indexerid,
|
||||||
"tvdbid": mindexers[1] if 1 in mindexers else 0,
|
"tvdbid": helpers.mapIndexersToShow(curShow)[1],
|
||||||
"tvrage_id": mindexers[2] if 2 in mindexers else 0,
|
"tvrage_id": helpers.mapIndexersToShow(curShow)[2],
|
||||||
"tvrage_name": curShow.name,
|
"tvrage_name": curShow.name,
|
||||||
"network": curShow.network,
|
"network": curShow.network,
|
||||||
"show_name": curShow.name,
|
"show_name": curShow.name,
|
||||||
|
Loading…
Reference in New Issue
Block a user