warp-beacon 2.7.29__tar.gz → 2.7.31__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 (70) hide show
  1. {warp_beacon-2.7.29/warp_beacon.egg-info → warp_beacon-2.7.31}/PKG-INFO +1 -1
  2. warp_beacon-2.7.31/warp_beacon/__version__.py +2 -0
  3. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scheduler/instagram_human.py +16 -9
  4. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/__init__.py +3 -3
  5. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/fail_handler.py +3 -2
  6. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/handlers.py +11 -4
  7. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/uploader/__init__.py +5 -4
  8. {warp_beacon-2.7.29 → warp_beacon-2.7.31/warp_beacon.egg-info}/PKG-INFO +1 -1
  9. warp_beacon-2.7.29/warp_beacon/__version__.py +0 -2
  10. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/LICENSE +0 -0
  11. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/MANIFEST.in +0 -0
  12. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/README.md +0 -0
  13. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/assets/cc-group-black.png +0 -0
  14. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/assets/placeholder.gif +0 -0
  15. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/etc/.gitignore +0 -0
  16. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/etc/accounts.json +0 -0
  17. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/etc/proxies.json +0 -0
  18. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/etc/warp_beacon.conf +0 -0
  19. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/etc/warp_beacon.service +0 -0
  20. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/pyproject.toml +0 -0
  21. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/setup.cfg +0 -0
  22. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/setup.py +0 -0
  23. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/__init__.py +0 -0
  24. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/compress/__init__.py +0 -0
  25. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/compress/video.py +0 -0
  26. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/jobs/__init__.py +0 -0
  27. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/jobs/abstract.py +0 -0
  28. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/jobs/download_job.py +0 -0
  29. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/jobs/types.py +0 -0
  30. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/jobs/upload_job.py +0 -0
  31. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/mediainfo/__init__.py +0 -0
  32. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/mediainfo/abstract.py +0 -0
  33. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/mediainfo/audio.py +0 -0
  34. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/mediainfo/silencer.py +0 -0
  35. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/mediainfo/video.py +0 -0
  36. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scheduler/__init__.py +0 -0
  37. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scheduler/scheduler.py +0 -0
  38. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/abstract.py +0 -0
  39. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/account_selector.py +0 -0
  40. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/exceptions.py +0 -0
  41. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/instagram/__init__.py +0 -0
  42. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/instagram/captcha.py +0 -0
  43. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/instagram/instagram.py +0 -0
  44. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/instagram/wb_instagrapi.py +0 -0
  45. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/link_resolver.py +0 -0
  46. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/utils.py +0 -0
  47. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/youtube/__init__.py +0 -0
  48. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/youtube/abstract.py +0 -0
  49. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/youtube/music.py +0 -0
  50. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/youtube/shorts.py +0 -0
  51. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/scraper/youtube/youtube.py +0 -0
  52. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/storage/__init__.py +0 -0
  53. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/storage/mongo.py +0 -0
  54. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/__init__.py +0 -0
  55. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/bot.py +0 -0
  56. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/caption_shortener.py +0 -0
  57. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/download_status.py +0 -0
  58. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/edit_message.py +0 -0
  59. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/placeholder_message.py +0 -0
  60. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/progress_bar.py +0 -0
  61. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/progress_file_reader.py +0 -0
  62. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/types.py +0 -0
  63. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/telegram/utils.py +0 -0
  64. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/warp_beacon.py +0 -0
  65. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon/yt_auth.py +0 -0
  66. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon.egg-info/SOURCES.txt +0 -0
  67. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon.egg-info/dependency_links.txt +0 -0
  68. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon.egg-info/entry_points.txt +0 -0
  69. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/warp_beacon.egg-info/requires.txt +0 -0
  70. {warp_beacon-2.7.29 → warp_beacon-2.7.31}/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.7.29
3
+ Version: 2.7.31
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.7.31"
2
+
@@ -75,16 +75,23 @@ class InstagramHuman(object):
75
75
  if not raw_tray:
76
76
  logging.info("No stories tray available.")
77
77
  return
78
- logging.info("raw_tray: %s", str(raw_tray))
78
+ #logging.info("raw_tray: %s", str(raw_tray))
79
79
  tray = raw_tray.get("tray", [])
80
- for user_story in tray:
81
- user = user_story["user"]
82
- user_id = user["pk"]
83
- _stories = self.scrapler.download_hndlr(self.scrapler.cl.user_stories, user_id)
84
- self.operations_count += 1
85
- if _stories:
86
- stories.extend(_stories)
87
- self.random_pause()
80
+ if tray:
81
+ reels_tray = []
82
+ target_len = random.randint(1, 5)
83
+ for el in tray[:target_len]:
84
+ user = el["user"]
85
+ user_id = user["pk"]
86
+ if el.get("seen", 0) == 0:
87
+ reels_tray.append({"user_id": user_id})
88
+
89
+ for el in reels_tray:
90
+ _stories = self.scrapler.download_hndlr(self.scrapler.cl.user_stories, el["user_id"])
91
+ self.operations_count += 1
92
+ if _stories:
93
+ stories.extend(_stories)
94
+ self.random_pause()
88
95
 
89
96
  if not stories:
90
97
  return
@@ -79,8 +79,6 @@ class AsyncDownloader(object):
79
79
 
80
80
  def try_next_account(self, selector: AccountSelector, job: DownloadJob, report_error: str = None) -> None:
81
81
  logging.warning("Switching account!")
82
- if job.account_switches > self.acc_selector.count_service_accounts(job.job_origin):
83
- raise AllAccountsFailed("All config accounts failed!", job=job, reason=report_error)
84
82
  if report_error:
85
83
  selector.bump_acc_fail(report_error)
86
84
  selector.next()
@@ -112,6 +110,9 @@ class AsyncDownloader(object):
112
110
  replay=True
113
111
  ))
114
112
  continue
113
+
114
+ if job.account_switches > self.acc_selector.count_service_accounts(job.job_origin):
115
+ raise AllAccountsFailed("All config accounts failed!", job=job)
115
116
  if not job.in_process:
116
117
  if job.job_postponed_until > 0:
117
118
  if (job.job_postponed_until - time.time()) > 0:
@@ -403,7 +404,6 @@ class AsyncDownloader(object):
403
404
  else:
404
405
  logging.info("Job already in work in parallel worker. Redirecting job to upload worker.")
405
406
  self.uploader.queue_task(job.to_upload_job())
406
-
407
407
  except AllAccountsFailed as e:
408
408
  self.send_message_to_admin(
409
409
  f"Task <code>{job.job_id}</code> failed. URL: '{job.url}'. Reason: '<b>AllAccountsFailed</b>'."
@@ -28,13 +28,14 @@ class FailHandler(object):
28
28
  logging.exception(e)
29
29
  return db_id
30
30
 
31
- def get_failed_jobs(self) -> list:
31
+ def get_failed_jobs(self, clean: bool = True) -> list:
32
32
  ret = []
33
33
  try:
34
34
  cursor = self.db.find()
35
35
  for document in cursor:
36
36
  ret.append(pickle.loads(document["job_data"]))
37
- self.db.delete_many({})
37
+ if clean:
38
+ self.db.delete_many({})
38
39
  except Exception as e:
39
40
  logging.error("Failed to get failed jobs!")
40
41
  logging.exception(e)
@@ -1,6 +1,7 @@
1
- import os
1
+ import logging
2
+
2
3
  from pyrogram import Client
3
- from pyrogram.types import Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
4
+ from pyrogram.types import Message, CallbackQuery#, InlineKeyboardButton, InlineKeyboardMarkup
4
5
  from pyrogram.enums import ChatType, ParseMode
5
6
  from pyrogram.types import BotCommand
6
7
 
@@ -13,8 +14,8 @@ from warp_beacon.jobs.upload_job import UploadJob
13
14
  from warp_beacon.jobs import Origin
14
15
  from warp_beacon.jobs.types import JobType
15
16
  from warp_beacon.scraper.link_resolver import LinkResolver
16
-
17
- import logging
17
+ from warp_beacon.scraper.fail_handler import FailHandler
18
+ from warp_beacon.storage.mongo import DBClient
18
19
 
19
20
  class Handlers(object):
20
21
  storage = None
@@ -24,6 +25,12 @@ class Handlers(object):
24
25
  def __init__(self, bot: "Bot") -> None:
25
26
  self.bot = bot
26
27
  self.storage = bot.storage
28
+ # add uploader callbacks to handle service restart
29
+ for job in FailHandler(DBClient()).get_failed_jobs(clean=False):
30
+ self.bot.uploader.add_callback(
31
+ job.placeholder_message_id,
32
+ self.upload_wrapper
33
+ )
27
34
 
28
35
  async def help(self, _: Client, message: Message) -> None:
29
36
  """Send a message when the command /help is issued."""
@@ -50,10 +50,11 @@ class AsyncUploader(object):
50
50
  self.threads.append(thread)
51
51
 
52
52
  def add_callback(self, message_id: int, callback: Callable) -> None:
53
- async def callback_wrap(*args, **kwargs) -> None:
54
- await callback(*args, **kwargs)
55
- #self.remove_callback(message_id)
56
- self.callbacks[message_id] = {"callback": callback_wrap}
53
+ if message_id not in self.callbacks:
54
+ async def callback_wrap(*args, **kwargs) -> None:
55
+ await callback(*args, **kwargs)
56
+ #self.remove_callback(message_id)
57
+ self.callbacks[message_id] = {"callback": callback_wrap}
57
58
 
58
59
  def remove_callback(self, message_id: int) -> None:
59
60
  if message_id in self.callbacks:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.7.29
3
+ Version: 2.7.31
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.7.29"
2
-
File without changes
File without changes
File without changes
File without changes
File without changes