eaf_base_api 3.2__tar.gz → 3.2.2__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.2 → eaf_base_api-3.2.2}/PKG-INFO +2 -3
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/base.py +13 -7
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/modules/type_hints.py +7 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/pyproject.toml +7 -5
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/LICENSE +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/README.md +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/__init__.py +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/modules/__init__.py +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/modules/config.py +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/modules/errors.py +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/modules/logger.py +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/modules/progress_bars.py +0 -0
- {eaf_base_api-3.2 → eaf_base_api-3.2.2}/base_api/modules/static_functions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: eaf_base_api
|
|
3
|
-
Version: 3.2
|
|
3
|
+
Version: 3.2.2
|
|
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>
|
|
@@ -8,11 +8,10 @@ License-Expression: LGPL-3.0-or-later
|
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Classifier: Programming Language :: Python
|
|
10
10
|
Requires-Dist: curl-cffi
|
|
11
|
-
Requires-Dist: pylint>=3.3.9
|
|
12
11
|
Requires-Dist: tenacity>=9.1.2
|
|
13
12
|
Requires-Dist: m3u8 ; extra == 'hls'
|
|
14
13
|
Requires-Dist: av ; python_full_version >= '3.10' and extra == 'hls'
|
|
15
|
-
Requires-Python: >=3.
|
|
14
|
+
Requires-Python: >=3.10
|
|
16
15
|
Project-URL: Homepage, https://github.com/EchterAlsFake/eaf_base_api
|
|
17
16
|
Project-URL: Repository, https://github.com/EchterAlsFake/eaf_base_api
|
|
18
17
|
Provides-Extra: hls
|
|
@@ -259,6 +259,12 @@ class Helper:
|
|
|
259
259
|
if asyncio.iscoroutine(video_instance):
|
|
260
260
|
video_instance = await video_instance
|
|
261
261
|
|
|
262
|
+
# Automatically call and await the init method if available (async initialization)
|
|
263
|
+
if hasattr(video_instance, "init") and callable(video_instance.init):
|
|
264
|
+
init_result = video_instance.init()
|
|
265
|
+
if asyncio.iscoroutine(init_result):
|
|
266
|
+
await init_result
|
|
267
|
+
|
|
262
268
|
elapsed_ms = (time.perf_counter() - start_timestamp) * 1000
|
|
263
269
|
logger.debug("video_init ok url=%s (%.2f ms)", video_url, elapsed_ms)
|
|
264
270
|
return video_instance
|
|
@@ -1437,7 +1443,7 @@ a new Python file, import only m3u8 and see what error you get.
|
|
|
1437
1443
|
|
|
1438
1444
|
try:
|
|
1439
1445
|
_, segment_data, is_success = await self.download_segment(url, timeout, stop_event)
|
|
1440
|
-
if is_success and
|
|
1446
|
+
if is_success and segment_data:
|
|
1441
1447
|
return idx, True, segment_data
|
|
1442
1448
|
except Exception as exception:
|
|
1443
1449
|
self.logger.error(f"Worker exception for segment {idx}: {exception}")
|
|
@@ -1939,8 +1945,8 @@ allow_multipart=%s""", url, path, max_retries, read_timeout, bool(stop_event and
|
|
|
1939
1945
|
|
|
1940
1946
|
async def download_chunk(start_chunk: int, end_chunk: int, chunk_idx_now: int) -> bool:
|
|
1941
1947
|
nonlocal total_downloaded
|
|
1942
|
-
headers_chunk = {"Range": f"bytes={
|
|
1943
|
-
chunk_progress[
|
|
1948
|
+
headers_chunk = {"Range": f"bytes={start_chunk}-{end_chunk}", "Accept-Encoding": "identity"}
|
|
1949
|
+
chunk_progress[chunk_idx_now] = 0
|
|
1944
1950
|
|
|
1945
1951
|
for attempt_chunk in range(max_retries + 1):
|
|
1946
1952
|
if stop_event is not None and stop_event.is_set():
|
|
@@ -1972,18 +1978,18 @@ allow_multipart=%s""", url, path, max_retries, read_timeout, bool(stop_event and
|
|
|
1972
1978
|
elif progress_bar:
|
|
1973
1979
|
progress_bar.text_progress_bar(downloaded=total_downloaded[0], total=file_size)
|
|
1974
1980
|
finally:
|
|
1975
|
-
await asyncio.to_thread(
|
|
1981
|
+
await asyncio.to_thread(file.close)
|
|
1976
1982
|
|
|
1977
1983
|
return True # Chunk success
|
|
1978
1984
|
|
|
1979
1985
|
except Exception as exc:
|
|
1980
|
-
if
|
|
1986
|
+
if attempt_chunk < max_retries:
|
|
1981
1987
|
self.logger.warning("Chunk %s failed (attempt %s/%s): %s",
|
|
1982
|
-
chunk_idx_now,
|
|
1988
|
+
chunk_idx_now, attempt_chunk + 1, max_retries, exc)
|
|
1983
1989
|
# Reset progress for this chunk before retry
|
|
1984
1990
|
total_downloaded[0] -= chunk_progress[chunk_idx_now]
|
|
1985
1991
|
chunk_progress[chunk_idx_now] = 0
|
|
1986
|
-
await asyncio.sleep(1 *
|
|
1992
|
+
await asyncio.sleep(1 * attempt_chunk)
|
|
1987
1993
|
else:
|
|
1988
1994
|
self.logger.error("Chunk %s permanently failed: %s", chunk_idx_now, exc)
|
|
1989
1995
|
return False
|
|
@@ -18,6 +18,9 @@ class DownloadState:
|
|
|
18
18
|
missing: list[int]
|
|
19
19
|
segments: list[str]
|
|
20
20
|
|
|
21
|
+
def __getitem__(self, key: str) -> Any:
|
|
22
|
+
return getattr(self, key)
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
# Download state is used for the literal file that tracks it
|
|
23
26
|
@dataclass
|
|
@@ -32,3 +35,7 @@ class DownloadReport:
|
|
|
32
35
|
start_segment: int
|
|
33
36
|
quality: str | int
|
|
34
37
|
|
|
38
|
+
def __getitem__(self, key: str) -> Any:
|
|
39
|
+
return getattr(self, key)
|
|
40
|
+
|
|
41
|
+
|
|
@@ -4,10 +4,10 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "eaf_base_api"
|
|
7
|
-
version = "3.2"
|
|
7
|
+
version = "3.2.2"
|
|
8
8
|
description = "A base API for EchterAlsFake's Porn APIs"
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
11
|
license = "LGPL-3.0-or-later"
|
|
12
12
|
license-files = ["LICENSE*"]
|
|
13
13
|
|
|
@@ -21,7 +21,6 @@ classifiers = [
|
|
|
21
21
|
|
|
22
22
|
dependencies = [
|
|
23
23
|
"curl_cffi",
|
|
24
|
-
"pylint>=3.3.9",
|
|
25
24
|
"tenacity>=9.1.2",
|
|
26
25
|
]
|
|
27
26
|
|
|
@@ -45,6 +44,9 @@ module-name = "base_api" # Because I named it differently we need to change here
|
|
|
45
44
|
|
|
46
45
|
[dependency-groups]
|
|
47
46
|
dev = [
|
|
48
|
-
"mypy
|
|
49
|
-
"types-m3u8
|
|
47
|
+
"mypy",
|
|
48
|
+
"types-m3u8",
|
|
49
|
+
"pylint",
|
|
50
|
+
"pytest",
|
|
51
|
+
"pytest-asyncio"
|
|
50
52
|
]
|
|
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
|