warp-beacon 2.2.39__tar.gz → 2.2.41__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 (54) hide show
  1. {warp_beacon-2.2.39/warp_beacon.egg-info → warp_beacon-2.2.41}/PKG-INFO +1 -1
  2. warp_beacon-2.2.41/warp_beacon/__version__.py +2 -0
  3. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/jobs/abstract.py +2 -0
  4. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/__init__.py +15 -4
  5. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/account_selector.py +3 -2
  6. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/exceptions.py +0 -2
  7. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/youtube/abstract.py +9 -5
  8. {warp_beacon-2.2.39 → warp_beacon-2.2.41/warp_beacon.egg-info}/PKG-INFO +1 -1
  9. warp_beacon-2.2.39/warp_beacon/__version__.py +0 -2
  10. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/LICENSE +0 -0
  11. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/MANIFEST.in +0 -0
  12. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/README.md +0 -0
  13. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/assets/placeholder.gif +0 -0
  14. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/etc/.gitignore +0 -0
  15. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/etc/accounts.json +0 -0
  16. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/etc/warp_beacon.conf +0 -0
  17. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/etc/warp_beacon.service +0 -0
  18. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/pyproject.toml +0 -0
  19. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/setup.cfg +0 -0
  20. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/setup.py +0 -0
  21. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/__init__.py +0 -0
  22. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/compress/__init__.py +0 -0
  23. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/compress/video.py +0 -0
  24. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/jobs/__init__.py +0 -0
  25. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/jobs/download_job.py +0 -0
  26. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/jobs/types.py +0 -0
  27. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/jobs/upload_job.py +0 -0
  28. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/mediainfo/__init__.py +0 -0
  29. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/mediainfo/abstract.py +0 -0
  30. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/mediainfo/audio.py +0 -0
  31. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/mediainfo/silencer.py +0 -0
  32. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/mediainfo/video.py +0 -0
  33. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scheduler/__init__.py +0 -0
  34. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scheduler/scheduler.py +0 -0
  35. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/abstract.py +0 -0
  36. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/instagram/__init__.py +0 -0
  37. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/instagram/instagram.py +0 -0
  38. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/youtube/__init__.py +0 -0
  39. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/youtube/music.py +0 -0
  40. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/youtube/shorts.py +0 -0
  41. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/scraper/youtube/youtube.py +0 -0
  42. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/storage/__init__.py +0 -0
  43. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/telegram/__init__.py +0 -0
  44. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/telegram/bot.py +0 -0
  45. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/telegram/handlers.py +0 -0
  46. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/telegram/placeholder_message.py +0 -0
  47. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/telegram/utils.py +0 -0
  48. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/uploader/__init__.py +0 -0
  49. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon/warp_beacon.py +0 -0
  50. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon.egg-info/SOURCES.txt +0 -0
  51. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon.egg-info/dependency_links.txt +0 -0
  52. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon.egg-info/entry_points.txt +0 -0
  53. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon.egg-info/requires.txt +0 -0
  54. {warp_beacon-2.2.39 → warp_beacon-2.2.41}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: warp_beacon
3
- Version: 2.2.39
3
+ Version: 2.2.41
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.2.41"
2
+
@@ -41,6 +41,7 @@ class JobSettings(TypedDict):
41
41
  session_validation: bool
42
42
  chat_type: ChatType
43
43
  account_admins: str
44
+ job_postponed_until: int
44
45
 
45
46
  class AbstractJob(ABC):
46
47
  job_id: uuid.UUID = None
@@ -74,6 +75,7 @@ class AbstractJob(ABC):
74
75
  session_validation: bool = False
75
76
  chat_type: ChatType = None
76
77
  account_admins: str = None
78
+ job_postponed_until: int = -1
77
79
 
78
80
  def __init__(self, **kwargs: Unpack[JobSettings]) -> None:
79
81
  if kwargs:
@@ -1,5 +1,6 @@
1
1
  import os
2
2
 
3
+ import time
3
4
  from typing import Optional
4
5
  import multiprocessing
5
6
  from queue import Empty
@@ -72,7 +73,7 @@ class AsyncDownloader(object):
72
73
  def try_next_account(self, selector: AccountSelector, job: DownloadJob, report_error: str = None) -> None:
73
74
  logging.warning("Switching account!")
74
75
  if job.account_switches > self.acc_selector.count_service_accounts(job.job_origin):
75
- raise AllAccountsFailed("All config accounts failed!")
76
+ raise AllAccountsFailed("All config accounts failed!", job=job, reason=report_error)
76
77
  if report_error:
77
78
  selector.bump_acc_fail(report_error)
78
79
  selector.next()
@@ -96,6 +97,12 @@ class AsyncDownloader(object):
96
97
  logging.warning("Unknown task origin! Skipping.")
97
98
  continue
98
99
  if not job.in_process:
100
+ if job.job_postponed_until > 0:
101
+ if job.job_postponed_until - time.time() > 0:
102
+ logging.warning("Job '%s' is postponed, rescheduling", job.url)
103
+ time.sleep(2)
104
+ self.job_queue.put(job)
105
+ continue
99
106
  actor = None
100
107
  self.acc_selector.set_module(job.job_origin)
101
108
  if job.job_origin is Origin.INSTAGRAM:
@@ -182,7 +189,7 @@ class AsyncDownloader(object):
182
189
  self.send_message_to_admin(
183
190
  f"Captcha required for account #{acc_index}, login: '{acc_data.get('login', 'unknown')}'."
184
191
  )
185
- self.try_next_account(selector, job)
192
+ self.try_next_account(selector, job, report_error="captcha")
186
193
  self.job_queue.put(job)
187
194
  break
188
195
  except YotubeLiveError as e:
@@ -208,12 +215,16 @@ class AsyncDownloader(object):
208
215
  logging.error("All accounts failed!")
209
216
  logging.exception(e)
210
217
  self.send_message_to_admin(
211
- f"Task `{job.job_id}` failed. URL: '{job.url}'. Reason: '**AllAccountsFailed**'."
218
+ f"Task `{e.job.job_id}` failed. URL: '{e.job.url}'. Reason: '**AllAccountsFailed**'."
212
219
  )
213
- self.uploader.queue_task(job.to_upload_job(
220
+ self.uploader.queue_task(e.job.to_upload_job(
214
221
  job_failed=True,
215
222
  job_failed_msg="All bot accounts failed to download content. Bot administrator noticed about the issue.")
216
223
  )
224
+ if e.job.job_origin == Origin.INSTAGRAM:
225
+ self.try_next_account(selector, job, report_error="captcha")
226
+ e.job.job_timeout = time.time() + 300
227
+ self.job_queue.put(e.job)
217
228
  break
218
229
  except (UnknownError, Exception) as e:
219
230
  logging.warning("UnknownError occurred!")
@@ -56,7 +56,7 @@ class AccountSelector(object):
56
56
  if module_name not in self.accounts_meta_data:
57
57
  self.accounts_meta_data[module_name] = []
58
58
  for index, _ in enumerate(lst):
59
- self.accounts_meta_data[module_name].insert(index, {"auth_fails": 0, "rate_limits": 0})
59
+ self.accounts_meta_data[module_name].insert(index, {"auth_fails": 0, "rate_limits": 0, "cathcha": 0})
60
60
 
61
61
  def set_module(self, module_origin: Origin) -> None:
62
62
  module_name = 'youtube' if next((s for s in ("yt", "youtube", "youtu_be") if s in module_origin.value), None) else 'instagram'
@@ -81,7 +81,8 @@ class AccountSelector(object):
81
81
  return self.accounts_meta_data[self.current_module_name][self.account_index[self.current_module_name].value][key]
82
82
 
83
83
  def get_current(self) -> tuple:
84
- return (self.account_index[self.current_module_name].value, self.current)
84
+ idx = self.account_index[self.current_module_name].value
85
+ return (idx, self.accounts[self.current_module_name][idx])
85
86
 
86
87
  def get_meta_data(self) -> dict:
87
88
  return self.accounts_meta_data[self.current_module_name][self.account_index[self.current_module_name].value]
@@ -1,5 +1,3 @@
1
- from typing import Union
2
-
3
1
  class ScraperError(Exception):
4
2
  def __init__(self, *args, **kwargs):
5
3
  args = list(args)
@@ -13,7 +13,7 @@ import http.client
13
13
  from PIL import Image
14
14
 
15
15
  from warp_beacon.scraper.abstract import ScraperAbstract
16
- #from warp_beacon.mediainfo.abstract import MediaInfoAbstract
16
+ from warp_beacon.mediainfo.abstract import MediaInfoAbstract
17
17
  from warp_beacon.scraper.exceptions import TimeOut, Unavailable, extract_exception_message
18
18
 
19
19
  from pytubefix import YouTube
@@ -118,9 +118,9 @@ class YoutubeAbstract(ScraperAbstract):
118
118
  new_image = Image.new("RGB", target_size, background_color)
119
119
  image.thumbnail(target_size, Image.Resampling.LANCZOS)
120
120
 
121
- if aspect_ratio_height > 4:
122
- image = image.resize((image.size[0], image.size[1]+new_image.size[1]))
123
- #height += new_image.size[1] - 5
121
+ #if aspect_ratio_height > 4:
122
+ # image = image.resize((image.size[0], image.size[1]+new_image.size[1]))
123
+ # target_height += new_image.size[1] - 5
124
124
 
125
125
  paste_position = ((target_width - width) // 2, (target_height - height) // 2)
126
126
  new_image.paste(image, paste_position)
@@ -143,7 +143,11 @@ class YoutubeAbstract(ScraperAbstract):
143
143
  image = Image.open(io.BytesIO(response.content))
144
144
  ratio = self.aspect_ratio(image.size)
145
145
  logging.info("thumb ratio: '%s'", ratio)
146
- new_image = self.calculate_size_with_padding(image, ratio[0], ratio[1])
146
+ new_image = None
147
+ if ratio[1] > 4:
148
+ new_image = MediaInfoAbstract.shrink_image_to_fit(image)
149
+ else:
150
+ new_image = self.calculate_size_with_padding(image, ratio[0], ratio[1])
147
151
  logging.info("thumb size: '%s'", new_image.size)
148
152
  io_buf = io.BytesIO()
149
153
  new_image.save(io_buf, format='JPEG', subsampling=0, quality=100, progressive=True, optimize=False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: warp_beacon
3
- Version: 2.2.39
3
+ Version: 2.2.41
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.2.39"
2
-
File without changes
File without changes
File without changes
File without changes
File without changes