fix ricerca globale
This commit is contained in:
@@ -588,6 +588,7 @@ def do_search(item, categories=None):
|
|||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
item.page = 0
|
||||||
progreso.close()
|
progreso.close()
|
||||||
if multithread:
|
if multithread:
|
||||||
Thread(target=search_progress, args=[threads]).start()
|
Thread(target=search_progress, args=[threads]).start()
|
||||||
@@ -640,27 +641,36 @@ def search_wait_page():
|
|||||||
|
|
||||||
def show_list(item, itemlist, categories, result_mode, tecleado, start_time=None):
|
def show_list(item, itemlist, categories, result_mode, tecleado, start_time=None):
|
||||||
search_wait_page()
|
search_wait_page()
|
||||||
|
page = item.page
|
||||||
total = 0
|
total = 0
|
||||||
search_results = {}
|
search_results = {}
|
||||||
for f in os.listdir(res_dir)[:res_per_page]:
|
pageDir = os.path.join(res_dir, 'page' + str(page))
|
||||||
if f == 'done':
|
oldPage = False
|
||||||
continue
|
if os.path.exists(pageDir): # this is an already viewed page
|
||||||
f = os.path.join(res_dir, f)
|
new = os.listdir(pageDir)
|
||||||
if os.path.isfile(f):
|
oldPage = True
|
||||||
with open(f, 'rb') as file:
|
else:
|
||||||
channel_results = cPickle.load(file)
|
os.makedirs(pageDir)
|
||||||
# [channel_parameters, {"item: item1, "result": result1}, {"item: item2, "result": result2}, ..]
|
new = [f for f in os.listdir(res_dir) if not 'page' in f and f not in ('writing', 'done')]
|
||||||
os.remove(f)
|
|
||||||
channel_parameters = channel_results[0]
|
for f in new[:res_per_page]:
|
||||||
search_results[channel_parameters['title']] = []
|
f = os.path.join(pageDir if oldPage else res_dir, f)
|
||||||
for el in channel_results[1:]:
|
|
||||||
item = el["item"]
|
with open(f, 'rb') as file:
|
||||||
result = el["result"]
|
channel_results = cPickle.load(file)
|
||||||
search_results[channel_parameters['title']].append({"item": item,
|
# [channel_parameters, {"item: item1, "result": result1}, {"item: item2, "result": result2}, ..]
|
||||||
"itemlist": result,
|
# os.remove(f)
|
||||||
"thumbnail": channel_parameters["thumbnail"],
|
if not oldPage:
|
||||||
"adult": channel_parameters["adult"]})
|
shutil.move(f, pageDir)
|
||||||
|
channel_parameters = channel_results[0]
|
||||||
|
search_results[channel_parameters['title']] = []
|
||||||
|
for el in channel_results[1:]:
|
||||||
|
item = el["item"]
|
||||||
|
result = el["result"]
|
||||||
|
search_results[channel_parameters['title']].append({"item": item,
|
||||||
|
"itemlist": result,
|
||||||
|
"thumbnail": channel_parameters["thumbnail"],
|
||||||
|
"adult": channel_parameters["adult"]})
|
||||||
|
|
||||||
for channel in sorted(search_results.keys()):
|
for channel in sorted(search_results.keys()):
|
||||||
for element in search_results[channel]:
|
for element in search_results[channel]:
|
||||||
@@ -677,7 +687,8 @@ def show_list(item, itemlist, categories, result_mode, tecleado, start_time=None
|
|||||||
title = re.sub("\[/COLOR]", "", title)
|
title = re.sub("\[/COLOR]", "", title)
|
||||||
plot = config.get_localized_string(60491) + '\n'
|
plot = config.get_localized_string(60491) + '\n'
|
||||||
for i in element["itemlist"]:
|
for i in element["itemlist"]:
|
||||||
plot += i.title + '\n'
|
if type(i) == Item:
|
||||||
|
plot += i.title + '\n'
|
||||||
itemlist.append(Item(title=title, channel="search", action="show_result", url=element["item"].url,
|
itemlist.append(Item(title=title, channel="search", action="show_result", url=element["item"].url,
|
||||||
extra=element["item"].extra, folder=True, adult=element["adult"],
|
extra=element["item"].extra, folder=True, adult=element["adult"],
|
||||||
thumbnail=element["thumbnail"], contentPlot=plot,
|
thumbnail=element["thumbnail"], contentPlot=plot,
|
||||||
@@ -697,11 +708,20 @@ def show_list(item, itemlist, categories, result_mode, tecleado, start_time=None
|
|||||||
title = config.get_localized_string(59972) % (
|
title = config.get_localized_string(59972) % (
|
||||||
tecleado, total, time.time() - start_time)
|
tecleado, total, time.time() - start_time)
|
||||||
itemlist.insert(0, Item(title=typo(title, 'bold color kod')))
|
itemlist.insert(0, Item(title=typo(title, 'bold color kod')))
|
||||||
if not os.path.isfile(os.path.join(res_dir, 'done')):
|
maxPage = page
|
||||||
|
for d in os.listdir(res_dir):
|
||||||
|
p = scrapertools.find_single_match(d, 'page([0-9])')
|
||||||
|
if p and int(p) > maxPage:
|
||||||
|
maxPage = int(p)
|
||||||
|
isLast = maxPage == page
|
||||||
|
# from core import support
|
||||||
|
# support.dbg()
|
||||||
|
|
||||||
|
if not os.path.isfile(os.path.join(res_dir, 'done')) or (len(new) > res_per_page or not isLast):
|
||||||
itemlist.append(Item(title=typo(config.get_localized_string(30992), 'color kod bold'), channel='search', action='update_list', args={"start_time": start_time,
|
itemlist.append(Item(title=typo(config.get_localized_string(30992), 'color kod bold'), channel='search', action='update_list', args={"start_time": start_time,
|
||||||
"tecleado": tecleado,
|
"tecleado": tecleado,
|
||||||
"categories": categories
|
"categories": categories
|
||||||
}))
|
}, page=page+1))
|
||||||
# Para opcion Buscar en otros canales
|
# Para opcion Buscar en otros canales
|
||||||
if item.contextual == True:
|
if item.contextual == True:
|
||||||
return exact_results(itemlist, tecleado)
|
return exact_results(itemlist, tecleado)
|
||||||
|
|||||||
Reference in New Issue
Block a user