Commit 9969a0b3 authored by echel0n's avatar echel0n
Browse files

Added function to strip accents to encoding functions

parent 89fd3bc5
# Changelog # Changelog
- * 2620093 - 2018-10-27: Release v9.4.1 - * f1b4113 - 2018-10-28: Added function to strip accents to encoding functions
- * bf93454 - 2018-10-27: Release v9.4.1
- * 3dbd257 - 2018-10-27: Release v9.3.100 - * 3dbd257 - 2018-10-27: Release v9.3.100
- * 479d80e - 2018-10-27: Removed app_id and replaced with app_sub. App now links its self to SSO user via userid instead of appid. SSL cert and key now stored/retrieved from data folder. - * 479d80e - 2018-10-27: Removed app_id and replaced with app_sub. App now links its self to SSO user via userid instead of appid. SSL cert and key now stored/retrieved from data folder.
- * 33ea2f1 - 2018-10-21: Release v9.3.99 - * 33ea2f1 - 2018-10-21: Release v9.3.99
......
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import time import time
import unicodedata
from datetime import datetime, timedelta from datetime import datetime, timedelta
from CodernityDB.database import RecordNotFound from CodernityDB.database import RecordNotFound
import sickrage import sickrage
from sickrage.core.helpers import full_sanitizeSceneName from sickrage.core.helpers import full_sanitizeSceneName
from sickrage.core.helpers.encoding import strip_accents
from sickrage.core.scene_exceptions import retrieve_exceptions, get_scene_seasons, get_scene_exceptions from sickrage.core.scene_exceptions import retrieve_exceptions, get_scene_seasons, get_scene_exceptions
...@@ -131,22 +131,8 @@ class NameCache(object): ...@@ -131,22 +131,8 @@ class NameCache(object):
for curSeason in [-1] + get_scene_seasons(show.indexerid): for curSeason in [-1] + get_scene_seasons(show.indexerid):
for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])): for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])):
show_names.append(name) show_names.append(name)
show_names.append(strip_accents(name))
# strip accents show_names.append(strip_accents(name).replace("'", " "))
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): for show_name in set(show_names):
self.put(show_name, show.indexerid) self.put(show_name, show.indexerid)
\ No newline at end of file
...@@ -25,6 +25,7 @@ import locale ...@@ -25,6 +25,7 @@ import locale
import os import os
import sys import sys
import types import types
import unicodedata
import six import six
from chardet import detect from chardet import detect
...@@ -143,6 +144,21 @@ def to_unicode(var): ...@@ -143,6 +144,21 @@ def to_unicode(var):
return var return var
def strip_accents(name):
try:
# strip accents
try:
name.decode('ascii')
except UnicodeEncodeError:
pass
name = unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore')
except UnicodeDecodeError:
pass
return name
def patch_modules(): def patch_modules():
_modules = ['io.open', _modules = ['io.open',
'os.access', 'os.access',
......
...@@ -21,7 +21,6 @@ from __future__ import unicode_literals ...@@ -21,7 +21,6 @@ from __future__ import unicode_literals
import fnmatch import fnmatch
import os import os
import re import re
import unicodedata
from datetime import date from datetime import date
from functools import partial from functools import partial
...@@ -29,6 +28,7 @@ import sickrage ...@@ -29,6 +28,7 @@ import sickrage
from sickrage.core.common import DOWNLOADED, Quality, SNATCHED, WANTED, \ from sickrage.core.common import DOWNLOADED, Quality, SNATCHED, WANTED, \
countryList countryList
from sickrage.core.helpers import sanitizeSceneName from sickrage.core.helpers import sanitizeSceneName
from sickrage.core.helpers.encoding import strip_accents
from sickrage.core.nameparser import InvalidNameException, InvalidShowException, \ from sickrage.core.nameparser import InvalidNameException, InvalidShowException, \
NameParser NameParser
from sickrage.core.scene_exceptions import get_scene_exceptions from sickrage.core.scene_exceptions import get_scene_exceptions
...@@ -318,16 +318,8 @@ def allPossibleShowNames(show, season=-1): ...@@ -318,16 +318,8 @@ def allPossibleShowNames(show, season=-1):
if season in [-1, 1]: if season in [-1, 1]:
show_names.append(show.name) show_names.append(show.name)
try: show_names.append(strip_accents(show.name))
# strip accents show_names.append(strip_accents(show.name).replace("'", " "))
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: if not show.is_anime:
new_show_names = [] new_show_names = []
......
...@@ -21,7 +21,6 @@ from __future__ import unicode_literals ...@@ -21,7 +21,6 @@ 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
...@@ -30,6 +29,7 @@ from dateutil import parser ...@@ -30,6 +29,7 @@ from dateutil import parser
import sickrage import sickrage
from sickrage.core.common import Quality from sickrage.core.common import Quality
from sickrage.core.helpers import findCertainShow, full_sanitizeSceneName, remove_extension from sickrage.core.helpers import findCertainShow, full_sanitizeSceneName, remove_extension
from sickrage.core.helpers.encoding import strip_accents
from sickrage.core.nameparser import regexes from sickrage.core.nameparser import regexes
from sickrage.core.scene_exceptions import get_scene_exception_by_name from sickrage.core.scene_exceptions import get_scene_exception_by_name
from sickrage.core.scene_numbering import get_absolute_number_from_season_and_episode, get_indexer_absolute_numbering, \ from sickrage.core.scene_numbering import get_absolute_number_from_season_and_episode, get_indexer_absolute_numbering, \
...@@ -76,16 +76,8 @@ class NameParser(object): ...@@ -76,16 +76,8 @@ class NameParser(object):
show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(term), 'show')[0].ids['tvdb']) show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(term), 'show')[0].ids['tvdb'])
return (None, show_id1)[show_id1 == show_id2] return (None, show_id1)[show_id1 == show_id2]
try: show_names.append(strip_accents(name))
# strip accents show_names.append(strip_accents(name).replace("'", " "))
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): for show_name in set(show_names):
lookup_list = [ lookup_list = [
......
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