From c45ade924c48dcc4536839f7f9e9bc55a9b3a49a Mon Sep 17 00:00:00 2001 From: Alhaziel Date: Sat, 21 Dec 2019 16:41:18 +0100 Subject: [PATCH] VVVVID ricerca multithread --- channels/vvvvid.py | 24 +++++++++++++++++------- specials/search.py | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/channels/vvvvid.py b/channels/vvvvid.py index 9394023f..29a4e4a2 100644 --- a/channels/vvvvid.py +++ b/channels/vvvvid.py @@ -6,6 +6,7 @@ import requests, re from core import support, tmdb from core.item import Item from specials import autorenumber +from lib.concurrent import futures __channel__ = "vvvvid" host = support.config.get_channel_url(__channel__) @@ -87,19 +88,28 @@ def newest(categoria): item.contentType = 'tvshow' item.url = host + 'anime/' return peliculas(item) - + + +def dl_pages(name,item): + itemlist = [] + url = item.url + 'channel/10003/last/?filter=' + str(name) + json_file = current_session.get(url, headers=headers, params=payload).json() + if 'data' in json_file: + json_file = current_session.get(url, headers=headers, params=payload).json() + make_itemlist(itemlist, item, json_file) + return itemlist def peliculas(item): itemlist = [] if not item.args: json_file = current_session.get(item.url + 'channels', headers=headers, params=payload).json() names = [i['filter'] for i in json_file['data'] if 'filter' in i][0] - for name in names: - url = item.url + 'channel/10003/last/?filter=' + str(name) - json_file = current_session.get(url, headers=headers, params=payload).json() - if 'data' in json_file: - json_file = current_session.get(url, headers=headers, params=payload).json() - make_itemlist(itemlist, item, json_file) + with futures.ThreadPoolExecutor() as executor: + json_file = [executor.submit(dl_pages, name, item,) for name in names] + for res in futures.as_completed(json_file): + if res.result(): + itemlist += res.result() + itemlist = sorted(itemlist, key=lambda it: it.fulltitle) elif ('=' not in item.args) and ('=' not in item.url): json_file = current_session.get(item.url + item.args, headers=headers, params=payload).json() diff --git a/specials/search.py b/specials/search.py index 79269499..c0101d19 100755 --- a/specials/search.py +++ b/specials/search.py @@ -271,7 +271,7 @@ def channel_search(item): ch_thumb = channeltools.get_channel_parameters(key)['thumbnail'] results.append(Item(channel='search', title=title, action='get_from_temp', thumbnail=ch_thumb, itemlist=[ris.tourl() for ris in grouped], plot=plot, page=1)) - results = sorted(results, key=lambda it: it.from_channel) + # send_to_temp(to_temp) @@ -279,7 +279,7 @@ def channel_search(item): if item.mode == 'all': if config.get_setting('result_mode', 'search') != 0: res_count = len(results) - results = sorted(results, key=lambda it: it.title) + results = sorted(results, key=lambda it: it.title) results_statistic = config.get_localized_string(59972) % (item.title, res_count, time.time() - start) results.insert(0, Item(title = typo(results_statistic,'color kod bold'))) # logger.debug(results_statistic)