1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05: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)
if showObj:
return showObj
if not showObj and sickbeard.showList:
showNames = list(set(sickbeard.show_name_helpers.sceneToNormalShowNames(name)))
for showName in showNames:
if showName in sickbeard.scene_exceptions.exceptionIndexerCache:
showObj = findCertainShow(sickbeard.showList, int(sickbeard.scene_exceptions.exceptionIndexerCache[showName]))
if showObj:
break
if name in sickbeard.scene_exceptions.exceptionIndexerCache:
showObj = findCertainShow(sickbeard.showList, int(sickbeard.scene_exceptions.exceptionIndexerCache[name]))
if useIndexer and not showObj:
(sn, idx, id) = searchIndexerForShowID(showName, ui=classes.ShowListUI)
if id:
showObj = findCertainShow(sickbeard.showList, int(id))
if showObj:
break
if useIndexer and not showObj:
(sn, idx, id) = searchIndexerForShowID(name, ui=classes.ShowListUI)
if id:
showObj = findCertainShow(sickbeard.showList, int(id))
# add show to cache
if showObj:

View File

@ -125,12 +125,11 @@ def retrieve_exceptions():
scene_exceptions table in cache.db. Also clears the scene name cache.
"""
global exceptionCache, exceptionSeasonCache, exceptionIndexerCache
global exceptionCache, exceptionSeasonCache
exception_dict = {}
exceptionCache = {}
exceptionSeasonCache = {}
exceptionIndexerCache = {}
# exceptions are stored on github pages
for indexer in sickbeard.indexerApi().indexers:
@ -192,9 +191,6 @@ def retrieve_exceptions():
for cur_exception_dict in exception_dict[cur_indexer_id]:
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 cur_exception not in existing_exceptions:
myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?)",
@ -208,6 +204,9 @@ def retrieve_exceptions():
else:
logger.log(u"No scene exceptions update needed")
# build indexer scene name cache
buildIndexerCache()
def update_scene_exceptions(indexer_id, scene_exceptions):
"""
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")
seasons = myDB.select("SELECT DISTINCT season FROM scene_exceptions WHERE indexer_id = ?", [indexer_id])
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)