eaf_base_api 3.0__tar.gz → 3.1__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-3.0 → eaf_base_api-3.1}/PKG-INFO +4 -1
- {eaf_base_api-3.0 → eaf_base_api-3.1}/README.md +3 -0
- {eaf_base_api-3.0 → eaf_base_api-3.1}/base_api/base.py +33 -24
- {eaf_base_api-3.0 → eaf_base_api-3.1}/base_api/modules/config.py +7 -2
- {eaf_base_api-3.0 → eaf_base_api-3.1}/pyproject.toml +1 -1
- {eaf_base_api-3.0 → eaf_base_api-3.1}/LICENSE +0 -0
- {eaf_base_api-3.0 → eaf_base_api-3.1}/base_api/__init__.py +0 -0
- {eaf_base_api-3.0 → eaf_base_api-3.1}/base_api/modules/__init__.py +0 -0
- {eaf_base_api-3.0 → eaf_base_api-3.1}/base_api/modules/errors.py +0 -0
- {eaf_base_api-3.0 → eaf_base_api-3.1}/base_api/modules/progress_bars.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: eaf_base_api
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.1
|
|
4
4
|
Summary: A base API for EchterAlsFake's Porn APIs
|
|
5
5
|
Author: Johannes Habel
|
|
6
6
|
Author-email: Johannes Habel <EchterAlsFake@proton.me>
|
|
@@ -16,6 +16,9 @@ Project-URL: Repository, https://github.com/EchterAlsFake/eaf_base_api
|
|
|
16
16
|
Provides-Extra: hls
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
|
|
19
|
+
> [!WARNING]
|
|
20
|
+
> The current release v3.0 breaks ALL existing projects that use this Project. DO NOT update yet, keep your v2.5.4.
|
|
21
|
+
|
|
19
22
|
# EAF Base API
|
|
20
23
|
|
|
21
24
|
# What is this?
|
|
@@ -30,6 +30,7 @@ from datetime import datetime, timezone
|
|
|
30
30
|
from email.utils import parsedate_to_datetime
|
|
31
31
|
from typing import Any, Dict, List, Optional, Union, Callable, Tuple, Iterable
|
|
32
32
|
|
|
33
|
+
from curl_cffi import CurlOpt # Used for DNS over HTTPS
|
|
33
34
|
from curl_cffi import requests
|
|
34
35
|
from curl_cffi.requests.errors import RequestsError
|
|
35
36
|
from curl_cffi.requests import AsyncSession, Response
|
|
@@ -796,15 +797,36 @@ class BaseCore:
|
|
|
796
797
|
def initialize_session(self):
|
|
797
798
|
verify = self.config.verify_ssl
|
|
798
799
|
|
|
800
|
+
curl_options = {}
|
|
801
|
+
if self.config.dns_over_https:
|
|
802
|
+
curl_options[CurlOpt.DOH_URL] = str(self.config.dns_over_https).encode("utf-8")
|
|
803
|
+
|
|
799
804
|
proxies = None
|
|
800
|
-
if self.config.
|
|
801
|
-
proxies =
|
|
805
|
+
if self.config.proxies:
|
|
806
|
+
proxies = self.config.proxies
|
|
807
|
+
|
|
808
|
+
if self.config.max_bandwidth_mb is not None and self.config.max_bandwidth_mb > 0:
|
|
809
|
+
global_limit_bytes = int(self.config.max_bandwidth_mb * 1024 * 1024)
|
|
810
|
+
total_concurrent_connections = self.config.max_workers_download * self.config.videos_concurrency
|
|
811
|
+
per_connection_limit = max(1, int(global_limit_bytes / total_concurrent_connections))
|
|
812
|
+
curl_options[CurlOpt.MAX_RECV_SPEED_LARGE] = per_connection_limit
|
|
813
|
+
|
|
814
|
+
js3 = self.config.custom_ja3
|
|
815
|
+
impersonation = self.config.impersonation
|
|
816
|
+
http_version = self.config.http_version
|
|
817
|
+
proxy_auth = self.config.proxy_auth
|
|
818
|
+
trust_env = self.config.trust_env
|
|
802
819
|
|
|
803
820
|
self.session = AsyncSession(
|
|
804
821
|
proxies=proxies,
|
|
805
822
|
timeout=self.config.timeout,
|
|
806
823
|
verify=verify,
|
|
807
|
-
impersonate=
|
|
824
|
+
impersonate=impersonation,
|
|
825
|
+
curl_options=curl_options,
|
|
826
|
+
http_version=http_version,
|
|
827
|
+
ja3=js3,
|
|
828
|
+
proxy_auth=proxy_auth,
|
|
829
|
+
trust_env=trust_env
|
|
808
830
|
)
|
|
809
831
|
# Ensure our defaults are on the session
|
|
810
832
|
self.session.headers.update(self.default_headers)
|
|
@@ -983,6 +1005,12 @@ class BaseCore:
|
|
|
983
1005
|
self.logger.debug(f"Using Headers: {self.session.headers}")
|
|
984
1006
|
self.logger.debug(f"Using Cookies: {self.session.cookies}")
|
|
985
1007
|
|
|
1008
|
+
if isinstance(self.config.max_bandwidth_mb, int):
|
|
1009
|
+
speed_limit = self.config.max_bandwidth_mb * 1024 * 1024 # Convert to bytes
|
|
1010
|
+
|
|
1011
|
+
else:
|
|
1012
|
+
speed_limit = None
|
|
1013
|
+
|
|
986
1014
|
response = await self.session.request(
|
|
987
1015
|
method=method,
|
|
988
1016
|
url=url,
|
|
@@ -991,6 +1019,7 @@ class BaseCore:
|
|
|
991
1019
|
data=data,
|
|
992
1020
|
json=json,
|
|
993
1021
|
params=params,
|
|
1022
|
+
max_recv_speed=speed_limit,
|
|
994
1023
|
)
|
|
995
1024
|
|
|
996
1025
|
last_response = response
|
|
@@ -1004,27 +1033,7 @@ class BaseCore:
|
|
|
1004
1033
|
if get_response:
|
|
1005
1034
|
return response
|
|
1006
1035
|
|
|
1007
|
-
|
|
1008
|
-
if self.config.max_bandwidth_mb is not None and self.config.max_bandwidth_mb >= 0.2:
|
|
1009
|
-
raw_content = bytearray()
|
|
1010
|
-
chunk_size = 64 * 1024 # 64 KB
|
|
1011
|
-
speed_limit = self.config.max_bandwidth_mb * 1024 * 1024
|
|
1012
|
-
min_time_per_chunk = chunk_size / speed_limit
|
|
1013
|
-
start_time = time.time()
|
|
1014
|
-
|
|
1015
|
-
content_bytes = response.content
|
|
1016
|
-
for i in range(0, len(content_bytes), chunk_size):
|
|
1017
|
-
chunk = content_bytes[i:i+chunk_size]
|
|
1018
|
-
raw_content.extend(chunk)
|
|
1019
|
-
elapsed = time.time() - start_time
|
|
1020
|
-
sleep_time = min_time_per_chunk - elapsed
|
|
1021
|
-
if sleep_time > 0:
|
|
1022
|
-
await asyncio.sleep(sleep_time)
|
|
1023
|
-
start_time = time.time()
|
|
1024
|
-
raw_content = bytes(raw_content)
|
|
1025
|
-
|
|
1026
|
-
else:
|
|
1027
|
-
raw_content = response.content
|
|
1036
|
+
raw_content = response.content
|
|
1028
1037
|
|
|
1029
1038
|
if get_bytes:
|
|
1030
1039
|
content = raw_content
|
|
@@ -5,9 +5,14 @@ class RuntimeConfig:
|
|
|
5
5
|
self.request_delay = 0
|
|
6
6
|
self.timeout = 20
|
|
7
7
|
self.max_bandwidth_mb = None # Set speed limit in megabytes per second e.g, 2.0, 3.5 etc...
|
|
8
|
-
self.
|
|
9
|
-
self.
|
|
8
|
+
self.proxies = None
|
|
9
|
+
self.http_version = "v3" # "v3 = HTTP/3.0, v2 = HTTP/2.0, v1 = HTTP/1.1
|
|
10
|
+
self.dns_over_https = None
|
|
11
|
+
self.impersonation = "chrome"
|
|
12
|
+
self.custom_ja3 = None # Absolutely only for advanced users, research before you use this!!!
|
|
13
|
+
self.proxy_auth = None
|
|
10
14
|
self.verify_ssl = True
|
|
15
|
+
self.trust_env = False
|
|
11
16
|
self.cookies = None
|
|
12
17
|
self.locale = "en-US,en;q=0.9" # If you override this, it could change regexes and thus make stuff not work...
|
|
13
18
|
self.max_workers_download = 20
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|