From fe7ebb5f22acf49635e200644a4cdc27546bcc1f Mon Sep 17 00:00:00 2001 From: Alhaziel Date: Wed, 18 Dec 2019 20:41:55 +0100 Subject: [PATCH] Revert "niente sessione per ricerca globale" This reverts commit 303e3d793f476df58472bc78e2c1674e17407968. --- core/httptools.py | 8 ++++++-- specials/search.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/httptools.py b/core/httptools.py index 3cc56be2..979109a4 100755 --- a/core/httptools.py +++ b/core/httptools.py @@ -419,8 +419,12 @@ def downloadpage(url, **opt): # from lib import requests # session = requests.session() - from lib import cloudscraper - session = cloudscraper.create_scraper() + if opt.get('session', False): + session = opt['session'] # same session to speed up search + logger.info('same session') + else: + from lib import cloudscraper + session = cloudscraper.create_scraper() # Headers by default, if nothing is specified req_headers = default_headers.copy() 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: