Improved caching results code, helps with daily searches.

This commit is contained in:
echel0n 2014-05-14 22:55:39 -07:00
parent e20adcfab8
commit 1fcfa4c70a
4 changed files with 25 additions and 3 deletions

View file

@ -87,7 +87,7 @@ class DailySearcher():
def searchForNeededEpisodes(self): def searchForNeededEpisodes(self):
logger.log(u"Searching all providers for any needed episodes") logger.log(u"Searching ESS Cache for any needed new episodes")
foundResults = {} foundResults = {}

View file

@ -20,7 +20,7 @@ import sickbeard
from sickbeard import db from sickbeard import db
from sickbeard.helpers import sanitizeSceneName from sickbeard.helpers import sanitizeSceneName
from sickbeard import logger
def addNameToCache(name, indexer_id=0): def addNameToCache(name, indexer_id=0):
""" """
@ -59,6 +59,16 @@ def retrieveShowFromCache(name):
if indexerid: if indexerid:
return sickbeard.helpers.findCertainShow(sickbeard.showList, int(indexerid)) return sickbeard.helpers.findCertainShow(sickbeard.showList, int(indexerid))
def syncNameCache():
cacheDB = db.DBConnection('cache.db')
for curShow in sickbeard.showList:
for show_name in set(sickbeard.show_name_helpers.allPossibleShowNames(curShow)):
sqlResult = cacheDB.action("DELETE FROM scene_names WHERE name = ? and indexer_id = ?", [show_name, 0])
if sqlResult:
logger.log(u"Removing invalid record for [" + show_name + "] from cache ...")
break
def clearCache(): def clearCache():
""" """
Deletes all "unknown" entries from the cache (names with indexer_id of 0). Deletes all "unknown" entries from the cache (names with indexer_id of 0).

View file

@ -31,8 +31,11 @@ class RSSUpdater():
self.amActive = False self.amActive = False
def run(self): def run(self):
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()] # remove names from cache that link back to active shows that we watch
sickbeard.name_cache.syncNameCache()
# update RSS cache
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]
for provider in providers: for provider in providers:
logger.log(u"Updating RSS cache for provider [" + provider.name + "]") logger.log(u"Updating RSS cache for provider [" + provider.name + "]")
provider.cache.updateCache() provider.cache.updateCache()

View file

@ -249,18 +249,27 @@ class TVCache():
if cacheResult: if cacheResult:
in_cache = True in_cache = True
indexerid = int(cacheResult) indexerid = int(cacheResult)
elif cacheResult == 0:
return None
if not indexerid: if not indexerid:
showResult = helpers.searchDBForShow(parse_result.series_name) showResult = helpers.searchDBForShow(parse_result.series_name)
if showResult: if showResult:
indexerid = int(showResult[0]) indexerid = int(showResult[0])
if not indexerid:
for curShow in sickbeard.showList:
if show_name_helpers.isGoodResult(name, curShow, False):
indexerid = curShow.indexerid
break
showObj = None showObj = None
if indexerid: if indexerid:
showObj = helpers.findCertainShow(sickbeard.showList, indexerid) showObj = helpers.findCertainShow(sickbeard.showList, indexerid)
if not showObj: if not showObj:
logger.log(u"No match for show: [" + parse_result.series_name + "], not caching ...", logger.DEBUG) logger.log(u"No match for show: [" + parse_result.series_name + "], not caching ...", logger.DEBUG)
sickbeard.name_cache.addNameToCache(parse_result.series_name, 0)
return None return None
season = episodes = None season = episodes = None