warp-beacon 2.6.53__tar.gz → 2.6.55__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.
Files changed (67) hide show
  1. {warp_beacon-2.6.53/warp_beacon.egg-info → warp_beacon-2.6.55}/PKG-INFO +1 -1
  2. warp_beacon-2.6.55/warp_beacon/__version__.py +2 -0
  3. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/abstract.py +10 -10
  4. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/instagram/instagram.py +3 -0
  5. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/youtube/abstract.py +2 -4
  6. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/progress_bar.py +39 -17
  7. {warp_beacon-2.6.53 → warp_beacon-2.6.55/warp_beacon.egg-info}/PKG-INFO +1 -1
  8. warp_beacon-2.6.53/warp_beacon/__version__.py +0 -2
  9. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/LICENSE +0 -0
  10. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/MANIFEST.in +0 -0
  11. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/README.md +0 -0
  12. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/assets/placeholder.gif +0 -0
  13. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/etc/.gitignore +0 -0
  14. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/etc/accounts.json +0 -0
  15. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/etc/proxies.json +0 -0
  16. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/etc/warp_beacon.conf +0 -0
  17. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/etc/warp_beacon.service +0 -0
  18. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/pyproject.toml +0 -0
  19. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/setup.cfg +0 -0
  20. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/setup.py +0 -0
  21. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/__init__.py +0 -0
  22. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/compress/__init__.py +0 -0
  23. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/compress/video.py +0 -0
  24. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/jobs/__init__.py +0 -0
  25. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/jobs/abstract.py +0 -0
  26. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/jobs/download_job.py +0 -0
  27. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/jobs/types.py +0 -0
  28. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/jobs/upload_job.py +0 -0
  29. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/mediainfo/__init__.py +0 -0
  30. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/mediainfo/abstract.py +0 -0
  31. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/mediainfo/audio.py +0 -0
  32. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/mediainfo/silencer.py +0 -0
  33. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/mediainfo/video.py +0 -0
  34. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scheduler/__init__.py +0 -0
  35. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scheduler/instagram_human.py +0 -0
  36. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scheduler/scheduler.py +0 -0
  37. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/__init__.py +0 -0
  38. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/account_selector.py +0 -0
  39. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/exceptions.py +0 -0
  40. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/fail_handler.py +0 -0
  41. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/instagram/__init__.py +0 -0
  42. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/instagram/captcha.py +0 -0
  43. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/link_resolver.py +0 -0
  44. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/utils.py +0 -0
  45. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/youtube/__init__.py +0 -0
  46. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/youtube/music.py +0 -0
  47. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/youtube/shorts.py +0 -0
  48. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/scraper/youtube/youtube.py +0 -0
  49. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/storage/__init__.py +0 -0
  50. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/storage/mongo.py +0 -0
  51. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/__init__.py +0 -0
  52. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/bot.py +0 -0
  53. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/caption_shortener.py +0 -0
  54. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/download_status.py +0 -0
  55. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/edit_message.py +0 -0
  56. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/handlers.py +0 -0
  57. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/placeholder_message.py +0 -0
  58. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/progress_file_reader.py +0 -0
  59. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/telegram/utils.py +0 -0
  60. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/uploader/__init__.py +0 -0
  61. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/warp_beacon.py +0 -0
  62. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon/yt_auth.py +0 -0
  63. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon.egg-info/SOURCES.txt +0 -0
  64. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon.egg-info/dependency_links.txt +0 -0
  65. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon.egg-info/entry_points.txt +0 -0
  66. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon.egg-info/requires.txt +0 -0
  67. {warp_beacon-2.6.53 → warp_beacon-2.6.55}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.6.53
3
+ Version: 2.6.55
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
@@ -0,0 +1,2 @@
1
+ __version__ = "2.6.55"
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,31 +35,52 @@ 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] Uploaded to Telegram %d%%", label or 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)
58
- except MessageNotModified:
59
- logging.warning("bad_request_400.MessageNotModified")
74
+ #await self.client.edit_message_caption(chat_id, message_id, f"{pbar} <b>{operation}</b> {label}", ParseMode.HTML)
75
+ # we don't need to wait completion, waste of time and resources
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")
60
82
  except Exception as e:
61
- logging.warning("An error occurred while updating progress bar")
83
+ logging.warning("An error occurred while setup task to update progress bar")
62
84
  logging.exception(e)
63
85
  if total > 0:
64
86
  self._next_threshold += 20
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.6.53
3
+ Version: 2.6.55
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
@@ -1,2 +0,0 @@
1
- __version__ = "2.6.53"
2
-
File without changes
File without changes
File without changes
File without changes
File without changes