warp-beacon 2.6.54__py3-none-any.whl → 2.6.56__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.54"
1
+ __version__ = "2.6.56"
2
2
 
@@ -12,16 +12,16 @@ from PIL import Image
12
12
  from pillow_heif import register_heif_opener
13
13
 
14
14
  class ScraperAbstract(ABC):
15
- original_gai_family = None
16
- send_message_to_admin_func: Callable = lambda: None
17
- request_yt_auth: Callable = lambda: None
18
- status_pipe: multiprocessing.connection.Connection = None
19
- auth_event = None
20
- account = None
21
- account_index = 0
22
- proxy = None
23
-
24
- def __init__(self, account: tuple, proxy: dict=None) -> None:
15
+ def __init__(self, account: tuple, proxy: dict = None) -> None:
16
+ self.original_gai_family = None
17
+ self.send_message_to_admin_func: Callable = lambda: None
18
+ self.request_yt_auth: Callable = lambda: None
19
+ self.status_pipe: multiprocessing.connection.Connection = None
20
+ self.auth_event = None
21
+ self.account = None
22
+ self.account_index = 0
23
+ self.proxy = None
24
+ self.job = None
25
25
  self._gai_lock = multiprocessing.Lock()
26
26
  self.account_index = account[0]
27
27
  self.account = account[1]
@@ -304,10 +304,13 @@ class InstagramScraper(ScraperAbstract):
304
304
 
305
305
  def download(self, job: DownloadJob) -> Optional[list[dict]]:
306
306
  res = []
307
+ self.job = job
307
308
  while True:
308
309
  try:
309
310
  scrap_type, media_id = self.scrap(job.url)
310
311
  if scrap_type == "media":
312
+ #self.status_pipe.send({"action": "report_download_status", "current": 0, "total": 0,
313
+ # "message_id": self.job.placeholder_message_id, "chat_id": self.job.chat_id, "label": "Collection meta information ..."})
311
314
  media_info = self.download_hndlr(self.cl.media_info, media_id, use_cache=False)
312
315
  logging.info("media_type is '%d', product_type is '%s'", media_info.media_type, media_info.product_type)
313
316
  if media_info.media_type == 2 and media_info.product_type == "clips": # Reels
@@ -35,8 +35,6 @@ class YoutubeAbstract(ScraperAbstract):
35
35
  DOWNLOAD_DIR = "/tmp"
36
36
  YT_SESSION_FILE = '/var/warp_beacon/yt_session_%d.json'
37
37
 
38
- job = None
39
-
40
38
  def __init__(self, account: tuple, proxy: dict=None) -> None:
41
39
  super().__init__(account, proxy)
42
40
  self._download_progress_threshold = 20
@@ -321,10 +319,10 @@ class YoutubeAbstract(ScraperAbstract):
321
319
 
322
320
  return yt_dlp.YoutubeDL(ydl_opts)
323
321
 
324
- def _download(self, _: str, timeout: int = 60) -> list:
322
+ def _download(self, url: str, session: bool = True, thumbnail: Optional[io.BytesIO] = None, timeout: int = 60) -> list:
325
323
  raise NotImplementedError("You should to implement _download method")
326
324
 
327
- def _download_yt_dlp(self, _: str, timeout: int = 60) -> list:
325
+ def _download_yt_dlp(self, url: str, thumbnail: Optional[io.BytesIO] = None, timeout: int = 60) -> list:
328
326
  raise NotImplementedError("You should to implement _download_yt_dlp method")
329
327
 
330
328
  def download(self, job: DownloadJob) -> list:
@@ -1,5 +1,6 @@
1
1
  import logging
2
2
 
3
+ import asyncio
3
4
  import hashlib
4
5
 
5
6
  from pyrogram.enums import ParseMode
@@ -34,41 +35,50 @@ class ProgressBar(object):
34
35
  percent = frac * 100
35
36
  return f"<b>[{pbar}] {round(percent)}%</b>"
36
37
 
37
- def make_emoji_progress_bar(self, current: int, total: int, length: int = 10) -> str:
38
+ def make_emoji_progress_bar(self, percent: int, length: int = 10) -> str:
38
39
  """
39
- Returns string:
40
- [🟩🟩🟩⬜️⬜️⬜️⬜️⬜️⬜️⬜️] 30%
41
- length — common number of emoji cells
40
+ Builds an emoji progress bar.
41
+
42
+ Args:
43
+ percent: int from 0 to 100
44
+ length: total number of emoji cells
45
+
46
+ Returns:
47
+ String like "[🟩🟩🟩⬜️⬜️⬜️⬜️⬜️⬜️⬜️] 30%"
42
48
  """
43
- frac = (current / total) if total else 0
44
- filled_count = int(frac * length)
45
- empty_count = length - filled_count
46
- pbar = "🟩" * filled_count + "⬜️" * empty_count
47
- percent = frac * 100
48
- return f"[{pbar}] {round(percent)}%"
49
+ filled = int(percent * length / 100 + 0.5)
50
+ empty = length - filled
51
+ bar = "🟩" * filled + "⬜️" * empty
52
+ return f"[{bar}] {percent}%"
53
+
54
+ def _on_edit_done(self, task: asyncio.Task) -> None:
55
+ exc = task.exception()
56
+ if not exc:
57
+ return
58
+ if isinstance(exc, MessageNotModified):
59
+ logging.warning("bad_request_400.MessageNotModified")
60
+ else:
61
+ logging.exception("Error in edit_message_caption", exc_info=exc)
49
62
 
50
63
  async def progress_callback(self, current: int, total: int, chat_id: int | str, message_id: int, operation: str, label: str = "") -> None:
51
- percent = current * 100 / (total or 1)
64
+ if self.complete:
65
+ return
66
+ percent = 0
67
+ if total:
68
+ percent = round(current * 100 / (total or 1))
52
69
  if total == 0 or percent >= self._next_threshold:
53
70
  #pbar = self.make_progress_bar(percent, 100, 25)
54
- pbar = self.make_emoji_progress_bar(percent, 100, 14)
55
- logging.info("[%s] Operation: %s %d%%", label or operation, operation, percent)
71
+ pbar = self.make_emoji_progress_bar(percent, 14)
72
+ logging.info("[%s] Operation: %s %d%%", label or operation, operation, round(percent))
56
73
  try:
57
- #await self.client.edit_message_caption(chat_id, message_id, f"{pbar} <b>{operation}</b> {label}", ParseMode.HTML)
74
+ await self.client.edit_message_caption(chat_id, message_id, f"{pbar} <b>{operation}</b> {label}", ParseMode.HTML)
58
75
  # we don't need to wait completion, waste of time and resources
59
- task = self.client.loop.create_task(
60
- self.client.edit_message_caption(chat_id, message_id, f"{pbar} <b>{operation}</b> {label}", ParseMode.HTML)
61
- )
62
- task.add_done_callback(
63
- lambda t: (
64
- (exc := t.exception()) and
65
- (isinstance(exc, MessageNotModified)
66
- and logging.warning("bad_request_400.MessageNotModified")
67
- or logging.exception("Error in edit_message_caption", exc_info=exc))
68
- )
69
- )
70
- #except MessageNotModified:
71
- #logging.warning("bad_request_400.MessageNotModified")
76
+ #task = self.client.loop.create_task(
77
+ # self.client.edit_message_caption(chat_id, message_id, f"{pbar} <b>{operation}</b> {label}", ParseMode.HTML)
78
+ #)
79
+ #task.add_done_callback(self._on_edit_done)
80
+ except MessageNotModified:
81
+ logging.warning("bad_request_400.MessageNotModified")
72
82
  except Exception as e:
73
83
  logging.warning("An error occurred while setup task to update progress bar")
74
84
  logging.exception(e)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.6.54
3
+ Version: 2.6.56
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=n77-uVboGYOpzowD-4XvQrBJEhAfKpJcTLztmdsI4qA,24
7
+ warp_beacon/__version__.py,sha256=AdfnWlDMAuzaQu721-Vo_OBbQvxz9el6tXYNoDcyzz4,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=wwmk2L1S4H9la8x74eN4svdG-BgOdE1tKrOv7jjFhXE,3043
26
+ warp_beacon/scraper/abstract.py,sha256=Hr8BrLLG4AhVluKO50ryXy2T96goJ83ahXKRXnnQBn8,3110
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=zbkF-1lU5lxJ_2m8i8mGRX0EQMLVSflsOafBM1FEC6s,15588
34
+ warp_beacon/scraper/instagram/instagram.py,sha256=f4B_pHk99C9EGWRXCINCW7NeOA0gSuVryknGHLNyMCI,15827
35
35
  warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- warp_beacon/scraper/youtube/abstract.py,sha256=KjtMb_5RJrAyLGz_BIBv-RdBRey6PnJX6jnOaJKsbTk,13485
36
+ warp_beacon/scraper/youtube/abstract.py,sha256=cSvFOZAZzRNwVTlSQ9EK7kf3RzdwSvw8HBfbDv94qPQ,13578
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=dV0mRIOkA8dU0ECsmC_rZ33XQhVnkW2nZ
46
46
  warp_beacon/telegram/edit_message.py,sha256=_452kXWn65qj9iPSvSmORbKXXTjJ0z6kBCxPcmKDrlM,5742
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=KKY5Sb3Mc-pfFDEAfsk3No8cY5N5Bo8Ng6yrnjBoRtE,3097
49
+ warp_beacon/telegram/progress_bar.py,sha256=F9pbCaUJqXzfqB8NJDU3LdvlS2hVtXk1_CRQKRdaRHU,3206
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.54.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
54
- warp_beacon-2.6.54.dist-info/METADATA,sha256=5EesVY6qf_28_QAvLcWGXBznvUvigu7JDlLui-OuLpc,22706
55
- warp_beacon-2.6.54.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
56
- warp_beacon-2.6.54.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
57
- warp_beacon-2.6.54.dist-info/top_level.txt,sha256=2x4wBJ_HeeBt6Bsdu9C4tItXWqH8spX8jGSHpoL0IMw,1334
58
- warp_beacon-2.6.54.dist-info/RECORD,,
53
+ warp_beacon-2.6.56.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
54
+ warp_beacon-2.6.56.dist-info/METADATA,sha256=-bxVw_NVY79M0_YzOyIZf7lvMKnsL1GugCUXdfz90wc,22706
55
+ warp_beacon-2.6.56.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
56
+ warp_beacon-2.6.56.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
57
+ warp_beacon-2.6.56.dist-info/top_level.txt,sha256=2x4wBJ_HeeBt6Bsdu9C4tItXWqH8spX8jGSHpoL0IMw,1334
58
+ warp_beacon-2.6.56.dist-info/RECORD,,