abstract-webtools 0.1.6.70__py3-none-any.whl → 0.1.6.71__py3-none-any.whl
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.
- abstract_webtools/managers/videoDownloader.py +40 -20
- {abstract_webtools-0.1.6.70.dist-info → abstract_webtools-0.1.6.71.dist-info}/METADATA +1 -1
- {abstract_webtools-0.1.6.70.dist-info → abstract_webtools-0.1.6.71.dist-info}/RECORD +5 -5
- {abstract_webtools-0.1.6.70.dist-info → abstract_webtools-0.1.6.71.dist-info}/WHEEL +0 -0
- {abstract_webtools-0.1.6.70.dist-info → abstract_webtools-0.1.6.71.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@ from .requestManager.requestManager import requestManager
|
|
2
2
|
from .urlManager.urlManager import urlManager
|
3
3
|
from .soupManager.soupManager import soupManager
|
4
4
|
from .linkManager.linkManager import linkManager
|
5
|
-
import threading,os,re,yt_dlp,urllib.request,m3u8_To_MP4,subprocess,requests
|
5
|
+
import threading,os,re,yt_dlp,urllib.request,m3u8_To_MP4,subprocess,requests,,tempfile
|
6
6
|
from abstract_utilities import get_logFile,safe_dump_to_file,get_time_stamp
|
7
7
|
from m3u8 import M3U8 # Install: pip install m3u8
|
8
8
|
from urllib.parse import urljoin
|
@@ -201,34 +201,54 @@ def get_thumbnails(directory,info):
|
|
201
201
|
info['thumbnails'][i]['path']=thumbnail_path
|
202
202
|
download_image(thumbnail_url, save_path=thumbnail_path)
|
203
203
|
return info
|
204
|
-
def optimize_video_for_safari(input_file):
|
204
|
+
def optimize_video_for_safari(input_file, reencode=False):
|
205
205
|
"""
|
206
206
|
Optimizes an MP4 file for Safari by moving the 'moov' atom to the beginning.
|
207
|
-
|
207
|
+
Optionally, re-encodes the video for maximum compatibility.
|
208
208
|
|
209
209
|
Args:
|
210
210
|
input_file (str): Path to the original MP4 file.
|
211
|
+
reencode (bool): If True, re-encode the video for Safari compatibility.
|
211
212
|
|
212
213
|
Returns:
|
213
214
|
str: Path to the optimized MP4 file.
|
214
215
|
"""
|
215
|
-
|
216
|
-
base, ext = os.path.splitext(input_file)
|
217
|
-
output_file = f"{base}_optimized{ext}"
|
218
|
-
|
219
|
-
# ffmpeg command to copy streams and reposition the moov atom
|
220
|
-
command = ["ffmpeg", "-i", input_file, "-c", "copy", "-movflags", "faststart", output_file]
|
216
|
+
tmp_dir = tempfile.mkdtemp()
|
221
217
|
try:
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
os.
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
218
|
+
local_input = os.path.join(tmp_dir, os.path.basename(input_file))
|
219
|
+
shutil.copy2(input_file, local_input)
|
220
|
+
|
221
|
+
base, ext = os.path.splitext(local_input)
|
222
|
+
local_output = f"{base}_optimized{ext}"
|
223
|
+
|
224
|
+
if reencode:
|
225
|
+
# Re-encoding command for maximum Safari compatibility
|
226
|
+
command = [
|
227
|
+
"ffmpeg", "-i", local_input,
|
228
|
+
"-c:v", "libx264", "-profile:v", "baseline", "-level", "3.0", "-pix_fmt", "yuv420p",
|
229
|
+
"-c:a", "aac", "-b:a", "128k",
|
230
|
+
"-movflags", "faststart",
|
231
|
+
local_output
|
232
|
+
]
|
233
|
+
else:
|
234
|
+
# Simple faststart with stream copy
|
235
|
+
command = [
|
236
|
+
"ffmpeg", "-i", local_input,
|
237
|
+
"-c", "copy", "-movflags", "faststart",
|
238
|
+
local_output
|
239
|
+
]
|
240
|
+
|
241
|
+
try:
|
242
|
+
subprocess.run(command, check=True)
|
243
|
+
shutil.copy2(local_output, input_file)
|
244
|
+
print(f"Optimized video saved as {input_file}")
|
245
|
+
except subprocess.CalledProcessError as e:
|
246
|
+
print(f"Error during optimization: {e}")
|
247
|
+
return input_file
|
248
|
+
finally:
|
249
|
+
shutil.rmtree(tmp_dir)
|
230
250
|
|
231
|
-
def downloadvideo(url, directory=False, rename_display=True, thumbnails=True, audio=False):
|
251
|
+
def downloadvideo(url, directory=False, rename_display=True, thumbnails=True, audio=False,safai_optimize=False):
|
232
252
|
directory = directory or os.getcwd()
|
233
253
|
temp_id = re.sub(r'[^\w\d.-]', '_', url)[-20:]
|
234
254
|
temp_filename = f"temp_{temp_id}.mp4"
|
@@ -256,8 +276,8 @@ def downloadvideo(url, directory=False, rename_display=True, thumbnails=True, au
|
|
256
276
|
info['file_path'] = new_path
|
257
277
|
|
258
278
|
# *** Here we call the optimization function ***
|
259
|
-
if new_path.lower().endswith('.mp4'):
|
260
|
-
info['file_path'] = optimize_video_for_safari(new_path)
|
279
|
+
if new_path.lower().endswith('.mp4') and safai_optimize:
|
280
|
+
info['file_path'] = optimize_video_for_safari(new_path,reencode=safai_optimize)
|
261
281
|
|
262
282
|
info_path = os.path.join(directory, 'info.json')
|
263
283
|
if thumbnails:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: abstract_webtools
|
3
|
-
Version: 0.1.6.
|
3
|
+
Version: 0.1.6.71
|
4
4
|
Summary: Abstract Web Tools is a Python package that provides various utility functions for web scraping tasks. It is built on top of popular libraries such as `requests`, `BeautifulSoup`, and `urllib3` to simplify the process of fetching and parsing web content.
|
5
5
|
Home-page: https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_webtools
|
6
6
|
Author: putkoff
|
@@ -25,7 +25,7 @@ abstract_webtools/managers/sslManager.py,sha256=C-QgQw9CW84uOE5kx2MPjC3RsLbE2JQq
|
|
25
25
|
abstract_webtools/managers/tlsAdapter.py,sha256=XZSMZz9EUOhv-h3_Waf6mjV1dA3oN_M_oWuoo4VZ_HE,1454
|
26
26
|
abstract_webtools/managers/urlManager.py,sha256=Dvf-TiSo5j_YjZS2Eq6lFfbhveneD6NA_wEE0xUXy_E,8858
|
27
27
|
abstract_webtools/managers/userAgentManager.py,sha256=cUaOlcCTzftVBCp9ZHwMXR9IB1wAE-03YSVwUBaIFLM,2514
|
28
|
-
abstract_webtools/managers/videoDownloader.py,sha256=
|
28
|
+
abstract_webtools/managers/videoDownloader.py,sha256=pF0S4Oh9hRAWwLJ61UhNSxAK1sMkUDHBpXDiDs5e0S4,12415
|
29
29
|
abstract_webtools/managers/videoDownloader2.py,sha256=v3H6akdhvVWGrB-r35m3cp_-aKkNWadpfCiMylOnv6w,12748
|
30
30
|
abstract_webtools/managers/linkManager/__init__.py,sha256=NpfWNzvTLSfsIWSeLYIxPzeLHADk_grSx5rfgCeWERw,27
|
31
31
|
abstract_webtools/managers/linkManager/linkManager.py,sha256=roxOzOELca0rOlcMaJkTQHN3S0XF7dJihZmMq-uIXPQ,12184
|
@@ -37,7 +37,7 @@ abstract_webtools/managers/soupManager/soupManager.py,sha256=U3_o189-OWoBRaSCe2s
|
|
37
37
|
abstract_webtools/managers/urlManager/__init__.py,sha256=gaJCHeK91Z-eYsBnxgdhbIUten1-gbx-zqx70R6ag-Y,26
|
38
38
|
abstract_webtools/managers/urlManager/urlManager.py,sha256=vCFuLADmv3h7icaaoAsImGqb_49VizPY_ZvMl-C7PYk,7756
|
39
39
|
abstract_webtools/managers/videos/Heather brooke swallo from condom.mp4,sha256=h-bKFLAHt7pGLGu4EcMvSSox7BPRK0Nga3u813iMVKQ,8335544
|
40
|
-
abstract_webtools-0.1.6.
|
41
|
-
abstract_webtools-0.1.6.
|
42
|
-
abstract_webtools-0.1.6.
|
43
|
-
abstract_webtools-0.1.6.
|
40
|
+
abstract_webtools-0.1.6.71.dist-info/METADATA,sha256=SAnPlOjvIk9qkhVwxlOZf4ukox7WG84kNd2kgjUP8Jw,16029
|
41
|
+
abstract_webtools-0.1.6.71.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
42
|
+
abstract_webtools-0.1.6.71.dist-info/top_level.txt,sha256=2DMJ7RmjTcjCsa-uwAV0K6eXXlIIkFDEjBLg_uyCmCI,18
|
43
|
+
abstract_webtools-0.1.6.71.dist-info/RECORD,,
|
File without changes
|
File without changes
|