warp-beacon 2.6.62__py3-none-any.whl → 2.6.63__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.
@@ -1,2 +1,2 @@
1
- __version__ = "2.6.62"
1
+ __version__ = "2.6.63"
2
2
 
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import time
2
3
  import pathlib
3
4
  from abc import ABC, abstractmethod
4
5
  from typing import Callable, Union
@@ -77,6 +78,20 @@ class ScraperAbstract(ABC):
77
78
  logging.exception(e)
78
79
 
79
80
  return ''
81
+
82
+ def rename_local_file(self, filename: str) -> str:
83
+ if not os.path.exists(filename):
84
+ raise NameError("No file provided")
85
+ path_info = pathlib.Path(filename)
86
+ ext = path_info.suffix
87
+ #old_filename = path_info.stem
88
+ time_name = str(time.time()).replace('.', '_')
89
+ new_filename = f"{time_name}{ext}"
90
+ new_filepath = f"{os.path.dirname(filename)}/{new_filename}"
91
+
92
+ os.rename(filename, new_filepath)
93
+
94
+ return new_filepath
80
95
 
81
96
  def force_ipv6(self) -> None:
82
97
  def allowed_gai_family():
@@ -227,7 +227,7 @@ class InstagramScraper(ScraperAbstract):
227
227
  def download_video(self, url: str, media_info: Media) -> dict:
228
228
  self.cl.request_timeout = int(os.environ.get("IG_REQUEST_TIMEOUT", default=60))
229
229
  path = self.download_hndlr(self.cl.video_download_by_url, url, folder='/tmp')
230
- return {"local_media_path": str(path), "canonical_name": self.extract_canonical_name(media_info), \
230
+ return {"local_media_path": self.rename_local_file(str(path)), "canonical_name": self.extract_canonical_name(media_info), \
231
231
  "media_type": JobType.VIDEO, "last_pk": media_info.pk, \
232
232
  "media_info": {"duration": round(media_info.video_duration)}}
233
233
 
@@ -238,7 +238,7 @@ class InstagramScraper(ScraperAbstract):
238
238
  path = InstagramScraper.convert_webp_to_png(path)
239
239
  if ".heic" in path_lowered:
240
240
  path = InstagramScraper.convert_heic_to_png(path)
241
- return {"local_media_path": path, "canonical_name": self.extract_canonical_name(media_info), "media_type": JobType.IMAGE, "last_pk": media_info.pk}
241
+ return {"local_media_path": self.rename_local_file(path), "canonical_name": self.extract_canonical_name(media_info), "media_type": JobType.IMAGE, "last_pk": media_info.pk}
242
242
 
243
243
  def download_story(self, story_info: Story) -> dict:
244
244
  path, media_type, media_info = "", JobType.UNKNOWN, {}
@@ -263,7 +263,7 @@ class InstagramScraper(ScraperAbstract):
263
263
  media_type = JobType.VIDEO
264
264
  media_info["duration"] = story_info.video_duration
265
265
 
266
- return {"local_media_path": path, "media_type": media_type, "media_info": media_info, "effective_url": effective_url}
266
+ return {"local_media_path": self.rename_local_file(path), "media_type": media_type, "media_info": media_info, "effective_url": effective_url}
267
267
 
268
268
  def download_stories(self, stories: list[Story]) -> dict:
269
269
  chunks = []
@@ -4,7 +4,6 @@ import json
4
4
  import logging
5
5
  import math
6
6
  import os
7
- import pathlib
8
7
  import socket
9
8
  import ssl
10
9
  import time
@@ -65,20 +64,6 @@ class YoutubeAbstract(ScraperAbstract):
65
64
  logging.exception(e)
66
65
 
67
66
  return 0
68
-
69
- def rename_local_file(self, filename: str) -> str:
70
- if not os.path.exists(filename):
71
- raise NameError("No file provided")
72
- path_info = pathlib.Path(filename)
73
- ext = path_info.suffix
74
- #old_filename = path_info.stem
75
- time_name = str(time.time()).replace('.', '_')
76
- new_filename = f"{time_name}{ext}"
77
- new_filepath = f"{os.path.dirname(filename)}/{new_filename}"
78
-
79
- os.rename(filename, new_filepath)
80
-
81
- return new_filepath
82
67
 
83
68
  def get_video_id(self, url: str) -> Optional[str]:
84
69
  parsed_url = urlparse(url)
@@ -81,11 +81,11 @@ class ProgressBar(object):
81
81
  try:
82
82
  #await self.client.edit_message_caption(chat_id, message_id, f"{pbar} <b>{operation}</b> {label}", ParseMode.HTML)
83
83
  # we don't need to wait completion, waste of time and resources
84
- text = f"{pbar}\n<b>{operation}</b>"
84
+ text = f"{pbar}\n{operation}"
85
85
  if label:
86
- text += f"\n{label}"
86
+ text += f"\n<code>{label}</code>"
87
87
  if total:
88
- text += f" {self.format_size_si(total)}"
88
+ text += f" <b>{self.format_size_si(total)}</b>"
89
89
  task = self.client.loop.create_task(
90
90
  self.client.edit_message_caption(chat_id, message_id, text, ParseMode.HTML)
91
91
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.6.62
3
+ Version: 2.6.63
4
4
  Summary: Telegram bot for expanding external media links
5
5
  Home-page: https://github.com/sb0y/warp_beacon
6
6
  Author: Andrey Bagrintsev
@@ -4,7 +4,7 @@ var/warp_beacon/accounts.json,sha256=OsXdncs6h88xrF_AP6_WDCK1waGBn9SR-uYdIeK37GM
4
4
  var/warp_beacon/placeholder.gif,sha256=cE5CGJVaop4Sx21zx6j4AyoHU0ncmvQuS2o6hJfEH88,6064
5
5
  var/warp_beacon/proxies.json,sha256=VnjlQDXumOEq72ZFjbh6IqHS1TEHqn8HPYAZqWCeSIA,95
6
6
  warp_beacon/__init__.py,sha256=_rThNODmz0nDp_n4mWo_HKaNFE5jk1_7cRhHyYaencI,163
7
- warp_beacon/__version__.py,sha256=09IBOKxWe42LVlV24GfMJOBKt0hFlSRUhV5Q52nzG_Y,24
7
+ warp_beacon/__version__.py,sha256=0KBAGOPAv97q-WuHyu9Q4j_MnJB9l3T_j_629z8mY2M,24
8
8
  warp_beacon/warp_beacon.py,sha256=ED43vNzdjDUJ_9qLCbri0bjWLWEJ69BENGj9i7G6AvM,342
9
9
  warp_beacon/yt_auth.py,sha256=GUTKqYr_tzDC-07Lx_ahWXSag8EyLxXBUnQbDBIkEmk,6022
10
10
  warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -23,7 +23,7 @@ warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
23
23
  warp_beacon/scheduler/instagram_human.py,sha256=0LaRUu0MBBuEOQeFzuq22HIYfJL9pTK_7udsXfef0Fk,8204
24
24
  warp_beacon/scheduler/scheduler.py,sha256=9OCh7Ta4wY_aTHGAOOZmaKXg56Ftx1N_aV1g6E3ZLKA,4941
25
25
  warp_beacon/scraper/__init__.py,sha256=buXmGcJnwCi0qGZAh3srcSbww0XvKyTACp_DW11e86Q,20225
26
- warp_beacon/scraper/abstract.py,sha256=Hr8BrLLG4AhVluKO50ryXy2T96goJ83ahXKRXnnQBn8,3110
26
+ warp_beacon/scraper/abstract.py,sha256=hRyBbdZ5HK7QyyXlbFAgk3FZe2SIil0WBZ9vJziZv_s,3554
27
27
  warp_beacon/scraper/account_selector.py,sha256=-tAbOIbM7sC9QafsgSe64RCWXewRO-RehEYsYSB3HGo,9727
28
28
  warp_beacon/scraper/exceptions.py,sha256=EKwoF0oH2xZWbNU-v8DOaWK5skKwa3s1yTIBdlcfMpc,1452
29
29
  warp_beacon/scraper/fail_handler.py,sha256=zcPK3ZVEsu6JmHYcWP7L3naTRK3gWFVRkpP84VBOtJs,964
@@ -31,9 +31,9 @@ warp_beacon/scraper/link_resolver.py,sha256=Rc9ZuMyOo3iPywDHwjngy-WRQ2SXhJwxcg-5
31
31
  warp_beacon/scraper/utils.py,sha256=xJfCVhiLjVPoFVupE10sTzX7UpgNWbx2EeYIsoYXGDk,43
32
32
  warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  warp_beacon/scraper/instagram/captcha.py,sha256=9UYziuqB3Tsat_ET6ex-cnZDbi6yCnsXHSpmE8MuUHk,4651
34
- warp_beacon/scraper/instagram/instagram.py,sha256=f4B_pHk99C9EGWRXCINCW7NeOA0gSuVryknGHLNyMCI,15827
34
+ warp_beacon/scraper/instagram/instagram.py,sha256=hNknsMVEOG9pQw5hnXGbqvRNAbp5gJXKdIny6drF7rA,15899
35
35
  warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- warp_beacon/scraper/youtube/abstract.py,sha256=cSvFOZAZzRNwVTlSQ9EK7kf3RzdwSvw8HBfbDv94qPQ,13578
36
+ warp_beacon/scraper/youtube/abstract.py,sha256=sU1inNjg0dv96ae8pZennYfczE4u227RcpgulOtTNLw,13132
37
37
  warp_beacon/scraper/youtube/music.py,sha256=5AeSBQyUgVCJT2hoBCV2WvlyuV9US09SYJhmBG_P9F8,2755
38
38
  warp_beacon/scraper/youtube/shorts.py,sha256=1GtoYUlxAwcgSQcn80u5ehNJytH5AN5dPOicmX-XD8E,1705
39
39
  warp_beacon/scraper/youtube/youtube.py,sha256=x9v9p1coA9TvBhxjNAofGu4UBkAEdYPE2ePRnU-5tK0,7233
@@ -46,13 +46,13 @@ warp_beacon/telegram/download_status.py,sha256=SIWIKPjNJwl13VxBZcN-YKB0bzWqrMxhV
46
46
  warp_beacon/telegram/edit_message.py,sha256=L6YXPuR87aLBly0yUjS4XjXUbOtUQlrKEPKhzBVcjdI,5417
47
47
  warp_beacon/telegram/handlers.py,sha256=uvR6TPHSqdSxigp3wR-ewiE6t3TvVcbVLVcYGwkgD2s,9559
48
48
  warp_beacon/telegram/placeholder_message.py,sha256=wN9-BRiyrtHG-EvXtZkGJHt2CX71munQ57ITttjt0mw,6400
49
- warp_beacon/telegram/progress_bar.py,sha256=hVr-VmfVadRTRtzfChqCigCKT_4KRlKqT-dJxi5U9dc,3590
49
+ warp_beacon/telegram/progress_bar.py,sha256=Af5iN3Sng14dVMJhd4vxLF4tJPEygaHii230FSeoSx8,3603
50
50
  warp_beacon/telegram/progress_file_reader.py,sha256=e3equyNKlKs764AD-iE9QRsh3YDHTzP78Mx5tdvPPWs,969
51
51
  warp_beacon/telegram/utils.py,sha256=1Lq67aRylVJzbwSyvAgjPAGjJZFATkICvAj3TJGuJiM,4635
52
52
  warp_beacon/uploader/__init__.py,sha256=j3qcuKhpchseZLGzSsSiogqe6WdMbkK8d3I-ConhNRs,5687
53
- warp_beacon-2.6.62.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
54
- warp_beacon-2.6.62.dist-info/METADATA,sha256=LpNvKWdS3weCwLpmT7Q9bjhYgrQ_SIYzMf0aJQ_abs0,22706
55
- warp_beacon-2.6.62.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
56
- warp_beacon-2.6.62.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
57
- warp_beacon-2.6.62.dist-info/top_level.txt,sha256=2x4wBJ_HeeBt6Bsdu9C4tItXWqH8spX8jGSHpoL0IMw,1334
58
- warp_beacon-2.6.62.dist-info/RECORD,,
53
+ warp_beacon-2.6.63.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
54
+ warp_beacon-2.6.63.dist-info/METADATA,sha256=fGrV2iZU4vHbgPrlbTKdoxgPLrq7wsEB_M2kY_glNCg,22706
55
+ warp_beacon-2.6.63.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
56
+ warp_beacon-2.6.63.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
57
+ warp_beacon-2.6.63.dist-info/top_level.txt,sha256=2x4wBJ_HeeBt6Bsdu9C4tItXWqH8spX8jGSHpoL0IMw,1334
58
+ warp_beacon-2.6.63.dist-info/RECORD,,