Commit a24520f4 authored by echel0n's avatar echel0n
Browse files

Added code to strip accents from show names and add as a possible show match

parent 147e412b
# Changelog
- * 4be64d5 - 2018-10-21: Release v9.3.98
- * c4e7cda - 2018-10-21: Added code to strip accents from show names and add as a possible show match
- * e3b3be9 - 2018-10-21: Release v9.3.98
- * d5ec001 - 2018-10-21: Fixed issues with matching shows with parsed results when containing accents
- * 84de9fe - 2018-10-21: Release v9.3.97
- * a5f7b6a - 2018-10-21: Fixed issues with network timezones
......
......@@ -343,9 +343,10 @@ class Core(object):
IntervalTrigger(
hours=self.config.version_updater_freq
),
next_run_time=datetime.datetime.now(),
name=self.version_updater.name,
id=self.version_updater.name
).func()
)
# add network timezones updater job
self.scheduler.add_job(
......@@ -353,9 +354,10 @@ class Core(object):
IntervalTrigger(
days=1
),
next_run_time=datetime.datetime.now(),
name="TZUPDATER",
id="TZUPDATER"
).func()
)
# add show updater job
self.scheduler.add_job(
......
......@@ -20,6 +20,7 @@
from __future__ import unicode_literals
import time
import unicodedata
from datetime import datetime, timedelta
from CodernityDB.database import RecordNotFound
......@@ -125,6 +126,27 @@ class NameCache(object):
self.last_update[show.name] = datetime.fromtimestamp(int(time.mktime(datetime.today().timetuple())))
self.clear(show.indexerid)
show_names = []
for curSeason in [-1] + get_scene_seasons(show.indexerid):
for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])):
self.put(name, show.indexerid)
show_names.append(name)
# strip accents
try:
try:
name.decode('ascii')
except UnicodeEncodeError:
pass
show_names.append(
unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore')
)
show_names.append(
unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore').replace("'", " ")
)
except UnicodeDecodeError:
pass
for show_name in set(show_names):
self.put(show_name, show.indexerid)
\ No newline at end of file
......@@ -21,6 +21,7 @@ from __future__ import unicode_literals
import fnmatch
import os
import re
import unicodedata
from datetime import date
from functools import partial
......@@ -309,19 +310,30 @@ def allPossibleShowNames(show, season=-1):
:rtype: list[unicode]
"""
showNames = get_scene_exceptions(show.indexerid, season=season)[:]
if not showNames: # if we dont have any season specific exceptions fallback to generic exceptions
show_names = get_scene_exceptions(show.indexerid, season=season)[:]
if not show_names: # if we dont have any season specific exceptions fallback to generic exceptions
season = -1
showNames = get_scene_exceptions(show.indexerid, season=season)[:]
show_names = get_scene_exceptions(show.indexerid, season=season)[:]
if season in [-1, 1]:
showNames.append(show.name)
show_names.append(show.name)
try:
# strip accents
try:
show.name.decode('ascii')
except UnicodeEncodeError:
pass
show_names.append(unicodedata.normalize('NFKD', show.name).encode('ASCII', 'ignore'))
show_names.append(unicodedata.normalize('NFKD', show.name).encode('ASCII', 'ignore').replace("'", " "))
except UnicodeDecodeError:
pass
if not show.is_anime:
newShowNames = []
new_show_names = []
country_list = countryList
country_list.update(dict(zip(countryList.values(), countryList.keys())))
for curName in set(showNames):
for curName in set(show_names):
if not curName:
continue
......@@ -330,16 +342,16 @@ def allPossibleShowNames(show, season=-1):
# (and vice versa)
for curCountry in country_list:
if curName.endswith(' ' + curCountry):
newShowNames.append(curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')'))
new_show_names.append(curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')'))
elif curName.endswith(' (' + curCountry + ')'):
newShowNames.append(curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')'))
new_show_names.append(curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')'))
# # if we have "Show Name (2013)" this will strip the (2013) show year from the show name
# newShowNames.append(re.sub('\(\d{4}\)', '', curName))
# new_show_names.append(re.sub('\(\d{4}\)', '', curName))
showNames += newShowNames
show_names += new_show_names
return showNames
return list(set(show_names))
def determineReleaseName(dir_name=None, nzb_name=None):
......
......@@ -60,26 +60,38 @@ class NameParser(object):
def get_show(self, name):
show = None
show_id = None
show_names = [name]
if not all([name, sickrage.app.showlist]):
return show, show_id
def cache_lookup(show_name):
return sickrage.app.name_cache.get(show_name)
def cache_lookup(term):
return sickrage.app.name_cache.get(term)
def scene_exception_lookup(show_name):
return get_scene_exception_by_name(show_name)[0]
def scene_exception_lookup(term):
return get_scene_exception_by_name(term)[0]
def indexer_lookup(show_name):
show_id1 = int(IndexerApi().searchForShowID(full_sanitizeSceneName(show_name))[2])
show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(show_name), 'show')[0].ids['tvdb'])
def indexer_lookup(term):
show_id1 = int(IndexerApi().searchForShowID(full_sanitizeSceneName(term))[2])
show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(term), 'show')[0].ids['tvdb'])
return (None, show_id1)[show_id1 == show_id2]
for x in [unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore'), name]:
try:
# strip accents
try:
name.decode('ascii')
except UnicodeEncodeError:
pass
show_names.append(unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore'))
show_names.append(unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore').replace("'", " "))
except UnicodeDecodeError:
pass
for show_name in set(show_names):
lookup_list = [
lambda: cache_lookup(x),
lambda: scene_exception_lookup(x),
lambda: indexer_lookup(x),
lambda: cache_lookup(show_name),
lambda: scene_exception_lookup(show_name),
lambda: indexer_lookup(show_name),
]
# lookup show id
......@@ -92,7 +104,7 @@ class NameParser(object):
if show_id == 0:
continue
sickrage.app.name_cache.put(x, show_id)
sickrage.app.name_cache.put(show_name, show_id)
if self.validate_show:
show = findCertainShow(show_id)
else:
......@@ -103,7 +115,7 @@ class NameParser(object):
if show_id is None:
# ignore show name by caching it with a indexerid of 0
sickrage.app.name_cache.put(x, 0)
sickrage.app.name_cache.put(show_name, 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