eaf-base-api 2.2.7__tar.gz → 2.2.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.
- {eaf_base_api-2.2.7/eaf_base_api.egg-info → eaf_base_api-2.2.8}/PKG-INFO +1 -1
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/base_api/base.py +10 -10
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8/eaf_base_api.egg-info}/PKG-INFO +1 -1
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/setup.py +1 -1
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/LICENSE +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/README.md +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/base_api/__init__.py +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/base_api/modules/__init__.py +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/base_api/modules/config.py +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/base_api/modules/progress_bars.py +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/eaf_base_api.egg-info/SOURCES.txt +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/eaf_base_api.egg-info/dependency_links.txt +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/eaf_base_api.egg-info/requires.txt +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/eaf_base_api.egg-info/top_level.txt +0 -0
- {eaf_base_api-2.2.7 → eaf_base_api-2.2.8}/setup.cfg +0 -0
|
@@ -5,7 +5,6 @@ import time
|
|
|
5
5
|
import m3u8
|
|
6
6
|
import json
|
|
7
7
|
import httpx
|
|
8
|
-
import random
|
|
9
8
|
import logging
|
|
10
9
|
import traceback
|
|
11
10
|
import threading
|
|
@@ -143,6 +142,7 @@ class Cache:
|
|
|
143
142
|
self.cache_dictionary = {}
|
|
144
143
|
self.lock = threading.Lock()
|
|
145
144
|
self.logger = setup_logger("BASE API - [Cache]", level=logging.CRITICAL)
|
|
145
|
+
self.config = config
|
|
146
146
|
|
|
147
147
|
def enable_logging(self, log_file=None, level=logging.DEBUG):
|
|
148
148
|
"""
|
|
@@ -160,7 +160,7 @@ class Cache:
|
|
|
160
160
|
|
|
161
161
|
def save_cache(self, url, content):
|
|
162
162
|
with self.lock:
|
|
163
|
-
if len(self.cache_dictionary.keys()) >=
|
|
163
|
+
if len(self.cache_dictionary.keys()) >= self.config.max_cache_items:
|
|
164
164
|
first_key = next(iter(self.cache_dictionary))
|
|
165
165
|
# Delete the first item
|
|
166
166
|
del self.cache_dictionary[first_key]
|
|
@@ -200,7 +200,7 @@ class BaseCore:
|
|
|
200
200
|
self.kill_switch = True
|
|
201
201
|
|
|
202
202
|
def check_kill_switch(self):
|
|
203
|
-
proxy_ip = self.config.
|
|
203
|
+
proxy_ip = self.config.proxy
|
|
204
204
|
pattern = re.compile(
|
|
205
205
|
r'^(?P<scheme>http|socks5)://'
|
|
206
206
|
r'(?:(?:\w+:\w+)@)?' # optional user:pass@
|
|
@@ -233,16 +233,16 @@ class BaseCore:
|
|
|
233
233
|
|
|
234
234
|
def initialize_session(self, verify=True): # Disable SSL verification only if you really need it....
|
|
235
235
|
self.session = httpx.Client(
|
|
236
|
-
proxy=self.config.
|
|
237
|
-
headers=self.config.
|
|
238
|
-
timeout=self.config.
|
|
236
|
+
proxy=self.config.proxy,
|
|
237
|
+
headers=self.config.headers,
|
|
238
|
+
timeout=self.config.timeout,
|
|
239
239
|
follow_redirects=True,
|
|
240
240
|
verify=verify
|
|
241
241
|
)
|
|
242
242
|
|
|
243
243
|
def enforce_delay(self):
|
|
244
244
|
"""Enforces the specified delay in consts.REQUEST_DELAY"""
|
|
245
|
-
delay = self.config.
|
|
245
|
+
delay = self.config.request_delay
|
|
246
246
|
if delay > 0:
|
|
247
247
|
time_since_last_request = time.time() - self.last_request_time
|
|
248
248
|
self.logger.debug(f"Time since last request: {time_since_last_request:.2f} seconds.")
|
|
@@ -276,7 +276,7 @@ class BaseCore:
|
|
|
276
276
|
self.logger.info(f"Fetched content for: {url} from cache!")
|
|
277
277
|
return content
|
|
278
278
|
|
|
279
|
-
for attempt in range(1, self.config.
|
|
279
|
+
for attempt in range(1, self.config.max_retries + 1):
|
|
280
280
|
if attempt != 1:
|
|
281
281
|
time.sleep(1.5) # Sleeping for 1.5 seconds to minimize site overload when doing a lot of requests
|
|
282
282
|
|
|
@@ -342,9 +342,9 @@ class BaseCore:
|
|
|
342
342
|
except Exception:
|
|
343
343
|
self.logger.error(f"Attempt {attempt}: Unexpected error for URL {url}: {traceback.format_exc()}")
|
|
344
344
|
|
|
345
|
-
self.logger.info(f"Retrying ({attempt}/{self.config.
|
|
345
|
+
self.logger.info(f"Retrying ({attempt}/{self.config.max_retries}) for URL: {url}")
|
|
346
346
|
|
|
347
|
-
self.logger.error(f"Failed to fetch URL {url} after {self.config.
|
|
347
|
+
self.logger.error(f"Failed to fetch URL {url} after {self.config.max_retries} attempts.")
|
|
348
348
|
return None # Return None if all attempts fail
|
|
349
349
|
|
|
350
350
|
@classmethod
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|