KoD 1.6.3
- Corretto blocco nella ricerca globale\n- migliorie e fix vari ai canali e al core\n
This commit is contained in:
+6
-6
@@ -86,15 +86,15 @@ def encode(path, _samba=False):
|
||||
@rtype: str
|
||||
@return path encoded in system character set or utf-8 if samba
|
||||
"""
|
||||
# from core.support import dbg;dbg()
|
||||
if not isinstance(path, unicode):
|
||||
path = unicode(path, "utf-8", "ignore")
|
||||
|
||||
if scrapertools.find_single_match(path, r'(^\w+:\/\/)') or _samba and not PY3:
|
||||
path = path.encode("utf-8", "ignore")
|
||||
else:
|
||||
if fs_encoding and not PY3:
|
||||
path = path.encode(fs_encoding, "ignore")
|
||||
if not PY3:
|
||||
if scrapertools.find_single_match(path, r'(^\w+:\/\/)') or _samba:
|
||||
path = path.encode("utf-8", "ignore")
|
||||
else:
|
||||
if fs_encoding:
|
||||
path = path.encode(fs_encoding, "ignore")
|
||||
|
||||
# if PY3 and isinstance(path, bytes):
|
||||
# if fs_encoding:
|
||||
|
||||
@@ -478,3 +478,27 @@ def get_md5(cadena):
|
||||
devuelve = binascii.hexlify(md5.new(cadena).digest())
|
||||
|
||||
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()
|
||||
|
||||
+21
-11
@@ -558,7 +558,7 @@ def scrape(func):
|
||||
|
||||
if anime and inspect.stack()[1][3] not in ['find_episodes']:
|
||||
from platformcode import autorenumber
|
||||
if (function == 'episodios' or item.action == 'episodios'): autorenumber.start(itemlist, item)
|
||||
if function == 'episodios': autorenumber.start(itemlist, item)
|
||||
else: autorenumber.start(itemlist)
|
||||
# if anime and autorenumber.check(item) == False and len(itemlist)>0 and not scrapertools.find_single_match(itemlist[0].title, r'(\d+.\d+)'):
|
||||
# pass
|
||||
@@ -1123,6 +1123,15 @@ def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page=
|
||||
# If the call is direct, leave it blank
|
||||
logger.debug()
|
||||
action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level
|
||||
|
||||
if not data and not patron and not next_page:
|
||||
itemlist.append(
|
||||
item.clone(action = action,
|
||||
title=typo(config.get_localized_string(30992), 'color kod bold'),
|
||||
nextPage=True,
|
||||
thumbnail=thumb()))
|
||||
return itemlist[-1]
|
||||
|
||||
if next_page == '':
|
||||
next_page = scrapertools.find_single_match(data, patron)
|
||||
|
||||
@@ -1133,14 +1142,11 @@ def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page=
|
||||
next_page = next_page.replace('&', '&')
|
||||
logger.debug('NEXT= ', next_page)
|
||||
itemlist.append(
|
||||
item.clone(channel=item.channel,
|
||||
action = action,
|
||||
contentType=item.contentType,
|
||||
title=typo(config.get_localized_string(30992), 'color kod bold'),
|
||||
url=next_page,
|
||||
args=item.args,
|
||||
nextPage=True,
|
||||
thumbnail=thumb()))
|
||||
item.clone(action = action,
|
||||
title=typo(config.get_localized_string(30992), 'color kod bold'),
|
||||
url=next_page,
|
||||
nextPage=True,
|
||||
thumbnail=thumb()))
|
||||
return itemlist[-1]
|
||||
|
||||
def pagination(itemlist, item, page, perpage, function_level=1):
|
||||
@@ -1190,12 +1196,16 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru
|
||||
videoitem.title = findS[0]
|
||||
videoitem.url = findS[1]
|
||||
srv_param = servertools.get_server_parameters(videoitem.server.lower())
|
||||
|
||||
logger.debug(videoitem)
|
||||
if videoitem.video_urls or srv_param.get('active', False):
|
||||
item.title = typo(item.contentTitle.strip(), 'bold') if item.contentType == 'movie' or (config.get_localized_string(30161) in item.title) else item.title
|
||||
|
||||
quality = videoitem.quality if videoitem.quality else item.quality if item.quality else ''
|
||||
videoitem.title = (item.title if item.channel not in ['url'] else '') + (typo(videoitem.title, '_ color kod [] bold') if videoitem.title else "") + (typo(videoitem.quality, '_ color kod []') if videoitem.quality else "")
|
||||
videoitem.title = (item.title if item.channel not in ['url'] else '')\
|
||||
+ (typo(videoitem.title, '_ color kod [] bold') if videoitem.title else "")\
|
||||
+ (typo(videoitem.quality, '_ color kod []') if videoitem.quality else "")\
|
||||
+ (typo(videoitem.contentLanguage, '_ color kod []') if videoitem.contentLanguage else "")\
|
||||
+ (typo(videoitem.extraInfo, '_ color kod []') if videoitem.extraInfo else "")
|
||||
videoitem.plot = typo(videoitem.title, 'bold') + (typo(quality, '_ [] bold') if quality else '')
|
||||
videoitem.channel = item.channel
|
||||
videoitem.fulltitle = item.fulltitle
|
||||
|
||||
+36
-57
@@ -21,9 +21,11 @@ import ast, copy, re, time
|
||||
from core import filetools, httptools, jsontools, scrapertools
|
||||
from core.item import InfoLabels
|
||||
from platformcode import config, logger, platformtools
|
||||
import threading
|
||||
|
||||
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||
lock = threading.Lock()
|
||||
|
||||
# ------------------------------------------------- -------------------------------------------------- --------
|
||||
# Set of functions related to infoLabels.
|
||||
@@ -200,18 +202,22 @@ def set_infoLabels_itemlist(item_list, seekTmdb=False, idioma_busqueda=def_lang,
|
||||
|
||||
if not config.get_setting('tmdb_active') and not forced:
|
||||
return
|
||||
import threading
|
||||
|
||||
# threads_num = config.get_setting("tmdb_threads", default=20)
|
||||
# semaforo = threading.Semaphore(threads_num)
|
||||
lock = threading.Lock()
|
||||
r_list = list()
|
||||
i = 0
|
||||
l_hilo = list()
|
||||
|
||||
def sub_thread(_item, _i, _seekTmdb):
|
||||
# semaforo.acquire()
|
||||
ret = set_infoLabels_item(_item, _seekTmdb, idioma_busqueda, lock)
|
||||
ret = 0
|
||||
try:
|
||||
ret = set_infoLabels_item(_item, _seekTmdb, idioma_busqueda, lock)
|
||||
except:
|
||||
import traceback
|
||||
logger.error(traceback.format_exc(1))
|
||||
if lock and lock.locked():
|
||||
lock.release()
|
||||
# logger.debug(str(ret) + "item: " + _item.tostring())
|
||||
# semaforo.release()
|
||||
r_list.append((_i, _item, ret))
|
||||
@@ -298,16 +304,18 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
if episodio:
|
||||
# Update data
|
||||
__leer_datos(otmdb_global)
|
||||
item.infoLabels['title'] = episodio['episodio_titulo']
|
||||
if episodio['episodio_sinopsis']:
|
||||
if episodio.get('episodio_titulo'):
|
||||
item.infoLabels['title'] = episodio['episodio_titulo']
|
||||
if episodio.get('episodio_sinopsis'):
|
||||
item.infoLabels['plot'] = episodio['episodio_sinopsis']
|
||||
if episodio['episodio_imagen']:
|
||||
if episodio.get('episodio_imagen'):
|
||||
item.infoLabels['poster_path'] = episodio['episodio_imagen']
|
||||
item.thumbnail = item.infoLabels['poster_path']
|
||||
if episodio['episodio_air_date']:
|
||||
if episodio.get('episodio_air_date'):
|
||||
item.infoLabels['aired'] = episodio['episodio_air_date']
|
||||
if episodio['episodio_vote_average']:
|
||||
if episodio.get('episodio_vote_average'):
|
||||
item.infoLabels['rating'] = episodio['episodio_vote_average']
|
||||
if episodio.get('episodio_vote_count'):
|
||||
item.infoLabels['votes'] = episodio['episodio_vote_count']
|
||||
|
||||
# 4l3x87 - fix for overlap infoLabels if there is episode or season
|
||||
@@ -411,51 +419,24 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
__leer_datos(otmdb)
|
||||
return len(item.infoLabels)
|
||||
|
||||
# title might contain - or : --> try to search only second title
|
||||
def splitTitle():
|
||||
if '-' in item.fulltitle:
|
||||
item.infoLabels['tvshowtitle'] = item.fulltitle.split('-')[1]
|
||||
item.infoLabels['title'] = item.infoLabels['tvshowtitle']
|
||||
elif ':' in item.fulltitle:
|
||||
item.infoLabels['tvshowtitle'] = item.fulltitle.split(':')[1]
|
||||
item.infoLabels['title'] = item.infoLabels['tvshowtitle']
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
def unify():
|
||||
new_title = scrapertools.title_unify(item.fulltitle)
|
||||
if new_title != item.fulltitle:
|
||||
item.infoLabels['tvshowtitle'] = scrapertools.title_unify(item.infoLabels['tvshowtitle'])
|
||||
item.infoLabels['title'] = scrapertools.title_unify(item.infoLabels['title'])
|
||||
item.fulltitle = new_title
|
||||
return True
|
||||
# We check what type of content it is...
|
||||
if item.contentType == 'movie':
|
||||
tipo_busqueda = 'movie'
|
||||
elif item.contentType == 'undefined': # don't know
|
||||
def detect():
|
||||
# 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
|
||||
tipo_busqueda = 'multi'
|
||||
else:
|
||||
tipo_busqueda = 'tv'
|
||||
|
||||
ret = search(otmdb_global, tipo_busqueda)
|
||||
if not ret:
|
||||
if splitTitle():
|
||||
if not ret: # try with unified title
|
||||
if unify():
|
||||
ret = search(otmdb_global, tipo_busqueda)
|
||||
return ret
|
||||
# Search in tmdb is deactivated or has not given result
|
||||
@@ -1050,7 +1031,7 @@ class Tmdb(object):
|
||||
# We sort result based on fuzzy match to detect most similar
|
||||
if len(results) > 1:
|
||||
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
|
||||
self.results = results
|
||||
@@ -1065,7 +1046,6 @@ class Tmdb(object):
|
||||
logger.error(msg)
|
||||
return 0
|
||||
|
||||
|
||||
def __discover(self, index_results=0):
|
||||
self.result = ResultDictDefault()
|
||||
results = []
|
||||
@@ -1425,27 +1405,27 @@ class Tmdb(object):
|
||||
if not temporada:
|
||||
# An error has occurred
|
||||
return {}
|
||||
# if capitulo == 9: from core.support import dbg;dbg()
|
||||
|
||||
if len(temporada["episodes"]) == 0:
|
||||
# An error has occurred
|
||||
logger.error("Episode %d of the season %d not found." % (capitulo, numtemporada))
|
||||
return {}
|
||||
|
||||
|
||||
elif len(temporada["episodes"]) < capitulo and temporada["episodes"][-1]['episode_number'] >= capitulo:
|
||||
n = None
|
||||
for i, chapters in enumerate(temporada["episodes"]):
|
||||
if chapters['episode_number'] == capitulo:
|
||||
n = i
|
||||
n = i + 1
|
||||
break
|
||||
if n != None:
|
||||
capitulo = n
|
||||
else:
|
||||
logger.error("Episode %d of the season %d not found." % (capitulo, numtemporada))
|
||||
return {}
|
||||
# else:
|
||||
# logger.error("Episode %d of the season %d not found." % (capitulo, numtemporada))
|
||||
# return {}
|
||||
|
||||
elif len(temporada["episodes"]) < capitulo:
|
||||
logger.error("Episode %d of the season %d not found." % (capitulo, numtemporada))
|
||||
return {}
|
||||
|
||||
ret_dic = dict()
|
||||
# Get data for this season
|
||||
@@ -1465,7 +1445,7 @@ class Tmdb(object):
|
||||
dic_aux = temporada.get('credits', {})
|
||||
ret_dic["temporada_cast"] = dic_aux.get('cast', [])
|
||||
ret_dic["temporada_crew"] = dic_aux.get('crew', [])
|
||||
if capitulo == -1:
|
||||
if capitulo == 0:
|
||||
# If we only look for season data, include the technical team that has intervened in any chapter
|
||||
dic_aux = dict((i['id'], i) for i in ret_dic["temporada_crew"])
|
||||
for e in temporada["episodes"]:
|
||||
@@ -1475,8 +1455,7 @@ class Tmdb(object):
|
||||
ret_dic["temporada_crew"] = list(dic_aux.values())
|
||||
|
||||
# Obtain chapter data if applicable
|
||||
|
||||
if capitulo != -1:
|
||||
if capitulo > 0:
|
||||
episodio = temporada["episodes"][capitulo - 1]
|
||||
ret_dic["episodio_titulo"] = episodio.get("name", )
|
||||
ret_dic["episodio_sinopsis"] = episodio["overview"]
|
||||
|
||||
Reference in New Issue
Block a user