TMDB: miglioria riconoscimento
This commit is contained in:
@@ -120,8 +120,8 @@ def peliculas(item):
|
|||||||
item.title += support.typo(item.lang2, '_ [] color kod')
|
item.title += support.typo(item.lang2, '_ [] color kod')
|
||||||
if item.args == 'novita':
|
if item.args == 'novita':
|
||||||
item.title = item.title
|
item.title = item.title
|
||||||
if 'wp-content' in item.thumbnail and not item.infoLabels['year']:
|
# if 'wp-content' in item.thumbnail and not item.infoLabels['year']:
|
||||||
item.infoLabels['year'] = item.thumbnail.split('/')[5]
|
# item.infoLabels['year'] = item.thumbnail.split('/')[5]
|
||||||
return item
|
return item
|
||||||
return locals()
|
return locals()
|
||||||
|
|
||||||
|
|||||||
@@ -478,3 +478,27 @@ def get_md5(cadena):
|
|||||||
devuelve = binascii.hexlify(md5.new(cadena).digest())
|
devuelve = binascii.hexlify(md5.new(cadena).digest())
|
||||||
|
|
||||||
return devuelve
|
return devuelve
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
|||||||
+11
-39
@@ -411,51 +411,24 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
|||||||
__leer_datos(otmdb)
|
__leer_datos(otmdb)
|
||||||
return len(item.infoLabels)
|
return len(item.infoLabels)
|
||||||
|
|
||||||
# title might contain - or : --> try to search only second title
|
def unify():
|
||||||
def splitTitle():
|
new_title = scrapertools.title_unify(item.fulltitle)
|
||||||
if '-' in item.fulltitle:
|
if new_title != item.fulltitle:
|
||||||
item.infoLabels['tvshowtitle'] = item.fulltitle.split('-')[1]
|
item.infoLabels['tvshowtitle'] = scrapertools.title_unify(item.infoLabels['tvshowtitle'])
|
||||||
item.infoLabels['title'] = item.infoLabels['tvshowtitle']
|
item.infoLabels['title'] = scrapertools.title_unify(item.infoLabels['title'])
|
||||||
elif ':' in item.fulltitle:
|
item.fulltitle = new_title
|
||||||
item.infoLabels['tvshowtitle'] = item.fulltitle.split(':')[1]
|
return True
|
||||||
item.infoLabels['title'] = item.infoLabels['tvshowtitle']
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
# We check what type of content it is...
|
# We check what type of content it is...
|
||||||
if item.contentType == 'movie':
|
if item.contentType == 'movie':
|
||||||
tipo_busqueda = 'movie'
|
tipo_busqueda = 'movie'
|
||||||
elif item.contentType == 'undefined': # don't know
|
elif item.contentType == 'undefined': # don't know
|
||||||
def detect():
|
tipo_busqueda = 'multi'
|
||||||
# try movie first
|
|
||||||
results = search(otmdb_global, 'movie')
|
|
||||||
if results:
|
|
||||||
item.contentType = 'movie'
|
|
||||||
infoMovie = item.infoLabels
|
|
||||||
if infoMovie['title'] == item.fulltitle: # exact match -> it's probably correct
|
|
||||||
return results
|
|
||||||
|
|
||||||
# try tvshow then
|
|
||||||
item.infoLabels = {'tvshowtitle': item.infoLabels['tvshowtitle']} # reset infolabels
|
|
||||||
results = search(otmdb_global, 'tv')
|
|
||||||
if results:
|
|
||||||
item.contentType = 'tvshow'
|
|
||||||
else:
|
|
||||||
item.infoLabels = infoMovie
|
|
||||||
|
|
||||||
return results
|
|
||||||
|
|
||||||
results = detect()
|
|
||||||
if not results:
|
|
||||||
if splitTitle():
|
|
||||||
results = detect()
|
|
||||||
return results
|
|
||||||
else:
|
else:
|
||||||
tipo_busqueda = 'tv'
|
tipo_busqueda = 'tv'
|
||||||
|
|
||||||
ret = search(otmdb_global, tipo_busqueda)
|
ret = search(otmdb_global, tipo_busqueda)
|
||||||
if not ret:
|
if not ret: # try with unified title
|
||||||
if splitTitle():
|
if unify():
|
||||||
ret = search(otmdb_global, tipo_busqueda)
|
ret = search(otmdb_global, tipo_busqueda)
|
||||||
return ret
|
return ret
|
||||||
# Search in tmdb is deactivated or has not given result
|
# Search in tmdb is deactivated or has not given result
|
||||||
@@ -1028,7 +1001,7 @@ class Tmdb(object):
|
|||||||
# We sort result based on fuzzy match to detect most similar
|
# We sort result based on fuzzy match to detect most similar
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
from lib.fuzzy_match import algorithims
|
from lib.fuzzy_match import algorithims
|
||||||
results.sort(key=lambda r: algorithims.trigram(text_simple, r['title'] if self.busqueda_tipo == 'movie' else r['name']), reverse=True)
|
results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if self.busqueda_tipo == 'tv' else r.get('title', '')), reverse=True)
|
||||||
|
|
||||||
# We return the number of results of this page
|
# We return the number of results of this page
|
||||||
self.results = results
|
self.results = results
|
||||||
@@ -1043,7 +1016,6 @@ class Tmdb(object):
|
|||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def __discover(self, index_results=0):
|
def __discover(self, index_results=0):
|
||||||
self.result = ResultDictDefault()
|
self.result = ResultDictDefault()
|
||||||
results = []
|
results = []
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
if self.item.mode in ['all', 'search']:
|
if self.item.mode in ['all', 'search']:
|
||||||
if self.item.type:
|
if self.item.type:
|
||||||
self.item.mode = 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 = 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_']:
|
||||||
@@ -766,27 +766,3 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
server.window = True
|
server.window = True
|
||||||
server.globalsearch = True
|
server.globalsearch = True
|
||||||
return run(server)
|
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()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user