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

Added function to strip accents to encoding functions

parent 89fd3bc5
# 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
- * 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
......
......@@ -20,13 +20,13 @@
from __future__ import unicode_literals
import time
import unicodedata
from datetime import datetime, timedelta
from CodernityDB.database import RecordNotFound
import sickrage
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
......@@ -131,22 +131,8 @@ class NameCache(object):
for curSeason in [-1] + get_scene_seasons(show.indexerid):
for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])):
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
show_names.append(strip_accents(name))
show_names.append(strip_accents(name).replace("'", " "))
for show_name in set(show_names):
self.put(show_name, show.indexerid)
\ No newline at end of file
......@@ -25,6 +25,7 @@ import locale
import os
import sys
import types
import unicodedata
import six
from chardet import detect
......@@ -143,6 +144,21 @@ def to_unicode(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():
_modules = ['io.open',
'os.access',
......
......@@ -21,7 +21,6 @@ from __future__ import unicode_literals
import fnmatch
import os
import re
import unicodedata
from datetime import date
from functools import partial
......@@ -29,6 +28,7 @@ import sickrage
from sickrage.core.common import DOWNLOADED, Quality, SNATCHED, WANTED, \
countryList
from sickrage.core.helpers import sanitizeSceneName
from sickrage.core.helpers.encoding import strip_accents
from sickrage.core.nameparser import InvalidNameException, InvalidShowException, \
NameParser
from sickrage.core.scene_exceptions import get_scene_exceptions
......@@ -318,16 +318,8 @@ def allPossibleShowNames(show, season=-1):
if season in [-1, 1]:
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
show_names.append(strip_accents(show.name))
show_names.append(strip_accents(show.name).replace("'", " "))
if not show.is_anime:
new_show_names = []
......
......@@ -21,7 +21,6 @@ from __future__ import unicode_literals
import os
import re
import time
import unicodedata
from collections import OrderedDict
from threading import Lock
......@@ -30,6 +29,7 @@ from dateutil import parser
import sickrage
from sickrage.core.common import Quality
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.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, \
......@@ -76,16 +76,8 @@ class NameParser(object):
show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(term), 'show')[0].ids['tvdb'])
return (None, show_id1)[show_id1 == show_id2]
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
show_names.append(strip_accents(name))
show_names.append(strip_accents(name).replace("'", " "))
for show_name in set(show_names):
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