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

Fixed internal indexer scene name cache which resolved issues with searching and snatching.

This commit is contained in:
echel0n 2014-05-26 14:06:54 -07:00
parent c5f933e4c8
commit 4da248ef9b
2 changed files with 25 additions and 18 deletions

View File

@ -1014,21 +1014,14 @@ def get_show_by_name(name, useIndexer=False):
showObj = sickbeard.name_cache.retrieveShowFromCache(name) showObj = sickbeard.name_cache.retrieveShowFromCache(name)
if showObj: if showObj:
return showObj return showObj
if not showObj and sickbeard.showList: if not showObj and sickbeard.showList:
showNames = list(set(sickbeard.show_name_helpers.sceneToNormalShowNames(name))) if name in sickbeard.scene_exceptions.exceptionIndexerCache:
for showName in showNames: showObj = findCertainShow(sickbeard.showList, int(sickbeard.scene_exceptions.exceptionIndexerCache[name]))
if showName in sickbeard.scene_exceptions.exceptionIndexerCache:
showObj = findCertainShow(sickbeard.showList, int(sickbeard.scene_exceptions.exceptionIndexerCache[showName]))
if showObj:
break
if useIndexer and not showObj: if useIndexer and not showObj:
(sn, idx, id) = searchIndexerForShowID(showName, ui=classes.ShowListUI) (sn, idx, id) = searchIndexerForShowID(name, ui=classes.ShowListUI)
if id: if id:
showObj = findCertainShow(sickbeard.showList, int(id)) showObj = findCertainShow(sickbeard.showList, int(id))
if showObj:
break
# add show to cache # add show to cache
if showObj: if showObj:

View File

@ -125,12 +125,11 @@ def retrieve_exceptions():
scene_exceptions table in cache.db. Also clears the scene name cache. scene_exceptions table in cache.db. Also clears the scene name cache.
""" """
global exceptionCache, exceptionSeasonCache, exceptionIndexerCache global exceptionCache, exceptionSeasonCache
exception_dict = {} exception_dict = {}
exceptionCache = {} exceptionCache = {}
exceptionSeasonCache = {} exceptionSeasonCache = {}
exceptionIndexerCache = {}
# exceptions are stored on github pages # exceptions are stored on github pages
for indexer in sickbeard.indexerApi().indexers: for indexer in sickbeard.indexerApi().indexers:
@ -192,9 +191,6 @@ def retrieve_exceptions():
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]
# updating internal scene cache
exceptionIndexerCache[helpers.full_sanitizeSceneName(cur_exception)] = cur_indexer_id
# if this exception isn't already in the DB then add it # if this exception isn't already in the DB then add it
if cur_exception not in existing_exceptions: if cur_exception not in existing_exceptions:
myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?)", myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?)",
@ -208,6 +204,9 @@ def retrieve_exceptions():
else: else:
logger.log(u"No scene exceptions update needed") logger.log(u"No scene exceptions update needed")
# build indexer scene name cache
buildIndexerCache()
def update_scene_exceptions(indexer_id, scene_exceptions): def update_scene_exceptions(indexer_id, scene_exceptions):
""" """
Given a indexer_id, and a list of all show scene exceptions, update the db. Given a indexer_id, and a list of all show scene exceptions, update the db.
@ -267,3 +266,18 @@ def getSceneSeasons(indexer_id):
myDB = db.DBConnection("cache.db") myDB = db.DBConnection("cache.db")
seasons = myDB.select("SELECT DISTINCT season FROM scene_exceptions WHERE indexer_id = ?", [indexer_id]) seasons = myDB.select("SELECT DISTINCT season FROM scene_exceptions WHERE indexer_id = ?", [indexer_id])
return [cur_exception["season"] for cur_exception in seasons] return [cur_exception["season"] for cur_exception in seasons]
def buildIndexerCache():
logger.log(u"Updating internal scene name cache", logger.MESSAGE)
global exceptionIndexerCache
exceptionIndexerCache = {}
for show in sickbeard.showList:
for curSeason in [-1] + sickbeard.scene_exceptions.get_scene_seasons(show.indexerid):
exceptionIndexerCache[helpers.full_sanitizeSceneName(show.name)] = show.indexerid
for name in get_scene_exceptions(show.indexerid, season=curSeason):
exceptionIndexerCache[name] = show.indexerid
exceptionIndexerCache[helpers.full_sanitizeSceneName(name)] = show.indexerid
logger.log(u"Updated internal scene name cache", logger.MESSAGE)
logger.log(u"Internal scene name cache set to: " + str(exceptionIndexerCache), logger.DEBUG)