warp-beacon 2.1.9__py3-none-any.whl → 2.1.11__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 +5 -1
- warp_beacon/scheduler/scheduler.py +2 -1
- warp_beacon/scraper/__init__.py +2 -6
- warp_beacon/scraper/account_selector.py +2 -0
- warp_beacon/telegram/bot.py +26 -5
- warp_beacon/telegram/handlers.py +14 -6
- {warp_beacon-2.1.9.dist-info → warp_beacon-2.1.11.dist-info}/METADATA +1 -1
- {warp_beacon-2.1.9.dist-info → warp_beacon-2.1.11.dist-info}/RECORD +13 -13
- {warp_beacon-2.1.9.dist-info → warp_beacon-2.1.11.dist-info}/LICENSE +0 -0
- {warp_beacon-2.1.9.dist-info → warp_beacon-2.1.11.dist-info}/WHEEL +0 -0
- {warp_beacon-2.1.9.dist-info → warp_beacon-2.1.11.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.1.9.dist-info → warp_beacon-2.1.11.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.1.
|
1
|
+
__version__ = "2.1.11"
|
2
2
|
|
warp_beacon/jobs/abstract.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
import os
|
2
|
-
from abc import ABC
|
2
|
+
from abc import ABC
|
3
3
|
from typing import TypedDict
|
4
4
|
from typing_extensions import Unpack
|
5
5
|
import uuid
|
6
6
|
|
7
|
+
from pyrogram.enums import ChatType
|
8
|
+
|
7
9
|
from warp_beacon.jobs import Origin
|
8
10
|
from warp_beacon.jobs.types import JobType
|
9
11
|
|
@@ -37,6 +39,7 @@ class JobSettings(TypedDict):
|
|
37
39
|
account_switches: int
|
38
40
|
yt_auth: bool
|
39
41
|
session_validation: bool
|
42
|
+
chat_type: ChatType
|
40
43
|
|
41
44
|
class AbstractJob(ABC):
|
42
45
|
job_id: uuid.UUID = None
|
@@ -68,6 +71,7 @@ class AbstractJob(ABC):
|
|
68
71
|
account_switches: int = 0
|
69
72
|
yt_auth: bool = False
|
70
73
|
session_validation: bool = False
|
74
|
+
chat_type: ChatType = None
|
71
75
|
|
72
76
|
def __init__(self, **kwargs: Unpack[JobSettings]) -> None:
|
73
77
|
if kwargs:
|
@@ -11,7 +11,7 @@ class IGScheduler(object):
|
|
11
11
|
thread = None
|
12
12
|
event = None
|
13
13
|
|
14
|
-
def __init__(self, downloader:
|
14
|
+
def __init__(self, downloader: warp_beacon.scraper.AsyncDownloader) -> None:
|
15
15
|
self.downloader = downloader
|
16
16
|
self.event = threading.Event()
|
17
17
|
|
@@ -24,6 +24,7 @@ class IGScheduler(object):
|
|
24
24
|
|
25
25
|
def stop(self) -> None:
|
26
26
|
self.running = False
|
27
|
+
self.event.set()
|
27
28
|
if self.thread:
|
28
29
|
t_id = self.thread.native_id
|
29
30
|
logging.info("Stopping scheduler thread #'%s'", t_id)
|
warp_beacon/scraper/__init__.py
CHANGED
@@ -15,7 +15,6 @@ from warp_beacon.jobs.download_job import DownloadJob
|
|
15
15
|
from warp_beacon.jobs.upload_job import UploadJob
|
16
16
|
from warp_beacon.jobs.types import JobType
|
17
17
|
from warp_beacon.scraper.account_selector import AccountSelector
|
18
|
-
from warp_beacon.scheduler.scheduler import IGScheduler
|
19
18
|
|
20
19
|
import logging
|
21
20
|
|
@@ -37,8 +36,6 @@ class AsyncDownloader(object):
|
|
37
36
|
self.uploader = uploader
|
38
37
|
self.workers_count = workers_count
|
39
38
|
self.acc_selector = AccountSelector(ACC_FILE)
|
40
|
-
self.scheduler = IGScheduler(self)
|
41
|
-
self.scheduler.start()
|
42
39
|
|
43
40
|
def __del__(self) -> None:
|
44
41
|
self.stop_all()
|
@@ -93,7 +90,7 @@ class AsyncDownloader(object):
|
|
93
90
|
try:
|
94
91
|
items = []
|
95
92
|
if job.job_origin is Origin.UNKNOWN:
|
96
|
-
logging.warning("Unknown
|
93
|
+
logging.warning("Unknown task origin! Skipping.")
|
97
94
|
continue
|
98
95
|
if not job.in_process:
|
99
96
|
actor = None
|
@@ -325,11 +322,10 @@ class AsyncDownloader(object):
|
|
325
322
|
logging.error("Exception occurred inside worker!")
|
326
323
|
logging.exception(e)
|
327
324
|
|
328
|
-
|
325
|
+
logging.info("Process done")
|
329
326
|
|
330
327
|
def stop_all(self) -> None:
|
331
328
|
self.allow_loop.value = 0
|
332
|
-
self.scheduler.stop()
|
333
329
|
for proc in self.workers:
|
334
330
|
if proc.is_alive():
|
335
331
|
logging.info("stopping process #%d", proc.pid)
|
@@ -80,4 +80,6 @@ class AccountSelector(object):
|
|
80
80
|
|
81
81
|
def count_service_accounts(self, mod_name: Origin) -> int:
|
82
82
|
module_name = 'youtube' if next((s for s in ("yt", "youtube", "youtu_be") if s in mod_name.value), None) else 'instagram'
|
83
|
+
if module_name not in self.accounts_meta_data:
|
84
|
+
return 0
|
83
85
|
return len(self.accounts_meta_data[module_name])
|
warp_beacon/telegram/bot.py
CHANGED
@@ -4,7 +4,7 @@ import signal
|
|
4
4
|
import uvloop
|
5
5
|
|
6
6
|
from pyrogram import Client, filters
|
7
|
-
from pyrogram.enums import ParseMode
|
7
|
+
from pyrogram.enums import ParseMode, ChatType
|
8
8
|
from pyrogram.handlers import MessageHandler, CallbackQueryHandler
|
9
9
|
from pyrogram.types import Message, InputMedia, InputMediaAudio, InputMediaPhoto, InputMediaVideo, InputMediaAnimation, InputMediaDocument, InlineKeyboardButton, InlineKeyboardMarkup
|
10
10
|
from pyrogram.errors import RPCError, FloodWait, NetworkMigrate, BadRequest, MultiMediaTooLong, MessageIdInvalid
|
@@ -18,6 +18,7 @@ from warp_beacon.uploader import AsyncUploader
|
|
18
18
|
from warp_beacon.jobs.upload_job import UploadJob
|
19
19
|
from warp_beacon.jobs.types import JobType
|
20
20
|
from warp_beacon.telegram.utils import Utils
|
21
|
+
from warp_beacon.scheduler.scheduler import IGScheduler
|
21
22
|
|
22
23
|
import logging
|
23
24
|
|
@@ -29,6 +30,7 @@ class Bot(object):
|
|
29
30
|
client = None
|
30
31
|
handlers = None
|
31
32
|
placeholder = None
|
33
|
+
scheduler = None
|
32
34
|
|
33
35
|
def __init__(self, tg_bot_name: str, tg_token: str, tg_api_id: str, tg_api_hash: str) -> None:
|
34
36
|
# Enable logging
|
@@ -36,7 +38,7 @@ class Bot(object):
|
|
36
38
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
|
37
39
|
)
|
38
40
|
|
39
|
-
logging.info(
|
41
|
+
logging.info("Starting Warp Beacon version '%s' ...", __version__)
|
40
42
|
|
41
43
|
workers_amount = min(32, os.cpu_count() + 4)
|
42
44
|
|
@@ -70,8 +72,11 @@ class Bot(object):
|
|
70
72
|
uploader=self.uploader
|
71
73
|
)
|
72
74
|
|
75
|
+
self.scheduler = IGScheduler(self.downloader)
|
76
|
+
|
73
77
|
self.downloader.start()
|
74
78
|
self.uploader.start()
|
79
|
+
self.scheduler.start()
|
75
80
|
|
76
81
|
self.handlers = Handlers(self)
|
77
82
|
|
@@ -94,9 +99,9 @@ class Bot(object):
|
|
94
99
|
|
95
100
|
def stop(self) -> None:
|
96
101
|
logging.info("Warp Beacon terminating. This may take a while ...")
|
102
|
+
self.scheduler.stop()
|
97
103
|
self.downloader.stop_all()
|
98
104
|
self.uploader.stop_all()
|
99
|
-
#self.client.stop()
|
100
105
|
|
101
106
|
async def send_text(self, chat_id: int, text: str, reply_id: int = None) -> int:
|
102
107
|
try:
|
@@ -271,6 +276,15 @@ class Bot(object):
|
|
271
276
|
|
272
277
|
args["chat_id"] = job.chat_id
|
273
278
|
|
279
|
+
if job.chat_type in (ChatType.GROUP, ChatType.SUPERGROUP):
|
280
|
+
args["caption"] = ""
|
281
|
+
if job.source_usename:
|
282
|
+
args["caption"] += f"Requested by **@{job.source_usename}**"
|
283
|
+
if job.source_usename and job.url:
|
284
|
+
args["caption"] += " | "
|
285
|
+
if job.url:
|
286
|
+
args["caption"] += f"[Source link]({job.url})"
|
287
|
+
|
274
288
|
# common args
|
275
289
|
if job.placeholder_message_id and job.media_type is not JobType.COLLECTION:
|
276
290
|
args["message_id"] = job.placeholder_message_id
|
@@ -333,7 +347,7 @@ class Bot(object):
|
|
333
347
|
)
|
334
348
|
sent_messages += messages
|
335
349
|
if job.media_collection:
|
336
|
-
for j,
|
350
|
+
for j, _ in enumerate(media_chunk):
|
337
351
|
tg_file_id = Utils.extract_file_id(messages[j])
|
338
352
|
if tg_file_id:
|
339
353
|
job.media_collection[i][j].tg_file_id = tg_file_id
|
@@ -360,7 +374,7 @@ class Bot(object):
|
|
360
374
|
if retry_amount+1 >= max_retries:
|
361
375
|
msg = ""
|
362
376
|
if hasattr(e, "MESSAGE") and e.MESSAGE:
|
363
|
-
msg = "Telegram error:
|
377
|
+
msg = f"Telegram error: {str(e.MESSAGE)}"
|
364
378
|
else:
|
365
379
|
msg = (f"Unknown Telegram error. Known information:\n```python\n{traceback.format_exc().strip()}```"
|
366
380
|
"\nPlease [create issue](https://github.com/sb0y/warp_beacon/issues) with this info and service logs.")
|
@@ -374,4 +388,11 @@ class Bot(object):
|
|
374
388
|
finally:
|
375
389
|
job.remove_files()
|
376
390
|
|
391
|
+
if job.chat_type in (ChatType.GROUP, ChatType.SUPERGROUP):
|
392
|
+
try:
|
393
|
+
self.client.delete_messages(job.chat_id, (job.message_id,))
|
394
|
+
except Exception as e:
|
395
|
+
logging.warning("Failed to delete source message. Check bot permissions in Telegram chat settings.")
|
396
|
+
logging.exception(e)
|
397
|
+
|
377
398
|
return tg_file_ids
|
warp_beacon/telegram/handlers.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from pyrogram import Client
|
2
2
|
from pyrogram.types import Message, CallbackQuery
|
3
3
|
from pyrogram.enums import ChatType, ParseMode
|
4
|
-
from pyrogram.types import
|
4
|
+
from pyrogram.types import BotCommand
|
5
5
|
|
6
6
|
from urlextract import URLExtract
|
7
7
|
|
@@ -37,7 +37,9 @@ class Handlers(object):
|
|
37
37
|
tg_file_id=d["tg_file_id"],
|
38
38
|
chat_id=message.chat.id,
|
39
39
|
media_type=JobType[d["media_type"].upper()],
|
40
|
-
message_id=message.id
|
40
|
+
message_id=message.id,
|
41
|
+
chat_type=message.chat.type,
|
42
|
+
source_username=message.from_user
|
41
43
|
)
|
42
44
|
)
|
43
45
|
|
@@ -96,7 +98,9 @@ class Handlers(object):
|
|
96
98
|
tg_file_id=",".join(tg_file_ids),
|
97
99
|
message_id=effective_message_id,
|
98
100
|
media_type=JobType.COLLECTION,
|
99
|
-
chat_id=chat.id
|
101
|
+
chat_id=chat.id,
|
102
|
+
chat_type=message.chat.type,
|
103
|
+
source_username=message.from_user
|
100
104
|
)
|
101
105
|
)
|
102
106
|
elif ent_len:
|
@@ -107,7 +111,9 @@ class Handlers(object):
|
|
107
111
|
tg_file_id=tg_file_ids.pop(),
|
108
112
|
message_id=effective_message_id,
|
109
113
|
media_type=media_type,
|
110
|
-
chat_id=chat.id
|
114
|
+
chat_id=chat.id,
|
115
|
+
chat_type=message.chat.type,
|
116
|
+
source_username=message.from_user
|
111
117
|
)
|
112
118
|
)
|
113
119
|
else:
|
@@ -141,7 +147,7 @@ class Handlers(object):
|
|
141
147
|
if not placeholder_message_id:
|
142
148
|
await self.bot.send_text(
|
143
149
|
chat_id=chat.id,
|
144
|
-
reply_id=effective_message_id,
|
150
|
+
reply_id=effective_message_id,
|
145
151
|
text="Failed to create message placeholder. Please check your bot Internet connection.")
|
146
152
|
return
|
147
153
|
|
@@ -157,7 +163,9 @@ class Handlers(object):
|
|
157
163
|
chat_id=chat.id,
|
158
164
|
in_process=self.bot.uploader.is_inprocess(uniq_id),
|
159
165
|
uniq_id=uniq_id,
|
160
|
-
job_origin=origin
|
166
|
+
job_origin=origin,
|
167
|
+
source_username=message.from_user,
|
168
|
+
chat_type=chat.type
|
161
169
|
))
|
162
170
|
self.bot.uploader.set_inprocess(uniq_id)
|
163
171
|
except Exception as e:
|
@@ -3,12 +3,12 @@ lib/systemd/system/warp_beacon.service,sha256=lPmHqLqcI2eIV7nwHS0qcALQrznixqJuww
|
|
3
3
|
var/warp_beacon/accounts.json,sha256=rKFQM_b9eoDS4mJ1B_SZNolPLXx1SQdQMdY2F_ZcBt8,1523
|
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=wiW76pTWCmfLdnpKj9UWKrYcKbwp4MO8rkgmyMKEM3Q,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=5jCkCTNVeoO55a-q2VmcY_94VMQfR1UPokK1tUDiQ4g,2849
|
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
|
@@ -18,10 +18,10 @@ warp_beacon/mediainfo/audio.py,sha256=ous88kwQj4bDIChN5wnGil5LqTs0IQHH0d-nyrL0-Z
|
|
18
18
|
warp_beacon/mediainfo/silencer.py,sha256=MgUc9Ibbhjhg9GbJMNfJqrdDkMsQShZkQ1sCwvW_-qI,1647
|
19
19
|
warp_beacon/mediainfo/video.py,sha256=AIRy_op_BvehsjarM1rvT5Qo0QWwf-Q6xVVd_aCnbJ4,2505
|
20
20
|
warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
|
-
warp_beacon/scheduler/scheduler.py,sha256=
|
22
|
-
warp_beacon/scraper/__init__.py,sha256=
|
21
|
+
warp_beacon/scheduler/scheduler.py,sha256=BO9nzJ2oKK877527HrzztBBOSClt5cAK1jGmO7gv38c,1536
|
22
|
+
warp_beacon/scraper/__init__.py,sha256=0ZxLxzXweg1LJ1qBRJ1s3EOKe7xpUrp9Nj26gjsLMOQ,14734
|
23
23
|
warp_beacon/scraper/abstract.py,sha256=aNZ9ypF9B8BjflcIwi-7wEzIqF-XPeF0xvfX9CP_iIw,2708
|
24
|
-
warp_beacon/scraper/account_selector.py,sha256=
|
24
|
+
warp_beacon/scraper/account_selector.py,sha256=RYBmLDhE-fqaLqQiQ6zVd13q-1pqQ3F3nYJu2Gx3gV4,2881
|
25
25
|
warp_beacon/scraper/exceptions.py,sha256=lHsPrYy5iYnHsIdUHqRxZmzlqrkNj_TS4TkiTJfWhTs,1326
|
26
26
|
warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
27
|
warp_beacon/scraper/instagram/instagram.py,sha256=iT66IM7nsbVDWQzBW-CJUWDBjoBbRZH4BHx6TJw3oqo,13517
|
@@ -32,14 +32,14 @@ warp_beacon/scraper/youtube/shorts.py,sha256=pHfvEBau8Zp7Ar3LBuPmjqYq8fmjJUQvzeZ
|
|
32
32
|
warp_beacon/scraper/youtube/youtube.py,sha256=K98n2TSJaDZt-xT7mADZL1UEf2exIYm0Wnenn2GAYfI,2250
|
33
33
|
warp_beacon/storage/__init__.py,sha256=8XsJXq9X7GDlTaWREF4W1PDX9PH5utwhjf5c5M8Bb7o,3378
|
34
34
|
warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
|
-
warp_beacon/telegram/bot.py,sha256=
|
36
|
-
warp_beacon/telegram/handlers.py,sha256=
|
35
|
+
warp_beacon/telegram/bot.py,sha256=tJh3EbtrOebRG4fj1uh5CiJ8CUzjDywQGoSMlX-AK9s,13965
|
36
|
+
warp_beacon/telegram/handlers.py,sha256=8MeLgnhaucLc7ptsKV3NXecsGN7kItwrU5xIoJ1Eik8,6645
|
37
37
|
warp_beacon/telegram/placeholder_message.py,sha256=u5kVfTjGmVYkwA5opniRltHXGpsdSxI41WEde8J5os0,6418
|
38
38
|
warp_beacon/telegram/utils.py,sha256=LdCU4ChJHyzpCvyG5v3XcUtUgK3v5by_v8D56VsPeI0,2171
|
39
39
|
warp_beacon/uploader/__init__.py,sha256=BQ5rli0soLf0FGqCpivVh9w6lyoGM10-ck2mUjnoOLU,4777
|
40
|
-
warp_beacon-2.1.
|
41
|
-
warp_beacon-2.1.
|
42
|
-
warp_beacon-2.1.
|
43
|
-
warp_beacon-2.1.
|
44
|
-
warp_beacon-2.1.
|
45
|
-
warp_beacon-2.1.
|
40
|
+
warp_beacon-2.1.11.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
41
|
+
warp_beacon-2.1.11.dist-info/METADATA,sha256=T9UzGN4gcYl_puYM0KXJGkI9C7C9uxY_FJi54dlyG0E,21251
|
42
|
+
warp_beacon-2.1.11.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
43
|
+
warp_beacon-2.1.11.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
44
|
+
warp_beacon-2.1.11.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
|
45
|
+
warp_beacon-2.1.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|