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,]): if not all([name,]):
return show, show_id return show, show_id
def cache_lookup(name): def cache_lookup(show_name):
return return
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:
show_id = int(lookup())
if show_id == 0:
continue continue, show_id) try:
if self.validate_show: show_id = int(lookup())
show = findCertainShow(show_id) if show_id == 0:
else: continue
from import TVShow
show = TVShow(1, show_id), show_id)
except Exception: if self.validate_show:
pass show = findCertainShow(show_id)
if show_id is None: from import TVShow
# ignore show name by caching it with a indexerid of 0 show = TVShow(1, show_id), 0) except Exception:
if show_id is None:
# ignore show name by caching it with a indexerid of 0, 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