Commit 34d3b93c authored by echel0n's avatar echel0n
Browse files

Added code to name cache to allow adding show names we wish to ignore, helps...

Added code to name cache to allow adding show names we wish to ignore, helps speed up name parsing and searches
parent b922499a
# Changelog
- * 3d58a74 - 2017-12-12: Py3 compat for queue
- * 14048db - 2017-12-13: Added code to name cache to allow adding show names we wish to ignore, helps speed up name parsing and searches
- * b922499 - 2017-12-12: Py3 compat for queue
- * 2c6c207 - 2017-12-11: Fixed issue with thread naming for post-processing
- * 5c4b822 - 2017-12-11: refactored remaining GET database calls
- * c07404b - 2017-12-11: Fixed issues with SkyTorrents
......
......@@ -51,25 +51,25 @@ class NameCache(object):
# standardize the name we're using to account for small differences in providers
name = full_sanitizeSceneName(name)
if name not in self.cache:
self.cache[name] = int(indexer_id)
try:
if not len([x for x in sickrage.app.cache_db.get_many('scene_names', name)
if x['indexer_id'] == indexer_id]):
# insert name into cache
sickrage.app.cache_db.insert({
'_t': 'scene_names',
'indexer_id': indexer_id,
'name': name
})
except RecordNotFound:
self.cache[name] = int(indexer_id)
try:
if not len([x for x in sickrage.app.cache_db.get_many('scene_names', name)
if x['indexer_id'] == indexer_id]):
# insert name into cache
sickrage.app.cache_db.insert({
'_t': 'scene_names',
'indexer_id': indexer_id,
'name': name
})
except RecordNotFound:
# insert name into cache
sickrage.app.cache_db.insert({
'_t': 'scene_names',
'indexer_id': indexer_id,
'name': name
})
def get(self, name):
"""
......@@ -82,15 +82,15 @@ class NameCache(object):
if name in self.cache:
return int(self.cache[name])
def clear(self, indexerid=0):
def clear(self, indexerid):
"""
Deletes all "unknown" entries from the cache (names with indexer_id of 0).
Deletes all entries from the cache matching the indexerid.
"""
[sickrage.app.cache_db.delete(x) for x in
sickrage.app.cache_db.all('scene_names')
if x['indexer_id'] in [indexerid, 0]]
if x['indexer_id'] == indexerid]
for item in [self.cache[key] for key, value in self.cache.items() if value == 0 or value == indexerid]:
for item in [self.cache[key] for key, value in self.cache.items() if value == indexerid]:
del item
def load(self):
......
......@@ -58,7 +58,7 @@ class NameParser(object):
def get_show(self, name):
show = None
show_id = 0
show_id = None
if not all([name, sickrage.app.showlist]):
return show, show_id
......@@ -82,19 +82,24 @@ class NameParser(object):
# lookup show id
for lookup in lookup_list:
if show:
if show or show_id is not None:
continue
try:
from sickrage.core.tv.show import TVShow
show_id = int(lookup())
sickrage.app.name_cache.put(name, show_id)
if self.validate_show:
show = findCertainShow(int(lookup()))
show = findCertainShow(show_id)
else:
show = TVShow(1, int(lookup()))
sickrage.app.name_cache.put(name, show.indexerid)
from sickrage.core.tv.show import TVShow
show = TVShow(1, show_id)
except Exception:
pass
if show_id is None:
# ignore show name by caching it with a indexerid of 0
sickrage.app.name_cache.put(name, 0)
return show, show_id or 0
@staticmethod
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment