warp-beacon 2.5.9__tar.gz → 2.6.1__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.
- {warp_beacon-2.5.9/warp_beacon.egg-info → warp_beacon-2.6.1}/PKG-INFO +1 -1
- warp_beacon-2.6.1/warp_beacon/__version__.py +2 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/__init__.py +4 -1
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/telegram/bot.py +24 -13
- {warp_beacon-2.5.9 → warp_beacon-2.6.1/warp_beacon.egg-info}/PKG-INFO +1 -1
- warp_beacon-2.5.9/warp_beacon/__version__.py +0 -2
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/LICENSE +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/MANIFEST.in +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/README.md +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/assets/placeholder.gif +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/etc/.gitignore +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/etc/accounts.json +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/etc/proxies.json +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/etc/warp_beacon.conf +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/etc/warp_beacon.service +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/pyproject.toml +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/setup.cfg +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/setup.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/compress/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/compress/video.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/jobs/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/jobs/abstract.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/jobs/download_job.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/jobs/types.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/jobs/upload_job.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/mediainfo/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/mediainfo/abstract.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/mediainfo/audio.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/mediainfo/silencer.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/mediainfo/video.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scheduler/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scheduler/instagram_human.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scheduler/scheduler.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/abstract.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/account_selector.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/exceptions.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/fail_handler.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/instagram/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/instagram/instagram.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/link_resolver.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/youtube/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/youtube/abstract.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/youtube/music.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/youtube/shorts.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/scraper/youtube/youtube.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/storage/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/storage/mongo.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/telegram/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/telegram/caption_shortener.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/telegram/handlers.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/telegram/placeholder_message.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/telegram/utils.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/uploader/__init__.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/warp_beacon.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon/yt_auth.py +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon.egg-info/SOURCES.txt +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon.egg-info/dependency_links.txt +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon.egg-info/entry_points.txt +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon.egg-info/requires.txt +0 -0
- {warp_beacon-2.5.9 → warp_beacon-2.6.1}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -321,7 +321,10 @@ class AsyncDownloader(object):
|
|
321
321
|
)
|
322
322
|
ffmpeg = VideoCompress(file_path=item["local_media_path"])
|
323
323
|
new_filepath = ffmpeg.generate_filepath(base_filepath=item["local_media_path"])
|
324
|
-
|
324
|
+
target_size = 2000 * 1000
|
325
|
+
if os.environ.get("TG_PREMIUM", default="false") == "true":
|
326
|
+
target_size = 4000 * 1000
|
327
|
+
if ffmpeg.compress_to(new_filepath, target_size=target_size):
|
325
328
|
logging.info("Successfully compressed file '%s'", new_filepath)
|
326
329
|
os.unlink(item["local_media_path"])
|
327
330
|
item["local_media_path"] = new_filepath
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import signal
|
3
|
+
import asyncio
|
3
4
|
from typing import Optional, Union
|
4
5
|
|
5
6
|
import logging
|
@@ -29,6 +30,7 @@ from warp_beacon.telegram.caption_shortener import CaptionShortner
|
|
29
30
|
from warp_beacon.scheduler.scheduler import IGScheduler
|
30
31
|
|
31
32
|
class Bot(object):
|
33
|
+
should_exit = None
|
32
34
|
storage = None
|
33
35
|
uploader = None
|
34
36
|
downloader = None
|
@@ -37,6 +39,7 @@ class Bot(object):
|
|
37
39
|
handlers = None
|
38
40
|
placeholder = None
|
39
41
|
scheduler = None
|
42
|
+
me = None
|
40
43
|
|
41
44
|
def __init__(self, tg_bot_name: str, tg_token: str, tg_api_id: str, tg_api_hash: str) -> None:
|
42
45
|
# Enable logging
|
@@ -46,10 +49,12 @@ class Bot(object):
|
|
46
49
|
|
47
50
|
logging.getLogger("pyrogram").setLevel(logging.ERROR)
|
48
51
|
|
52
|
+
logging.info("Starting Warp Beacon version '%s' ...", __version__)
|
53
|
+
|
49
54
|
db_connect = DBClient()
|
50
55
|
self.storage = Storage(db_connect)
|
51
56
|
|
52
|
-
|
57
|
+
self.should_exit = asyncio.Event()
|
53
58
|
|
54
59
|
workers_amount = min(32, os.cpu_count() + 4)
|
55
60
|
|
@@ -64,14 +69,6 @@ class Bot(object):
|
|
64
69
|
workers=int(os.environ.get("TG_WORKERS_POOL_SIZE", default=workers_amount))
|
65
70
|
)
|
66
71
|
|
67
|
-
this = self
|
68
|
-
def __terminator() -> None:
|
69
|
-
this.stop()
|
70
|
-
|
71
|
-
stop_signals = (signal.SIGINT, signal.SIGTERM, signal.SIGABRT)
|
72
|
-
for sig in stop_signals:
|
73
|
-
self.client.loop.add_signal_handler(sig, __terminator)
|
74
|
-
|
75
72
|
self.uploader = AsyncUploader(
|
76
73
|
storage=self.storage,
|
77
74
|
admin_message_callback=self.send_text_to_admin,
|
@@ -102,20 +99,34 @@ class Bot(object):
|
|
102
99
|
|
103
100
|
self.placeholder = PlaceholderMessage(self)
|
104
101
|
|
105
|
-
self.client.run()
|
106
|
-
|
107
102
|
def __del__(self) -> None:
|
108
103
|
self.stop()
|
109
|
-
logging.info("Warp Beacon terminated.")
|
110
104
|
|
111
105
|
def start(self) -> None:
|
112
|
-
self.client.run()
|
106
|
+
self.client.run(self.run)
|
107
|
+
|
108
|
+
async def run(self) -> None:
|
109
|
+
loop = asyncio.get_running_loop()
|
110
|
+
for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGABRT):
|
111
|
+
loop.add_signal_handler(sig, self.should_exit.set)
|
112
|
+
async with self.client:
|
113
|
+
self.me = await self.client.get_me()
|
114
|
+
self.client.me = self.me
|
115
|
+
if self.me.is_premium:
|
116
|
+
os.environ["TG_PREMIUM"] = "true"
|
117
|
+
logging.info("Warp Beacon version '%s' started", __version__)
|
118
|
+
await self.should_exit.wait()
|
119
|
+
|
120
|
+
self.stop()
|
121
|
+
logging.info("Warp Beacon version '%s' terminated.", __version__)
|
113
122
|
|
114
123
|
def stop(self) -> None:
|
115
124
|
logging.info("Warp Beacon is terminating. This may take a while ...")
|
116
125
|
self.scheduler.stop()
|
117
126
|
self.downloader.stop_all()
|
118
127
|
self.uploader.stop_all()
|
128
|
+
if self.client and self.client.is_initialized and self.client.is_connected:
|
129
|
+
asyncio.run_coroutine_threadsafe(self.client.stop(), self.client.loop)
|
119
130
|
|
120
131
|
async def send_text(self, chat_id: int, text: str, reply_id: int = None) -> int:
|
121
132
|
try:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|