Added back in name cache but force it to only store entries if they have a valid Indexer ID otherwise disgard them.

This commit is contained in:
echel0n 2014-04-30 07:02:47 -07:00
parent 9384881241
commit 3f8729ef83
2 changed files with 11 additions and 12 deletions

View File

@ -28,14 +28,11 @@ def addNameToCache(name, indexer_id):
indexer_id: the TVDB and TVRAGE id that this show should be cached with (can be None/0 for unknown)
"""
# standardize the name we're using to account for small differences in providers
name = sanitizeSceneName(name)
if not indexer_id:
indexer_id = 0
cacheDB = db.DBConnection('cache.db')
cacheDB.action("INSERT INTO scene_names (indexer_id, name) VALUES (?, ?)", [indexer_id, name])
if indexer_id:
# standardize the name we're using to account for small differences in providers
name = sanitizeSceneName(name)
cacheDB = db.DBConnection('cache.db')
cacheDB.action("INSERT INTO scene_names (indexer_id, name) VALUES (?, ?)", [indexer_id, name])
def retrieveNameFromCache(name):
@ -53,10 +50,8 @@ def retrieveNameFromCache(name):
cacheDB = db.DBConnection('cache.db')
cache_results = cacheDB.select("SELECT * FROM scene_names WHERE name = ?", [name])
if not cache_results:
return None
return int(cache_results[0]["indexer_id"])
if cache_results:
return int(cache_results[0]["indexer_id"])
def clearCache():

View File

@ -242,6 +242,10 @@ class TVCache():
# if we didn't find a Indexer ID return None
if indexer_id:
# add to name cache if we didn't get it from the cache
if not from_cache:
name_cache.addNameToCache(parse_result.series_name, indexer_id)
# if the show isn't in out database then return None
try:
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)