eaf-base-api 2.2.3__tar.gz → 2.2.5__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.3 → eaf_base_api-2.2.5}/PKG-INFO +1 -1
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/base_api/base.py +17 -6
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/eaf_base_api.egg-info/PKG-INFO +1 -1
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/setup.py +1 -1
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/LICENSE +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/README.md +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/base_api/__init__.py +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/base_api/modules/__init__.py +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/base_api/modules/consts.py +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/base_api/modules/progress_bars.py +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/eaf_base_api.egg-info/SOURCES.txt +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/eaf_base_api.egg-info/dependency_links.txt +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/eaf_base_api.egg-info/requires.txt +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/eaf_base_api.egg-info/top_level.txt +0 -0
- {eaf_base_api-2.2.3 → eaf_base_api-2.2.5}/setup.cfg +0 -0
|
@@ -84,8 +84,8 @@ class BaseCore:
|
|
|
84
84
|
self.session = httpx.Client(proxy=consts.PROXY,
|
|
85
85
|
headers=consts.HEADERS,
|
|
86
86
|
verify=verify,
|
|
87
|
-
timeout=consts.TIMEOUT
|
|
88
|
-
)
|
|
87
|
+
timeout=consts.TIMEOUT,
|
|
88
|
+
follow_redirects=True)
|
|
89
89
|
|
|
90
90
|
def enforce_delay(self):
|
|
91
91
|
"""Enforces the specified delay in consts.REQUEST_DELAY"""
|
|
@@ -119,6 +119,9 @@ class BaseCore:
|
|
|
119
119
|
return content
|
|
120
120
|
|
|
121
121
|
for attempt in range(1, consts.MAX_RETRIES + 1):
|
|
122
|
+
if attempt != 1:
|
|
123
|
+
time.sleep(1.5) # Sleeping for 1.5 seconds to minimize site overload when doing a lot of requests
|
|
124
|
+
|
|
122
125
|
try:
|
|
123
126
|
# Update user agent periodically
|
|
124
127
|
if self.total_requests % 3 == 0:
|
|
@@ -149,11 +152,20 @@ class BaseCore:
|
|
|
149
152
|
return response
|
|
150
153
|
|
|
151
154
|
# Process and return content
|
|
155
|
+
# Collecting all chunks before processing because some sites cause issues with real-time decoding
|
|
156
|
+
raw_content = b"".join(response.iter_bytes())
|
|
157
|
+
|
|
152
158
|
if get_bytes:
|
|
153
|
-
content =
|
|
159
|
+
content = raw_content
|
|
160
|
+
|
|
154
161
|
else:
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
try:
|
|
163
|
+
content = raw_content.decode("utf-8")
|
|
164
|
+
|
|
165
|
+
except UnicodeDecodeError:
|
|
166
|
+
content = raw_content.decode("latin1") # Fallback, hope that works somehow idk
|
|
167
|
+
|
|
168
|
+
if save_cache and not get_bytes:
|
|
157
169
|
logger.debug(f"Saving content of {url} to local cache.")
|
|
158
170
|
cache.save_cache(url, content)
|
|
159
171
|
|
|
@@ -368,7 +380,6 @@ class BaseCore:
|
|
|
368
380
|
try:
|
|
369
381
|
with self.session.stream("GET", url, timeout=30) as response: # Use a reasonable timeout
|
|
370
382
|
response.raise_for_status()
|
|
371
|
-
|
|
372
383
|
file_size = int(response.headers.get('content-length', 0))
|
|
373
384
|
|
|
374
385
|
if callback is None:
|
|
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
|