abstract-webtools 0.1.6.79__py3-none-any.whl → 0.1.6.81__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/allss//.py +7 -0
- abstract_webtools/managers/videoDownloader.py +61 -22
- {abstract_webtools-0.1.6.79.dist-info → abstract_webtools-0.1.6.81.dist-info}/METADATA +1 -1
- {abstract_webtools-0.1.6.79.dist-info → abstract_webtools-0.1.6.81.dist-info}/RECORD +6 -5
- {abstract_webtools-0.1.6.79.dist-info → abstract_webtools-0.1.6.81.dist-info}/WHEEL +0 -0
- {abstract_webtools-0.1.6.79.dist-info → abstract_webtools-0.1.6.81.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,7 @@
|
|
1
|
+
from abstract_apis import *
|
2
|
+
from abstract_webtools import *
|
3
|
+
url = 'https://clownworld.biz/media/download_from_url'
|
4
|
+
video_url = 'https://www.youtube.com/watch?v=Tn7fks2UDRE'
|
5
|
+
downloadvideo(video_url,directory=directory,safari_optimize=True)
|
6
|
+
response= postRequest(url,data={"url":video_url})
|
7
|
+
input(response)
|
@@ -240,50 +240,89 @@ def optimize_video_for_safari(input_file, reencode=False):
|
|
240
240
|
|
241
241
|
try:
|
242
242
|
subprocess.run(command, check=True)
|
243
|
-
|
243
|
+
|
244
|
+
os.remove(input_file)
|
245
|
+
shutil.move(local_output, input_file)
|
244
246
|
print(f"Optimized video saved as {input_file}")
|
245
247
|
except subprocess.CalledProcessError as e:
|
246
248
|
print(f"Error during optimization: {e}")
|
247
249
|
return input_file
|
248
250
|
finally:
|
249
251
|
shutil.rmtree(tmp_dir)
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
252
|
+
def bool_or_default(obj,default=True):
|
253
|
+
if obj == None:
|
254
|
+
obj = default
|
255
|
+
return obj
|
256
|
+
def get_video_info(url,download_directory=None,output_filename=None,get_info=None,download_video=None):
|
257
|
+
directory = download_directory or os.getcwd()
|
258
|
+
output_filename = output_filename or get_temp_file_name(url)
|
259
|
+
get_info = bool_or_true(get_info)
|
260
|
+
download_video = bool_or_default(download_video,default=False)
|
255
261
|
video_mgr = VideoDownloader(
|
256
262
|
url=url,
|
257
263
|
download_directory=directory,
|
258
|
-
download_video=
|
259
|
-
get_info=
|
260
|
-
output_filename=
|
264
|
+
download_video=download_video,
|
265
|
+
get_info=get_info,
|
266
|
+
output_filename=output_filename
|
261
267
|
)
|
262
|
-
|
268
|
+
return video_mgr
|
269
|
+
def get_temp_id(url):
|
270
|
+
url = str(url)
|
271
|
+
url_length = len(url)
|
272
|
+
len_neg = 20
|
273
|
+
len_neg = len_neg if url_length >= len_neg else url_length
|
274
|
+
temp_id = re.sub(r'[^\w\d.-]', '_', url)[-len_neg:]
|
275
|
+
return temp_id
|
276
|
+
def get_temp_file_name(url):
|
277
|
+
temp_id = get_temp_id(url)
|
278
|
+
temp_filename = f"temp_{temp_id}.mp4"
|
279
|
+
return temp_filename
|
280
|
+
def get_display_id(info):
|
263
281
|
display_id = info.get('display_id') or info.get('id')
|
264
|
-
|
282
|
+
return display_id
|
283
|
+
def get_video_title(info):
|
284
|
+
title = info.get('title', 'video')[:30]
|
285
|
+
return title
|
286
|
+
def get_safe_title(title):
|
287
|
+
re_str = r'[^\w\d.-]'
|
288
|
+
safe_title = re.sub(re_str, '_', title)
|
289
|
+
return safe_title
|
290
|
+
def downloadvideo(url, directory=None,output_filename=None, rename_display=None, thumbnails=None, audio=None,safari_optimize=None,download_video=None,*args,**kwargs):
|
291
|
+
rename_display = bool_or_default(rename_display)
|
292
|
+
thumbnails= bool_or_default(thumbnails)
|
293
|
+
audio= bool_or_default(thumbnails,default=False)
|
294
|
+
safari_optimize=bool_or_default(thumbnails,default=True)
|
295
|
+
download_video =bool_or_default(download_video,default=True)
|
296
|
+
output_filename = output_filename or get_temp_file_name(url)
|
297
|
+
video_mgr = get_video_info(url,download_directory=directory,output_filename=output_filename,download_video=download_video)
|
298
|
+
info = video_mgr.info
|
299
|
+
display_id = get_display_id(info)
|
265
300
|
os.makedirs(directory, exist_ok=True)
|
266
|
-
|
267
|
-
|
301
|
+
video_directory = os.path.join(directory, display_id)
|
302
|
+
os.makedirs(video_directory, exist_ok=True)
|
303
|
+
file_path = None
|
304
|
+
if info:
|
305
|
+
file_path = info.get('file_path')
|
306
|
+
if rename_display and file_path:
|
268
307
|
# Rename using metadata
|
269
|
-
video_id = info.get('id',
|
270
|
-
title = info
|
271
|
-
safe_title =
|
272
|
-
final_filename = f"{safe_title}_{video_id}
|
273
|
-
|
308
|
+
video_id = info.get('id', get_temp_id(url))
|
309
|
+
title = output_filename or get_video_title(info)
|
310
|
+
safe_title = get_safe_title(title)
|
311
|
+
final_filename = output_filename or f"{safe_title}_{video_id}"
|
312
|
+
final_filename = f"{final_filename}.mp4"
|
313
|
+
new_path = os.path.join(video_directory, final_filename)
|
274
314
|
if os.path.exists(info['file_path']):
|
275
315
|
os.rename(info['file_path'], new_path)
|
276
316
|
info['file_path'] = new_path
|
317
|
+
info['file_path'] = new_path
|
277
318
|
|
278
319
|
# *** Here we call the optimization function ***
|
279
320
|
video_path = info.get('file_path')
|
280
321
|
if video_path and video_path.lower().endswith('.mp4') and safari_optimize:
|
281
322
|
info['file_path'] = optimize_video_for_safari(video_path,reencode=safari_optimize)
|
282
|
-
|
283
|
-
|
284
|
-
info_path = os.path.join(dirname, 'info.json')
|
323
|
+
info_path = os.path.join(video_directory, 'info.json')
|
285
324
|
if thumbnails:
|
286
|
-
info = get_thumbnails(
|
325
|
+
info = get_thumbnails(video_directory, info)
|
287
326
|
if audio:
|
288
327
|
try:
|
289
328
|
info = download_audio(directory, info)
|
@@ -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.81
|
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
|
@@ -8,6 +8,7 @@ abstract_webtools/soup_gui.py,sha256=n95YAps1R6DpMwR4UbthSqQby0C5WHUa9tsW-f2qpLg
|
|
8
8
|
abstract_webtools/url_grabber.py,sha256=pnCCev7ZIuM-6cAGTLmK5HfzZg_AX-fLcRpB6ZE70B8,10441
|
9
9
|
abstract_webtools/url_grabber_new.py,sha256=Oh2Kc0gBScCo0xpopNsg8JE5lIbPuzZVKM5f5GoZmw0,3454
|
10
10
|
abstract_webtools/managers/__init__.py,sha256=9pgy52NB-ONxLqoCRF52GZ6G7GM6Uc0-fgA1HvKcwxc,407
|
11
|
+
abstract_webtools/managers/allss\.py,sha256=Ha99RMD__i_1ouKDvQn9kkaaA9-sc6oZ7mCMq0dlb4I,305
|
11
12
|
abstract_webtools/managers/cipherManager.py,sha256=NHQGdR11eNSm-1H-GezD5dyQgsPTJwY5kczt8Sher2s,1621
|
12
13
|
abstract_webtools/managers/crawlManager.py,sha256=62Ej6AQC6-qXX_EWOmcJ2szNvEjmebFGugMz65HF1qI,12983
|
13
14
|
abstract_webtools/managers/crawlmgr2.py,sha256=PvHas-FSlp98osc-2so9zw-2c7amUMdwIj6tmc6Rl00,1910
|
@@ -25,7 +26,7 @@ abstract_webtools/managers/sslManager.py,sha256=C-QgQw9CW84uOE5kx2MPjC3RsLbE2JQq
|
|
25
26
|
abstract_webtools/managers/tlsAdapter.py,sha256=XZSMZz9EUOhv-h3_Waf6mjV1dA3oN_M_oWuoo4VZ_HE,1454
|
26
27
|
abstract_webtools/managers/urlManager.py,sha256=Dvf-TiSo5j_YjZS2Eq6lFfbhveneD6NA_wEE0xUXy_E,8858
|
27
28
|
abstract_webtools/managers/userAgentManager.py,sha256=cUaOlcCTzftVBCp9ZHwMXR9IB1wAE-03YSVwUBaIFLM,2514
|
28
|
-
abstract_webtools/managers/videoDownloader.py,sha256=
|
29
|
+
abstract_webtools/managers/videoDownloader.py,sha256=jQiSIZcE_1FhAaAbU24ZiNgZz0vaDhzB1CD-STeWS2Q,14196
|
29
30
|
abstract_webtools/managers/videoDownloader2.py,sha256=v3H6akdhvVWGrB-r35m3cp_-aKkNWadpfCiMylOnv6w,12748
|
30
31
|
abstract_webtools/managers/linkManager/__init__.py,sha256=NpfWNzvTLSfsIWSeLYIxPzeLHADk_grSx5rfgCeWERw,27
|
31
32
|
abstract_webtools/managers/linkManager/linkManager.py,sha256=roxOzOELca0rOlcMaJkTQHN3S0XF7dJihZmMq-uIXPQ,12184
|
@@ -37,7 +38,7 @@ abstract_webtools/managers/soupManager/soupManager.py,sha256=U3_o189-OWoBRaSCe2s
|
|
37
38
|
abstract_webtools/managers/urlManager/__init__.py,sha256=gaJCHeK91Z-eYsBnxgdhbIUten1-gbx-zqx70R6ag-Y,26
|
38
39
|
abstract_webtools/managers/urlManager/urlManager.py,sha256=vCFuLADmv3h7icaaoAsImGqb_49VizPY_ZvMl-C7PYk,7756
|
39
40
|
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.
|
41
|
+
abstract_webtools-0.1.6.81.dist-info/METADATA,sha256=T_ZLdr-uax5eSCw294J_O6Nr4jL2i8nVEzUObDNXnfo,16029
|
42
|
+
abstract_webtools-0.1.6.81.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
43
|
+
abstract_webtools-0.1.6.81.dist-info/top_level.txt,sha256=2DMJ7RmjTcjCsa-uwAV0K6eXXlIIkFDEjBLg_uyCmCI,18
|
44
|
+
abstract_webtools-0.1.6.81.dist-info/RECORD,,
|
File without changes
|
File without changes
|