warp-beacon 2.6.39__py3-none-any.whl → 2.6.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/telegram/bot.py +52 -24
- {warp_beacon-2.6.39.dist-info → warp_beacon-2.6.40.dist-info}/METADATA +1 -1
- {warp_beacon-2.6.39.dist-info → warp_beacon-2.6.40.dist-info}/RECORD +8 -8
- {warp_beacon-2.6.39.dist-info → warp_beacon-2.6.40.dist-info}/WHEEL +0 -0
- {warp_beacon-2.6.39.dist-info → warp_beacon-2.6.40.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.6.39.dist-info → warp_beacon-2.6.40.dist-info}/licenses/LICENSE +0 -0
- {warp_beacon-2.6.39.dist-info → warp_beacon-2.6.40.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.6.
|
1
|
+
__version__ = "2.6.40"
|
2
2
|
|
warp_beacon/telegram/bot.py
CHANGED
@@ -12,8 +12,9 @@ import uvloop
|
|
12
12
|
from pyrogram import Client, filters
|
13
13
|
from pyrogram.enums import ParseMode, ChatType
|
14
14
|
from pyrogram.handlers import MessageHandler, CallbackQueryHandler
|
15
|
-
from pyrogram.types import
|
16
|
-
from pyrogram.errors import
|
15
|
+
from pyrogram.types import InputMediaAudio, InputMediaPhoto, InputMediaVideo, InputMediaAnimation, InlineKeyboardButton, InlineKeyboardMarkup
|
16
|
+
from pyrogram.errors import NetworkMigrate, BadRequest, MultiMediaTooLong, MessageIdInvalid
|
17
|
+
from pyrogram.raw.types import InputFile, InputFileBig
|
17
18
|
|
18
19
|
import warp_beacon
|
19
20
|
from warp_beacon.__version__ import __version__
|
@@ -225,7 +226,7 @@ class Bot(object):
|
|
225
226
|
|
226
227
|
return caption
|
227
228
|
|
228
|
-
def build_tg_args(self, job: UploadJob) -> dict:
|
229
|
+
def build_tg_args(self, job: UploadJob, uploaded_files: list[Union[InputFile, InputFileBig]]) -> dict:
|
229
230
|
args = {}
|
230
231
|
if job.media_type == JobType.VIDEO:
|
231
232
|
if job.tg_file_id:
|
@@ -241,7 +242,7 @@ class Bot(object):
|
|
241
242
|
else:
|
242
243
|
if job.placeholder_message_id:
|
243
244
|
args["media"] = InputMediaVideo(
|
244
|
-
media=
|
245
|
+
media=next(iter(uploaded_files)),
|
245
246
|
supports_streaming=True,
|
246
247
|
width=job.media_info["width"],
|
247
248
|
height=job.media_info["height"],
|
@@ -250,7 +251,7 @@ class Bot(object):
|
|
250
251
|
caption=self.build_signature_caption(job)
|
251
252
|
)
|
252
253
|
else:
|
253
|
-
args["video"] =
|
254
|
+
args["video"] = next(iter(uploaded_files))
|
254
255
|
args["supports_streaming"] = True
|
255
256
|
args["width"] = job.media_info["width"]
|
256
257
|
args["height"] = job.media_info["height"]
|
@@ -272,11 +273,11 @@ class Bot(object):
|
|
272
273
|
else:
|
273
274
|
if job.placeholder_message_id:
|
274
275
|
args["media"] = InputMediaPhoto(
|
275
|
-
media=
|
276
|
+
media=next(iter(uploaded_files)),
|
276
277
|
caption=self.build_signature_caption(job)
|
277
278
|
)
|
278
279
|
else:
|
279
|
-
args["photo"] =
|
280
|
+
args["photo"] = next(iter(uploaded_files))
|
280
281
|
args["caption"] = self.build_signature_caption(job)
|
281
282
|
|
282
283
|
args["file_name"] = os.path.basename(job.local_media_path)
|
@@ -292,7 +293,7 @@ class Bot(object):
|
|
292
293
|
else:
|
293
294
|
if job.placeholder_message_id:
|
294
295
|
args["media"] = InputMediaAudio(
|
295
|
-
media=
|
296
|
+
media=next(iter(uploaded_files)),
|
296
297
|
performer=job.media_info["performer"],
|
297
298
|
thumb=job.media_info["thumb"],
|
298
299
|
duration=round(job.media_info["duration"]),
|
@@ -300,7 +301,7 @@ class Bot(object):
|
|
300
301
|
caption=self.build_signature_caption(job)
|
301
302
|
)
|
302
303
|
else:
|
303
|
-
args["audio"] =
|
304
|
+
args["audio"] = next(iter(uploaded_files))
|
304
305
|
args["performer"] = job.media_info["performer"]
|
305
306
|
args["thumb"] = job.media_info["thumb"]
|
306
307
|
args["duration"] = round(job.media_info["duration"])
|
@@ -321,7 +322,7 @@ class Bot(object):
|
|
321
322
|
else:
|
322
323
|
if job.placeholder_message_id:
|
323
324
|
args["media"] = InputMediaAnimation(
|
324
|
-
media=
|
325
|
+
media=next(iter(uploaded_files)),
|
325
326
|
thumb=job.media_info["thumb"],
|
326
327
|
duration=round(job.media_info["duration"]),
|
327
328
|
width=job.media_info["width"],
|
@@ -329,7 +330,7 @@ class Bot(object):
|
|
329
330
|
caption=self.build_signature_caption(job)
|
330
331
|
)
|
331
332
|
else:
|
332
|
-
args["animation"] =
|
333
|
+
args["animation"] = next(iter(uploaded_files))
|
333
334
|
args["width"] = job.media_info["width"]
|
334
335
|
args["height"] = job.media_info["height"]
|
335
336
|
args["duration"] = round(job.media_info["duration"])
|
@@ -357,23 +358,27 @@ class Bot(object):
|
|
357
358
|
args["media"].append(tg_chunk)
|
358
359
|
else:
|
359
360
|
mediafs = []
|
361
|
+
file_index = 0
|
360
362
|
for chunk in job.media_collection:
|
361
363
|
tg_chunk = []
|
362
|
-
for
|
363
|
-
|
364
|
+
for el in chunk:
|
365
|
+
uploaded_file = uploaded_files[file_index]
|
366
|
+
file_index += 1
|
367
|
+
|
368
|
+
if el.media_type == JobType.VIDEO:
|
364
369
|
vid = InputMediaVideo(
|
365
|
-
media=
|
370
|
+
media=uploaded_file,
|
366
371
|
supports_streaming=True,
|
367
|
-
width=
|
368
|
-
height=
|
369
|
-
duration=round(
|
370
|
-
thumb=
|
372
|
+
width=el.media_info["width"],
|
373
|
+
height=el.media_info["height"],
|
374
|
+
duration=round(el.media_info["duration"]),
|
375
|
+
thumb=el.media_info["thumb"],
|
371
376
|
caption=self.build_signature_caption(job)
|
372
377
|
)
|
373
378
|
tg_chunk.append(vid)
|
374
|
-
elif
|
379
|
+
elif el.media_type == JobType.IMAGE:
|
375
380
|
photo = InputMediaPhoto(
|
376
|
-
media=
|
381
|
+
media=uploaded_file,
|
377
382
|
caption=self.build_signature_caption(job)
|
378
383
|
)
|
379
384
|
tg_chunk.append(photo)
|
@@ -403,6 +408,26 @@ class Bot(object):
|
|
403
408
|
|
404
409
|
return args
|
405
410
|
|
411
|
+
async def upload_with_progress(self, job: UploadJob) -> list[Union[InputFile, InputFileBig]]:
|
412
|
+
def progress_callback(current: int, total: int) -> None:
|
413
|
+
logging.info("[%s] Uploaded %.1f%%", job.local_media_path, current * 100 / total)
|
414
|
+
|
415
|
+
if job.media_type == JobType.COLLECTION:
|
416
|
+
col_uploaded_files = []
|
417
|
+
for chunk in job.media_collection:
|
418
|
+
for col in chunk:
|
419
|
+
uploaded_file = await self.client.save_file(
|
420
|
+
file_path=col.local_media_path,
|
421
|
+
progress=progress_callback
|
422
|
+
)
|
423
|
+
col_uploaded_files.append(uploaded_file)
|
424
|
+
return col_uploaded_files
|
425
|
+
|
426
|
+
return [await self.client.save_file(
|
427
|
+
file_path=job.local_media_path,
|
428
|
+
progress=progress_callback
|
429
|
+
)]
|
430
|
+
|
406
431
|
async def upload_job(self, job: UploadJob) -> list[str]:
|
407
432
|
tg_file_ids = []
|
408
433
|
try:
|
@@ -416,7 +441,8 @@ class Bot(object):
|
|
416
441
|
await Utils.ensure_me_loaded(self.client)
|
417
442
|
if job.placeholder_message_id:
|
418
443
|
try:
|
419
|
-
|
444
|
+
uploaded_files = await self.upload_with_progress(job)
|
445
|
+
reply_message = await self.client.edit_message_media(**self.build_tg_args(job, uploaded_files))
|
420
446
|
except MessageIdInvalid:
|
421
447
|
logging.warning("Placeholder message not found. Looks like placeholder message was deleted by administrator.")
|
422
448
|
job.placeholder_message_id = None
|
@@ -429,14 +455,15 @@ class Bot(object):
|
|
429
455
|
JobType.ANIMATION: self.client.send_animation
|
430
456
|
}
|
431
457
|
try:
|
432
|
-
|
458
|
+
uploaded_files = await self.upload_with_progress(job)
|
459
|
+
reply_message = await send_funcs[job.media_type](**self.build_tg_args(job, uploaded_files))
|
433
460
|
except ValueError as e:
|
434
461
|
err_text = str(e)
|
435
462
|
if "Expected" in err_text:
|
436
463
|
logging.warning("Expectations exceeded reality.")
|
437
464
|
logging.warning(err_text)
|
438
465
|
expectation, reality = Utils.parse_expected_patronum_error(err_text)
|
439
|
-
job_args = self.build_tg_args(job)
|
466
|
+
job_args = self.build_tg_args(job, uploaded_files)
|
440
467
|
job_args[reality.value.lower()] = job_args.pop(expectation.value.lower())
|
441
468
|
reply_message = await send_funcs[reality](**job_args)
|
442
469
|
|
@@ -445,7 +472,8 @@ class Bot(object):
|
|
445
472
|
job.tg_file_id = tg_file_id
|
446
473
|
logging.info("Uploaded media file with type '%s' tg_file_id is '%s'", job.media_type.value, job.tg_file_id)
|
447
474
|
elif job.media_type == JobType.COLLECTION:
|
448
|
-
|
475
|
+
uploaded_files = await self.upload_with_progress(job)
|
476
|
+
col_job_args = self.build_tg_args(job, uploaded_files)
|
449
477
|
sent_messages = []
|
450
478
|
snd_grp_options = {"chat_id": job.chat_id, "reply_to_message_id": job.message_id}
|
451
479
|
for i, media_chunk in enumerate(col_job_args["media"]):
|
@@ -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=
|
7
|
+
warp_beacon/__version__.py,sha256=JeoFTFuXbUA8AG8mWIfjNnPe5U8lgjF_fAazxZJ1mRI,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
|
@@ -40,15 +40,15 @@ warp_beacon/scraper/youtube/youtube.py,sha256=x9v9p1coA9TvBhxjNAofGu4UBkAEdYPE2e
|
|
40
40
|
warp_beacon/storage/__init__.py,sha256=0Vajd0oITKJfu2vmNx5uQSt3-L6vwIvUYWJo8HZCjco,3398
|
41
41
|
warp_beacon/storage/mongo.py,sha256=qC4ZiO8XXvPnP0rJwz4CJx42pqFsyAjCiW10W5QdT6E,527
|
42
42
|
warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
|
-
warp_beacon/telegram/bot.py,sha256=
|
43
|
+
warp_beacon/telegram/bot.py,sha256=n5e_Z6RXDP2jjoHbxE3LJXxR17sOxL1l-y477nGGhb4,19941
|
44
44
|
warp_beacon/telegram/caption_shortener.py,sha256=EnguNCF52ne7y4P-iJAbI6K3sqoJqJbND_dX5Fhwkv0,1549
|
45
45
|
warp_beacon/telegram/handlers.py,sha256=uvR6TPHSqdSxigp3wR-ewiE6t3TvVcbVLVcYGwkgD2s,9559
|
46
46
|
warp_beacon/telegram/placeholder_message.py,sha256=wN9-BRiyrtHG-EvXtZkGJHt2CX71munQ57ITttjt0mw,6400
|
47
47
|
warp_beacon/telegram/utils.py,sha256=1Lq67aRylVJzbwSyvAgjPAGjJZFATkICvAj3TJGuJiM,4635
|
48
48
|
warp_beacon/uploader/__init__.py,sha256=j3qcuKhpchseZLGzSsSiogqe6WdMbkK8d3I-ConhNRs,5687
|
49
|
-
warp_beacon-2.6.
|
50
|
-
warp_beacon-2.6.
|
51
|
-
warp_beacon-2.6.
|
52
|
-
warp_beacon-2.6.
|
53
|
-
warp_beacon-2.6.
|
54
|
-
warp_beacon-2.6.
|
49
|
+
warp_beacon-2.6.40.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
50
|
+
warp_beacon-2.6.40.dist-info/METADATA,sha256=ITOyqqENYwVqUXwbktnVY_6Jczf584NiBvtDDuyfQpk,22706
|
51
|
+
warp_beacon-2.6.40.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
|
52
|
+
warp_beacon-2.6.40.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
53
|
+
warp_beacon-2.6.40.dist-info/top_level.txt,sha256=aFsWDQBplsMOyVMGGJ8iu-auZ25z1e_IB4tM2M8kW1A,1187
|
54
|
+
warp_beacon-2.6.40.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|