Commit d5ec0014 authored by echel0n's avatar echel0n
Browse files

Fixed issues with matching shows with parsed results when containing accents

parent d4214c53
...@@ -21,6 +21,7 @@ from __future__ import unicode_literals ...@@ -21,6 +21,7 @@ from __future__ import unicode_literals
import os import os
import re import re
import time import time
import unicodedata
from collections import OrderedDict from collections import OrderedDict
from threading import Lock from threading import Lock
...@@ -63,45 +64,46 @@ class NameParser(object): ...@@ -63,45 +64,46 @@ class NameParser(object):
if not all([name, sickrage.app.showlist]): if not all([name, sickrage.app.showlist]):
return show, show_id return show, show_id
def cache_lookup(name): def cache_lookup(show_name):
return sickrage.app.name_cache.get(name) return sickrage.app.name_cache.get(show_name)
def scene_exception_lookup(name): def scene_exception_lookup(show_name):
return get_scene_exception_by_name(name)[0] return get_scene_exception_by_name(show_name)[0]
def indexer_lookup(name): def indexer_lookup(show_name):
show_id1 = int(IndexerApi().searchForShowID(full_sanitizeSceneName(name))[2]) show_id1 = int(IndexerApi().searchForShowID(full_sanitizeSceneName(show_name))[2])
show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(name), 'show')[0].ids['tvdb']) show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(show_name), 'show')[0].ids['tvdb'])
return (None, show_id1)[show_id1 == show_id2] return (None, show_id1)[show_id1 == show_id2]
lookup_list = [ for x in [unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore'), name]:
lambda: cache_lookup(name), lookup_list = [
lambda: scene_exception_lookup(name), lambda: cache_lookup(x),
lambda: indexer_lookup(name), lambda: scene_exception_lookup(x),
] lambda: indexer_lookup(x),
]
# lookup show id # lookup show id
for lookup in lookup_list: for lookup in lookup_list:
if show or show_id is not None: if show or show_id is not None:
continue
try:
show_id = int(lookup())
if show_id == 0:
continue continue
sickrage.app.name_cache.put(name, show_id) try:
if self.validate_show: show_id = int(lookup())
show = findCertainShow(show_id) if show_id == 0:
else: continue
from sickrage.core.tv.show import TVShow
show = TVShow(1, show_id) sickrage.app.name_cache.put(x, show_id)
except Exception: if self.validate_show:
pass show = findCertainShow(show_id)
else:
if show_id is None: from sickrage.core.tv.show import TVShow
# ignore show name by caching it with a indexerid of 0 show = TVShow(1, show_id)
sickrage.app.name_cache.put(name, 0) except Exception:
pass
if show_id is None:
# ignore show name by caching it with a indexerid of 0
sickrage.app.name_cache.put(x, 0)
return show, show_id or 0 return show, show_id or 0
......
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