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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: eaf_base_api
3
- Version: 2.2.3
3
+ Version: 2.2.5
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
@@ -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 = b"".join([chunk for chunk in response.iter_bytes()])
159
+ content = raw_content
160
+
154
161
  else:
155
- content = "".join([chunk.decode("utf-8") for chunk in response.iter_bytes()])
156
- if save_cache:
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: eaf_base_api
3
- Version: 2.2.3
3
+ Version: 2.2.5
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.2.3",
5
+ version="2.2.5",
6
6
  packages=find_packages(),
7
7
  install_requires=["ffmpeg-progress-yield", "m3u8", "httpx"],
8
8
  entry_points={
File without changes
File without changes
File without changes