From 1c0b86208273e307a1e88a615ad77e23bce789f5 Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 18 Dec 2019 19:48:44 +0100 Subject: [PATCH] ricerca globale: stessa sessione --- core/httptools.py | 3 ++- specials/search.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/httptools.py b/core/httptools.py index ac8f06d4..979109a4 100755 --- a/core/httptools.py +++ b/core/httptools.py @@ -420,7 +420,8 @@ def downloadpage(url, **opt): # session = requests.session() if opt.get('session', False): - session = opt['session'] # same session to speed up search + session = opt['session'] # same session to speed up search + logger.info('same session') else: from lib import cloudscraper session = cloudscraper.create_scraper() diff --git a/specials/search.py b/specials/search.py index fcf3b31a..657824b6 100755 --- a/specials/search.py +++ b/specials/search.py @@ -174,6 +174,9 @@ def channel_search(item): channel_list = get_channels(item) + from lib import cloudscraper + session = cloudscraper.create_scraper() + searching += channel_list cnt = 0 @@ -182,7 +185,7 @@ def channel_search(item): config.set_setting('tmdb_active', False) with futures.ThreadPoolExecutor() as executor: - c_results = [executor.submit(get_channel_results, ch, item) for ch in channel_list] + c_results = [executor.submit(get_channel_results, ch, item, session) for ch in channel_list] for res in futures.as_completed(c_results): cnt += 1 @@ -264,7 +267,7 @@ def channel_search(item): return valid + results -def get_channel_results(ch, item): +def get_channel_results(ch, item, session): max_results = 10 results = list() @@ -277,6 +280,7 @@ def get_channel_results(ch, item): if search_action: for search_ in search_action: + search_.session = session try: results.extend(module.search(search_, item.text)) except: