TMDB: miglioria riconoscimento

This commit is contained in:
mac12m99
2021-04-17 14:15:41 +02:00
parent 7fa8212fed
commit 1e55f25b05
4 changed files with 38 additions and 66 deletions
+1 -25
View File
@@ -485,7 +485,7 @@ class SearchWindow(xbmcgui.WindowXML):
if self.item.mode in ['all', 'search']:
if self.item.type:
self.item.mode = self.item.type
self.item.text = title_unify(self.item.text)
self.item.text = scrapertools.title_unify(self.item.text)
self.thread = Thread(target=self.search)
self.thread.start()
elif self.item.mode in ['movie', 'tvshow', 'person_']:
@@ -766,27 +766,3 @@ class SearchWindow(xbmcgui.WindowXML):
server.window = True
server.globalsearch = True
return run(server)
def title_unify(title):
import unicodedata
u_title = ''
if type(title) == str: title = u'' + title
for c in unicodedata.normalize('NFD', title):
cat = unicodedata.category(c)
if cat != 'Mn':
if cat == 'Pd':
c_new = '-'
elif cat in ['Ll', 'Lu'] or c == ':':
c_new = c
else:
c_new = ' '
u_title += c_new
if (u_title.count(':') + u_title.count('-')) == 1:
# subtitle, split but only if there's one, it might be part of title
spl = u_title.replace(':', '-').split('-')
u_title = spl[0] if len(spl[0]) > 5 else spl[1]
return u_title.strip()