tmdb: Ottimizzazione nella ricerca globale, no cache in sezione discover

This commit is contained in:
marco
2020-10-12 18:02:04 +02:00
parent f8a87542eb
commit 0b5c0cd617
3 changed files with 36 additions and 32 deletions
+3 -2
View File
@@ -491,6 +491,9 @@ def scrape(func):
else:
break
if action != 'play' and function != 'episodios' and 'patronMenu' not in args and item.contentType in ['movie', 'tvshow', 'episode', 'undefined'] and not disabletmdb:
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
if (pagination and len(matches) <= pag * pagination) or not pagination: # next page with pagination
if patronNext and inspect.stack()[1][3] not in ['newest']:
nextPage(itemlist, item, data, patronNext, function)
@@ -509,8 +512,6 @@ def scrape(func):
args=item.args,
page=pag + 1,
thumbnail=thumb()))
if action != 'play' and function != 'episodios' and 'patronMenu' not in args and item.contentType in ['movie', 'tvshow', 'episode', 'undefined'] and not disabletmdb:
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
if anime:
from platformcode import autorenumber
+5 -5
View File
@@ -92,7 +92,7 @@ def cache_response(fn):
# import time
# start_time = time.time()
def wrapper(*args):
def wrapper(*args, **kwargs):
import base64
def check_expired(ts):
@@ -143,7 +143,8 @@ def cache_response(fn):
try:
# cache is not active
if not config.get_setting("tmdb_cache", default=False):
if not config.get_setting("tmdb_cache", default=False) or not kwargs.get('cache', True):
logger.debug('no cache')
result = fn(*args)
else:
@@ -861,8 +862,7 @@ class Tmdb(object):
@staticmethod
@cache_response
def get_json(url):
def get_json(url, cache=True):
try:
result = httptools.downloadpage(url, cookies=False, ignore_response_code=True)
@@ -1045,7 +1045,7 @@ class Tmdb(object):
% (type_search, "&".join(params)))
logger.info("[Tmdb.py] Searcing %s:\n%s" % (type_search, url))
resultado = self.get_json(url)
resultado = self.get_json(url, cache=False)
if not isinstance(resultado, dict):
resultado = ast.literal_eval(resultado.decode('utf-8'))
+28 -25
View File
@@ -235,6 +235,8 @@ def channel_search(item):
if channel not in ch_list:
ch_list[channel] = []
ch_list[channel].extend(res.result()[1])
if res.result()[2]:
valid.extend(res.result()[2])
if progress.iscanceled():
break
@@ -261,21 +263,7 @@ def channel_search(item):
ch_name = channel_titles[channel_list.index(key)]
grouped = list()
cnt += 1
progress.update(old_div((cnt * 100), len(ch_list)), config.get_localized_string(60295) + '\n' + config.get_localized_string(60293))
if item.mode != 'all':
if len(value) == 1:
if not value[0].action or config.get_localized_string(70006).lower() in value[0].title.lower():
continue
for elem in value:
if not elem.infoLabels.get('year', ""):
elem.infoLabels['year'] = '-'
tmdb.set_infoLabels_itemlist(value, True, forced=True)
for elem in value:
if elem.infoLabels['tmdb_id'] == searched_id:
elem.from_channel = key
if not config.get_setting('unify'):
elem.title += ' [%s]' % key
valid.append(elem)
progress.update(old_div((cnt * 100), len(ch_list)), config.get_localized_string(60295))
for it in value:
if it.channel == item.channel:
@@ -355,24 +343,39 @@ def channel_search(item):
def get_channel_results(item, module_dict, search_action):
ch = search_action.channel
max_results = 10
results = list()
valid = list()
module = module_dict[ch]
searched_id = item.infoLabels['tmdb_id']
try:
results.extend(module.search(search_action, item.text))
if len(results) == 1:
if not results[0].action or config.get_localized_string(70006).lower() in results[0].title.lower():
results.clear()
elif item.mode != 'all':
for elem in results:
if not elem.infoLabels.get('year', ""):
elem.infoLabels['year'] = '-'
tmdb.set_infoLabels_item(elem)
if elem.infoLabels['tmdb_id'] == searched_id:
elem.from_channel = ch
if not config.get_setting('unify'):
elem.title += ' [%s]' % ch
valid.append(elem)
break
if len(results) < 0 and len(results) < max_results and item.mode != 'all':
# if len(results) < 0 and len(results) < max_results and item.mode != 'all':
#
# if len(results) == 1:
# if not results[0].action or config.get_localized_string(30992).lower() in results[0].title.lower():
# return [ch, []]
#
# results = get_info(results)
if len(results) == 1:
if not results[0].action or config.get_localized_string(30992).lower() in results[0].title.lower():
return [ch, []]
results = get_info(results)
return [search_action, results]
return [search_action, results, valid]
except:
return [search_action, results]
return [search_action, results, valid]
def get_servers(item, module_dict):