title unify spostato in support e aggiunto a tmdb
This commit is contained in:
@@ -796,6 +796,30 @@ def menu(func):
|
||||
return wrapper
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
||||
def typo(string, typography=''):
|
||||
|
||||
kod_color = '0xFF65B3DA' #'0xFF0081C2'
|
||||
|
||||
11
core/tmdb.py
11
core/tmdb.py
@@ -243,6 +243,7 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
@rtype: int
|
||||
"""
|
||||
global otmdb_global
|
||||
from core.support import title_unify
|
||||
|
||||
def __leer_datos(otmdb_aux):
|
||||
item.infoLabels = otmdb_aux.get_infoLabels(item.infoLabels)
|
||||
@@ -269,7 +270,7 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
otmdb_global = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo_busqueda,
|
||||
idioma_busqueda=idioma_busqueda)
|
||||
else:
|
||||
otmdb_global = Tmdb(texto_buscado=item.infoLabels['tvshowtitle'], tipo=tipo_busqueda,
|
||||
otmdb_global = Tmdb(texto_buscado=title_unify(item.infoLabels['tvshowtitle']), tipo=tipo_busqueda,
|
||||
idioma_busqueda=idioma_busqueda, year=item.infoLabels['year'])
|
||||
|
||||
__leer_datos(otmdb_global)
|
||||
@@ -381,7 +382,7 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
# do it by title
|
||||
if tipo_busqueda == 'tv':
|
||||
# Serial search by title and filtering your results if necessary
|
||||
otmdb = Tmdb(texto_buscado=item.infoLabels['tvshowtitle'], tipo=tipo_busqueda,
|
||||
otmdb = Tmdb(texto_buscado=title_unify(item.infoLabels['tvshowtitle']), tipo=tipo_busqueda,
|
||||
idioma_busqueda=idioma_busqueda, filtro=item.infoLabels.get('filtro', {}),
|
||||
year=item.infoLabels['year'])
|
||||
else:
|
||||
@@ -389,7 +390,7 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
# if item.infoLabels['year'] or item.infoLabels['filtro']:
|
||||
# ...and year or filter
|
||||
searched_title = item.contentTitle if item.contentTitle else item.fulltitle
|
||||
otmdb = Tmdb(texto_buscado=searched_title, tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda,
|
||||
otmdb = Tmdb(texto_buscado=title_unify(searched_title), tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda,
|
||||
filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year'])
|
||||
if otmdb is not None:
|
||||
if otmdb.get_id() and config.get_setting("tmdb_plus_info", default=False):
|
||||
@@ -460,7 +461,7 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
|
||||
def find_and_set_infoLabels(item):
|
||||
logger.debug()
|
||||
|
||||
from core.support import title_unify
|
||||
global otmdb_global
|
||||
tmdb_result = None
|
||||
|
||||
@@ -481,7 +482,7 @@ def find_and_set_infoLabels(item):
|
||||
|
||||
if not item.infoLabels.get("tmdb_id") or not item.infoLabels.get("tmdb_id")[0].isdigit():
|
||||
if not item.infoLabels.get("imdb_id"):
|
||||
otmdb_global = Tmdb(texto_buscado=title, tipo=tipo_busqueda, year=item.infoLabels['year'])
|
||||
otmdb_global = Tmdb(texto_buscado=title_unify(title), tipo=tipo_busqueda, year=item.infoLabels['year'])
|
||||
else:
|
||||
otmdb_global = Tmdb(external_id=item.infoLabels.get("imdb_id"), external_source="imdb_id", tipo=tipo_busqueda)
|
||||
elif not otmdb_global or str(otmdb_global.result.get("id")) != item.infoLabels['tmdb_id']:
|
||||
|
||||
@@ -461,7 +461,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 = support.title_unify(self.item.text)
|
||||
if self.item.contentType == 'movie' and self.item.infoLabels['year']:
|
||||
self.item.text += " " + str(self.item.infoLabels['year'])
|
||||
self.thread = Thread(target=self.search)
|
||||
@@ -746,24 +746,4 @@ class SearchWindow(xbmcgui.WindowXML):
|
||||
return run(server)
|
||||
|
||||
|
||||
def title_unify(title):
|
||||
import unicodedata
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user