warp-beacon 2.2.38__py3-none-any.whl → 2.2.40__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.
- warp_beacon/__version__.py +1 -1
- warp_beacon/jobs/abstract.py +2 -0
- warp_beacon/scraper/__init__.py +15 -4
- warp_beacon/scraper/account_selector.py +5 -4
- warp_beacon/scraper/exceptions.py +0 -2
- warp_beacon/scraper/youtube/abstract.py +8 -4
- {warp_beacon-2.2.38.dist-info → warp_beacon-2.2.40.dist-info}/METADATA +1 -1
- {warp_beacon-2.2.38.dist-info → warp_beacon-2.2.40.dist-info}/RECORD +12 -12
- {warp_beacon-2.2.38.dist-info → warp_beacon-2.2.40.dist-info}/LICENSE +0 -0
- {warp_beacon-2.2.38.dist-info → warp_beacon-2.2.40.dist-info}/WHEEL +0 -0
- {warp_beacon-2.2.38.dist-info → warp_beacon-2.2.40.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.2.38.dist-info → warp_beacon-2.2.40.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.2.
|
1
|
+
__version__ = "2.2.40"
|
2
2
|
|
warp_beacon/jobs/abstract.py
CHANGED
@@ -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:
|
warp_beacon/scraper/__init__.py
CHANGED
@@ -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,13 +81,14 @@ 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
|
-
|
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]
|
88
89
|
|
89
90
|
def count_service_accounts(self, mod_name: Origin) -> int:
|
90
91
|
module_name = 'youtube' if next((s for s in ("yt", "youtube", "youtu_be") if s in mod_name.value), None) else 'instagram'
|
91
|
-
if module_name not in self.
|
92
|
+
if module_name not in self.accounts:
|
92
93
|
return 0
|
93
|
-
return len(self.
|
94
|
+
return len(self.accounts[module_name])
|
@@ -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
|
-
|
123
|
-
|
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 =
|
146
|
+
new_image = None
|
147
|
+
if ratio[1] > 4:
|
148
|
+
new_image = image.thumbnail((320, 320), Image.Resampling.LANCZOS)
|
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)
|
@@ -3,12 +3,12 @@ lib/systemd/system/warp_beacon.service,sha256=lPmHqLqcI2eIV7nwHS0qcALQrznixqJuww
|
|
3
3
|
var/warp_beacon/accounts.json,sha256=2QQMS9N_Z-TnfZq4U1vSUe4IKyZGmTFdgo8BoF4hQ7E,1710
|
4
4
|
var/warp_beacon/placeholder.gif,sha256=cE5CGJVaop4Sx21zx6j4AyoHU0ncmvQuS2o6hJfEH88,6064
|
5
5
|
warp_beacon/__init__.py,sha256=_rThNODmz0nDp_n4mWo_HKaNFE5jk1_7cRhHyYaencI,163
|
6
|
-
warp_beacon/__version__.py,sha256=
|
6
|
+
warp_beacon/__version__.py,sha256=jCCkS-3Hs5Tz0TZyN7VCfY3qzBmz0p4zCyPo1UW40Rg,24
|
7
7
|
warp_beacon/warp_beacon.py,sha256=7KEtZDj-pdhtl6m-zFLsSojs1ZR4o7L0xbqtdmYPvfE,342
|
8
8
|
warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
warp_beacon/compress/video.py,sha256=_PDMVYCyzLYxHv1uZmmzGcG_8rjaZr7BTXsXTTy_oS4,2846
|
10
10
|
warp_beacon/jobs/__init__.py,sha256=ED8_tPle4iL4kqNW0apAVkgNQtRRTnYfAJwBjO1g0JY,180
|
11
|
-
warp_beacon/jobs/abstract.py,sha256=
|
11
|
+
warp_beacon/jobs/abstract.py,sha256=IGcuohG-h8b6tzSsW_9hoV8JvlSyKBLrUdppzr_TllY,2956
|
12
12
|
warp_beacon/jobs/download_job.py,sha256=5HiPcnJppFMhO14___3eSkoMygM3y-vhpGkMAuNhK7s,854
|
13
13
|
warp_beacon/jobs/types.py,sha256=Ae8zINgbs7cOcYkYoOCOACA7duyhnIGMQAJ_SJB1QRQ,176
|
14
14
|
warp_beacon/jobs/upload_job.py,sha256=_ul4psPej1jLEs-BMcMR80GbXDSmm38jE9yoZtecclY,741
|
@@ -19,14 +19,14 @@ warp_beacon/mediainfo/silencer.py,sha256=MgUc9Ibbhjhg9GbJMNfJqrdDkMsQShZkQ1sCwvW
|
|
19
19
|
warp_beacon/mediainfo/video.py,sha256=DXHiWAOyJPSVXQ0OP7uOBikUFT7noFmMaMSIx04Mhs4,2506
|
20
20
|
warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
warp_beacon/scheduler/scheduler.py,sha256=oKuDP3RqUQmNYBorKxnhz9QqA-eLTJHVTinWbsYB530,2585
|
22
|
-
warp_beacon/scraper/__init__.py,sha256=
|
22
|
+
warp_beacon/scraper/__init__.py,sha256=58zSy74g1LY02HLEwP497a3ABg7f_LGxR6peKSt8dpI,15808
|
23
23
|
warp_beacon/scraper/abstract.py,sha256=aNZ9ypF9B8BjflcIwi-7wEzIqF-XPeF0xvfX9CP_iIw,2708
|
24
|
-
warp_beacon/scraper/account_selector.py,sha256=
|
25
|
-
warp_beacon/scraper/exceptions.py,sha256=
|
24
|
+
warp_beacon/scraper/account_selector.py,sha256=MbDJRuHr-1ebWwzEg4tTXuEZWAuwpJsgo0lI-LXEzVM,3552
|
25
|
+
warp_beacon/scraper/exceptions.py,sha256=fHywTm2-y2RkgM6hVz12CkDMBgHcEoN2a1TBLaVM2t4,1300
|
26
26
|
warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
27
|
warp_beacon/scraper/instagram/instagram.py,sha256=D_r6Kdpe4iBjCeGv-vVIodiVnZps6ZyBbaY0JC7mGWI,13782
|
28
28
|
warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
-
warp_beacon/scraper/youtube/abstract.py,sha256=
|
29
|
+
warp_beacon/scraper/youtube/abstract.py,sha256=64sdGdcVZpDiDzqdYflqshqfzYaL0tWSYXx5o4YU0zE,7867
|
30
30
|
warp_beacon/scraper/youtube/music.py,sha256=nbTDFdgXGbTNqttE828DEgvSc8-SuAsQAHeqUwU6yFM,1484
|
31
31
|
warp_beacon/scraper/youtube/shorts.py,sha256=RqMYDq4XHChtp-LdlxXyHej4h3NI3Qi9T8USxwk-pIk,1177
|
32
32
|
warp_beacon/scraper/youtube/youtube.py,sha256=JvN5pVz0jtxCY9FGMl1dIg5Ccr2Kulaoxtym0Vb1QwQ,2224
|
@@ -37,9 +37,9 @@ warp_beacon/telegram/handlers.py,sha256=xSNG_v4D4FaA5q1_5wXvJkjcDUhy5GaQnfpijJZp
|
|
37
37
|
warp_beacon/telegram/placeholder_message.py,sha256=32U-R_IMPRJd-S5UwlpemLkArJOxCmO7whcynduSbMA,6418
|
38
38
|
warp_beacon/telegram/utils.py,sha256=CeWXMwyzv2l4Af6I-wW2ySU490c-5k82sBhkjabv0n4,2452
|
39
39
|
warp_beacon/uploader/__init__.py,sha256=rbfsm_eYcfsBRkiaG0glVgBNtQCEe7cVQTWEIAHz5aw,4763
|
40
|
-
warp_beacon-2.2.
|
41
|
-
warp_beacon-2.2.
|
42
|
-
warp_beacon-2.2.
|
43
|
-
warp_beacon-2.2.
|
44
|
-
warp_beacon-2.2.
|
45
|
-
warp_beacon-2.2.
|
40
|
+
warp_beacon-2.2.40.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
41
|
+
warp_beacon-2.2.40.dist-info/METADATA,sha256=jgdLo19sD8yJR-tAeJoDQFeEd0MSYr3_fyI3M4QLm6w,21251
|
42
|
+
warp_beacon-2.2.40.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
43
|
+
warp_beacon-2.2.40.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
44
|
+
warp_beacon-2.2.40.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
|
45
|
+
warp_beacon-2.2.40.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|