eaf-base-api 1.2__tar.gz → 1.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-1.2 → eaf_base_api-1.5}/PKG-INFO +1 -1
- {eaf_base_api-1.2 → eaf_base_api-1.5}/base_api/base.py +3 -2
- eaf_base_api-1.5/base_api/modules/consts.py +2 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/base_api/modules/download.py +39 -2
- {eaf_base_api-1.2 → eaf_base_api-1.5}/eaf_base_api.egg-info/PKG-INFO +1 -1
- {eaf_base_api-1.2 → eaf_base_api-1.5}/setup.py +1 -1
- eaf_base_api-1.2/base_api/modules/consts.py +0 -1
- {eaf_base_api-1.2 → eaf_base_api-1.5}/README.md +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/base_api/__init__.py +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/base_api/modules/__init__.py +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/base_api/modules/progress_bars.py +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/base_api/modules/quality.py +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/eaf_base_api.egg-info/SOURCES.txt +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/eaf_base_api.egg-info/dependency_links.txt +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/eaf_base_api.egg-info/requires.txt +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/eaf_base_api.egg-info/top_level.txt +0 -0
- {eaf_base_api-1.2 → eaf_base_api-1.5}/setup.cfg +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import requests
|
|
2
2
|
import logging
|
|
3
3
|
import time
|
|
4
|
+
import string
|
|
4
5
|
|
|
5
6
|
from base_api.modules.quality import Quality
|
|
6
7
|
from base_api.modules.progress_bars import Callback
|
|
@@ -23,11 +24,11 @@ base_qualities = ["250p", "360p", "480p", "720p", "1080p", "1440p", "2160p"]
|
|
|
23
24
|
|
|
24
25
|
class Core:
|
|
25
26
|
@classmethod
|
|
26
|
-
def get_content(cls, url, headers=None, cookies=None):
|
|
27
|
+
def get_content(cls, url, headers=None, cookies=None, stream=False):
|
|
27
28
|
for i in range(MAX_RETRIES):
|
|
28
29
|
try:
|
|
29
30
|
logging.debug(f"Trying to fetch {url} / Attempt: [{i+1}]")
|
|
30
|
-
response = requests.get(url, headers=headers, cookies=cookies)
|
|
31
|
+
response = requests.get(url, headers=headers, cookies=cookies, stream=stream)
|
|
31
32
|
if response.status_code == 200:
|
|
32
33
|
logging.info(f"Successfully fetched {url} on attempt [{i+1}]")
|
|
33
34
|
return response.content
|
|
@@ -7,6 +7,13 @@ import os
|
|
|
7
7
|
from ffmpeg_progress_yield import FfmpegProgress
|
|
8
8
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
9
9
|
from typing import Callable, List
|
|
10
|
+
from base_api.modules.progress_bars import Callback
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from base_api.modules.consts import FFMPEG_PATH
|
|
14
|
+
|
|
15
|
+
except (ModuleNotFoundError, ImportError):
|
|
16
|
+
from .consts import FFMPEG_PATH
|
|
10
17
|
|
|
11
18
|
CallbackType = Callable[[int, int], None]
|
|
12
19
|
|
|
@@ -109,7 +116,7 @@ def FFMPEG(video, quality, callback, path, start=0) -> bool:
|
|
|
109
116
|
|
|
110
117
|
# Build the command for FFMPEG as a list directly
|
|
111
118
|
command = [
|
|
112
|
-
|
|
119
|
+
FFMPEG_PATH,
|
|
113
120
|
"-i", new_url, # Input URL
|
|
114
121
|
"-bsf:a", "aac_adtstoasc",
|
|
115
122
|
"-y", # Overwrite output files without asking
|
|
@@ -126,4 +133,34 @@ def FFMPEG(video, quality, callback, path, start=0) -> bool:
|
|
|
126
133
|
if progress == 100:
|
|
127
134
|
return True
|
|
128
135
|
|
|
129
|
-
return False
|
|
136
|
+
return False
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def legacy_download(stream, path, url, callback=None):
|
|
140
|
+
response = requests.get(url, stream=stream)
|
|
141
|
+
file_size = int(response.headers.get('content-length', 0))
|
|
142
|
+
|
|
143
|
+
if callback is None:
|
|
144
|
+
progress_bar = Callback()
|
|
145
|
+
|
|
146
|
+
downloaded_so_far = 0
|
|
147
|
+
|
|
148
|
+
if not os.path.exists(path):
|
|
149
|
+
with open(path, 'wb') as file:
|
|
150
|
+
for chunk in response.iter_content(chunk_size=1024):
|
|
151
|
+
file.write(chunk)
|
|
152
|
+
downloaded_so_far += len(chunk)
|
|
153
|
+
|
|
154
|
+
if callback:
|
|
155
|
+
callback(downloaded_so_far, file_size)
|
|
156
|
+
|
|
157
|
+
else:
|
|
158
|
+
progress_bar.text_progress_bar(downloaded=downloaded_so_far, total=file_size)
|
|
159
|
+
|
|
160
|
+
if not callback:
|
|
161
|
+
del progress_bar
|
|
162
|
+
|
|
163
|
+
return True
|
|
164
|
+
|
|
165
|
+
else:
|
|
166
|
+
raise FileExistsError("The file already exists.")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
MAX_RETRIES = 4
|
|
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
|