Title unify su nuova ricerc globale
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import xbmc, xbmcgui, sys, channelselector, time, os
|
import xbmc, xbmcgui, sys, channelselector, time, os
|
||||||
|
from core import support
|
||||||
from core.support import dbg, tmdb
|
from core.support import dbg, tmdb
|
||||||
from core.item import Item
|
from core.item import Item
|
||||||
from core import channeltools, servertools, scrapertools
|
from core import channeltools, servertools, scrapertools
|
||||||
@@ -8,8 +9,12 @@ from platformcode import platformtools, config, logger
|
|||||||
from platformcode.launcher import run
|
from platformcode.launcher import run
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
if sys.version_info[0] >= 3: from concurrent import futures
|
if sys.version_info[0] >= 3:
|
||||||
else: from concurrent_py2 import futures
|
PY3 = True
|
||||||
|
from concurrent import futures
|
||||||
|
else:
|
||||||
|
PY3 = False
|
||||||
|
from concurrent_py2 import futures
|
||||||
|
|
||||||
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||||
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||||
@@ -116,6 +121,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
from specials.search import save_search
|
from specials.search import save_search
|
||||||
save_search(self.item.text)
|
save_search(self.item.text)
|
||||||
|
|
||||||
|
|
||||||
def getActions(self):
|
def getActions(self):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
count = 0
|
count = 0
|
||||||
@@ -453,7 +459,9 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
if self.type:
|
if self.type:
|
||||||
self.type = None
|
self.type = None
|
||||||
if self.item.mode in ['all', 'search']:
|
if self.item.mode in ['all', 'search']:
|
||||||
if self.item.type: self.item.mode = self.item.type
|
if self.item.type:
|
||||||
|
self.item.mode = self.item.type
|
||||||
|
self.item.text = title_unify(self.item.text)
|
||||||
self.thread = Thread(target=self.search)
|
self.thread = Thread(target=self.search)
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
elif self.item.mode in ['movie', 'tvshow', 'person_']:
|
elif self.item.mode in ['movie', 'tvshow', 'person_']:
|
||||||
@@ -746,3 +754,29 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
server.globalsearch = True
|
server.globalsearch = True
|
||||||
return run(server)
|
return run(server)
|
||||||
|
|
||||||
|
|
||||||
|
def title_unify(title):
|
||||||
|
import unicodedata
|
||||||
|
|
||||||
|
u_title = ''
|
||||||
|
sep_count = 0
|
||||||
|
for c in unicodedata.normalize('NFD', title if PY3 else title.decode('utf-8', 'ignore')):
|
||||||
|
cat = unicodedata.category(c)
|
||||||
|
if cat != 'Mn':
|
||||||
|
if cat == 'Pd':
|
||||||
|
c_new = '-'
|
||||||
|
elif cat in ['Ll', 'Lu'] or c in [':']:
|
||||||
|
c_new = c
|
||||||
|
else:
|
||||||
|
c_new = ' '
|
||||||
|
if c_new in ['-', ':']:
|
||||||
|
sep_count += 1
|
||||||
|
|
||||||
|
u_title += c_new
|
||||||
|
if sep_count == 1: # subtitle, split but only if there's one, it might be part of title
|
||||||
|
spl = u_title.replace(':', '-').split('-')
|
||||||
|
if len(spl[0]) > 5:
|
||||||
|
u_title = spl[0]
|
||||||
|
else:
|
||||||
|
u_title = spl[1]
|
||||||
|
return u_title.strip()
|
||||||
Reference in New Issue
Block a user