eaf-base-api 2.3.6__tar.gz → 2.3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eaf_base_api
3
- Version: 2.3.6
3
+ Version: 2.3.8
4
4
  Summary: A base API for EchterAlsFake's Porn APIs
5
5
  Home-page: https://github.com/EchterAlsFake/eaf_base_api
6
6
  Author: Johannes Habel
@@ -168,15 +168,16 @@ class BaseCore:
168
168
  """
169
169
  The base class which has all necessary functions for other API packages
170
170
  """
171
- def __init__(self, config=config):
171
+ def __init__(self, config=config, auto_init: bool = True):
172
172
  self.last_request_time = time.time()
173
173
  self.total_requests = 0 # Tracks how many requests have been made
174
174
  self.session = None
175
175
  self.kill_switch = False
176
176
  self.config = config
177
177
  self.cache = Cache(self.config)
178
- self.initialize_session()
179
178
  self.logger = setup_logger("BASE API - [BaseCore]", log_file=False, level=logging.ERROR)
179
+ if auto_init:
180
+ self.initialize_session()
180
181
 
181
182
  def enable_logging(self, log_file=None, level=logging.DEBUG, log_ip=None, log_port=None):
182
183
  """
@@ -232,13 +233,13 @@ class BaseCore:
232
233
  raise KillSwitch("CRITICAL PROXY ERROR, CHECK LOGS!")
233
234
 
234
235
 
235
- def initialize_session(self, verify=True): # Disable SSL verification only if you really need it....
236
+ def initialize_session(self): # Disable SSL verification only if you really need it....
236
237
  self.session = httpx.Client(
237
238
  proxy=self.config.proxy,
238
239
  headers=self.config.headers,
239
240
  timeout=self.config.timeout,
240
241
  follow_redirects=True,
241
- verify=verify
242
+ verify=self.config.verify_ssl
242
243
  )
243
244
 
244
245
  def update_headers(self, headers: dict):
@@ -368,8 +369,12 @@ class BaseCore:
368
369
  self.logger.error(f"Attempt {attempt}: The connection has been unexpectedly closed by: {url}. Retrying...")
369
370
  continue
370
371
 
371
- except httpx.RequestError as e:
372
+ except (httpx.RequestError, httpx.ConnectError) as e:
372
373
  self.logger.error(f"Attempt {attempt}: Request error for URL {url}: {e}")
374
+
375
+ if "CERTIFICATE_VERIFY_FAILED" in str(e):
376
+ raise ProxySSLError("Proxy has an invalid SSL certificate, to get around this error, set 'verify = False' in config")
377
+
373
378
  self.logger.info(f"Retrying ({attempt}/{self.config.max_retries}) for URL: {url}")
374
379
  continue # Continuing even failed requests, because they may succeed on another try (maybe idk)
375
380
 
@@ -42,3 +42,10 @@ class NetworkingError(Exception):
42
42
  def __init__(self, message):
43
43
  self.message = message
44
44
 
45
+
46
+ class ProxySSLError(Exception):
47
+ """
48
+ Raises if a proxy request fails due to self-signed certificates or invalid TLS verification
49
+ """
50
+ def __init__(self, message):
51
+ self.message = message
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eaf_base_api
3
- Version: 2.3.6
3
+ Version: 2.3.8
4
4
  Summary: A base API for EchterAlsFake's Porn APIs
5
5
  Home-page: https://github.com/EchterAlsFake/eaf_base_api
6
6
  Author: Johannes Habel
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="eaf_base_api",
5
- version="2.3.6",
5
+ version="2.3.8",
6
6
  packages=find_packages(),
7
7
  install_requires=["m3u8", "httpx"],
8
8
  extras_require={
File without changes
File without changes
File without changes