From 447c035a55ec07d0f1e06bd262b0ca5365064a1c Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Sun, 6 Nov 2022 05:32:02 +0800 Subject: [PATCH] Simply message output --- ImageProcessing/__init__.py | 1 - ImageProcessing/hog.py | 2 +- core.py | 3 +-- scrapinglib/httprequest.py | 40 +++++++++++++++++++++---------------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/ImageProcessing/__init__.py b/ImageProcessing/__init__.py index 3fd19f5..4df1797 100644 --- a/ImageProcessing/__init__.py +++ b/ImageProcessing/__init__.py @@ -100,7 +100,6 @@ def cutImage(imagecut, path, fanart_path, poster_path, skip_facerec=False): def face_center(filename, model): - print('[+]Use model ' + model) try: mod = importlib.import_module('.' + model, 'ImageProcessing') return mod.face_center(filename, model) diff --git a/ImageProcessing/hog.py b/ImageProcessing/hog.py index 4e672b5..3a6ca49 100644 --- a/ImageProcessing/hog.py +++ b/ImageProcessing/hog.py @@ -4,7 +4,7 @@ import face_recognition def face_center(filename, model): image = face_recognition.load_image_file(filename) face_locations = face_recognition.face_locations(image, 1, model) - print('[+]Found person ' + str(len(face_locations))) + print('[+]Found person [' + str(len(face_locations)) + '] By model hog') maxRight = 0 maxTop = 0 for face_location in face_locations: diff --git a/core.py b/core.py index 0c1d033..56783e1 100644 --- a/core.py +++ b/core.py @@ -473,9 +473,8 @@ def add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, hack) -> None: if mark_type == '': return add_mark_thread(thumb_path, cn_sub, leak, uncensored, hack) - print('[+]Thumb Add Mark: ' + mark_type.strip(',')) add_mark_thread(poster_path, cn_sub, leak, uncensored, hack) - print('[+]Poster Add Mark: ' + mark_type.strip(',')) + print('[+]Add Mark: ' + mark_type.strip(',')) def add_mark_thread(pic_path, cn_sub, leak, uncensored, hack): diff --git a/scrapinglib/httprequest.py b/scrapinglib/httprequest.py index e987d63..ca3c36b 100644 --- a/scrapinglib/httprequest.py +++ b/scrapinglib/httprequest.py @@ -6,12 +6,14 @@ from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry from cloudscraper import create_scraper +import config + G_USER_AGENT = r'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.133 Safari/537.36' G_DEFAULT_TIMEOUT = 10 -def get(url: str, cookies=None, ua: str=None, extra_headers=None, return_type: str=None, encoding: str=None, - retry: int=3, timeout: int=G_DEFAULT_TIMEOUT, proxies=None, verify=None): +def get(url: str, cookies=None, ua: str = None, extra_headers=None, return_type: str = None, encoding: str = None, + retry: int = 3, timeout: int = G_DEFAULT_TIMEOUT, proxies=None, verify=None): """ 网页请求核心函数 @@ -33,14 +35,16 @@ def get(url: str, cookies=None, ua: str=None, extra_headers=None, return_type: s result.encoding = encoding or result.apparent_encoding return result.text except Exception as e: - print(f"[-]Connect: {url} retry {i + 1}/{retry}") + if config.getInstance().debug(): + print(f"[-]Connect: {url} retry {i + 1}/{retry}") errors = str(e) - if "getaddrinfo failed" in errors: - print("[-]Connect Failed! Please Check your proxy config") - print("[-]" + errors) - else: - print("[-]" + errors) - print('[-]Connect Failed! Please check your Proxy or Network!') + if config.getInstance().debug(): + if "getaddrinfo failed" in errors: + print("[-]Connect Failed! Please Check your proxy config") + print("[-]" + errors) + else: + print("[-]" + errors) + print('[-]Connect Failed! Please check your Proxy or Network!') raise Exception('Connect Failed') @@ -64,15 +68,17 @@ def post(url: str, data: dict=None, files=None, cookies=None, ua: str=None, retu result.encoding = encoding or result.apparent_encoding return result except Exception as e: - print(f"[-]Connect: {url} retry {i + 1}/{retry}") + if config.getInstance().debug(): + print(f"[-]Connect: {url} retry {i + 1}/{retry}") errors = str(e) - if "getaddrinfo failed" in errors: - print("[-]Connect Failed! Please Check your proxy config") - print("[-]" + errors) - else: - print("[-]" + errors) - print('[-]Connect Failed! Please check your Proxy or Network!') - raise Exception('Connect Failed') + if config.getInstance().debug(): + if "getaddrinfo failed" in errors: + print("[-]Connect Failed! Please Check your proxy config") + print("[-]" + errors) + else: + print("[-]" + errors) + print('[-]Connect Failed! Please check your Proxy or Network!') + raise Exception('Connect Failed') class TimeoutHTTPAdapter(HTTPAdapter):