warp-beacon 2.2.62__py3-none-any.whl → 2.2.64__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/scraper/__init__.py +19 -6
- warp_beacon/scraper/fail_handler.py +42 -0
- warp_beacon/storage/__init__.py +5 -11
- warp_beacon/storage/mongo.py +22 -0
- warp_beacon/telegram/bot.py +7 -2
- {warp_beacon-2.2.62.dist-info → warp_beacon-2.2.64.dist-info}/METADATA +1 -1
- {warp_beacon-2.2.62.dist-info → warp_beacon-2.2.64.dist-info}/RECORD +12 -10
- {warp_beacon-2.2.62.dist-info → warp_beacon-2.2.64.dist-info}/top_level.txt +2 -0
- {warp_beacon-2.2.62.dist-info → warp_beacon-2.2.64.dist-info}/LICENSE +0 -0
- {warp_beacon-2.2.62.dist-info → warp_beacon-2.2.64.dist-info}/WHEEL +0 -0
- {warp_beacon-2.2.62.dist-info → warp_beacon-2.2.64.dist-info}/entry_points.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.2.
|
1
|
+
__version__ = "2.2.64"
|
2
2
|
|
warp_beacon/scraper/__init__.py
CHANGED
@@ -16,6 +16,8 @@ from warp_beacon.jobs.download_job import DownloadJob
|
|
16
16
|
from warp_beacon.jobs.upload_job import UploadJob
|
17
17
|
from warp_beacon.jobs.types import JobType
|
18
18
|
from warp_beacon.scraper.account_selector import AccountSelector
|
19
|
+
from warp_beacon.storage.mongo import DBClient
|
20
|
+
from warp_beacon.scraper.fail_handler import FailHandler
|
19
21
|
|
20
22
|
import logging
|
21
23
|
|
@@ -32,8 +34,10 @@ class AsyncDownloader(object):
|
|
32
34
|
manager = None
|
33
35
|
acc_selector = None
|
34
36
|
scheduler = None
|
37
|
+
fail_handler = None
|
35
38
|
|
36
|
-
def __init__(self, uploader: AsyncUploader, workers_count: int) -> None:
|
39
|
+
def __init__(self, uploader: AsyncUploader, db_connect: DBClient, workers_count: int) -> None:
|
40
|
+
self.fail_handler = FailHandler(db_connect)
|
37
41
|
self.manager = multiprocessing.Manager()
|
38
42
|
self.allow_loop = self.manager.Value('i', 1)
|
39
43
|
self.acc_selector = AccountSelector(self.manager, ACC_FILE)
|
@@ -98,7 +102,7 @@ class AsyncDownloader(object):
|
|
98
102
|
continue
|
99
103
|
if not job.in_process:
|
100
104
|
if job.job_postponed_until > 0:
|
101
|
-
if job.job_postponed_until - time.time() > 0:
|
105
|
+
if (job.job_postponed_until - time.time()) > 0:
|
102
106
|
logging.warning("Job '%s' is postponed, rescheduling", job.url)
|
103
107
|
time.sleep(2)
|
104
108
|
self.job_queue.put(job)
|
@@ -169,7 +173,7 @@ class AsyncDownloader(object):
|
|
169
173
|
logging.warning("Telegram limits exceeded :(")
|
170
174
|
logging.exception(e)
|
171
175
|
self.send_message_to_admin(
|
172
|
-
f"Task <code>{job.job_id}</code> failed. URL: '{job.url}'. Reason: '<b>
|
176
|
+
f"Task <code>{job.job_id}</code> failed. URL: '{job.url}'. Reason: '<b>FileTooBig</b>'."
|
173
177
|
)
|
174
178
|
self.uploader.queue_task(job.to_upload_job(
|
175
179
|
job_failed=True,
|
@@ -222,9 +226,15 @@ class AsyncDownloader(object):
|
|
222
226
|
job_failed_msg="All bot accounts failed to download content. Bot administrator noticed about the issue.")
|
223
227
|
)
|
224
228
|
if e.job.job_origin == Origin.INSTAGRAM:
|
225
|
-
|
226
|
-
|
227
|
-
|
229
|
+
logging.info("Handling captcha postpone")
|
230
|
+
self.uploader.queue_task(job.to_upload_job(
|
231
|
+
job_warning=True,
|
232
|
+
job_warning_msg="Bot is experiencing issues, video delivery may be delayed.")
|
233
|
+
)
|
234
|
+
#self.try_next_account(selector, job, report_error="captcha")
|
235
|
+
#e.job.job_postponed_until = time.time() + 300
|
236
|
+
#self.job_queue.put(e.job)
|
237
|
+
self.fail_handler.store_failed_job(e.job)
|
228
238
|
break
|
229
239
|
except (UnknownError, Exception) as e:
|
230
240
|
logging.warning("UnknownError occurred!")
|
@@ -260,6 +270,9 @@ class AsyncDownloader(object):
|
|
260
270
|
break
|
261
271
|
|
262
272
|
if items:
|
273
|
+
# success
|
274
|
+
for job in self.fail_handler.get_failed_jobs():
|
275
|
+
self.queue_task(job)
|
263
276
|
for item in items:
|
264
277
|
media_info = {"filesize": 0}
|
265
278
|
if item["media_type"] == JobType.VIDEO:
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
import pickle
|
4
|
+
|
5
|
+
from warp_beacon.storage.mongo import DBClient
|
6
|
+
from warp_beacon.jobs.download_job import DownloadJob
|
7
|
+
|
8
|
+
import logging
|
9
|
+
|
10
|
+
class FailHandler(object):
|
11
|
+
client = None
|
12
|
+
db = None
|
13
|
+
def __init__(self, client: DBClient) -> None:
|
14
|
+
self.db = client.client.media.failed_jobs
|
15
|
+
|
16
|
+
def __del__(self) -> None:
|
17
|
+
self.client.close()
|
18
|
+
|
19
|
+
def store_failed_job(self, job: DownloadJob) -> int:
|
20
|
+
db_id = -1
|
21
|
+
try:
|
22
|
+
job_serilized = pickle.dumps(job)
|
23
|
+
db_id = self.db.insert_one(
|
24
|
+
{
|
25
|
+
"job_data": job_serilized
|
26
|
+
}).inserted_id
|
27
|
+
except Exception as e:
|
28
|
+
logging.error("Failed to store job as failed!")
|
29
|
+
logging.exception(e)
|
30
|
+
return db_id
|
31
|
+
|
32
|
+
def get_failed_jobs(self) -> list:
|
33
|
+
ret = []
|
34
|
+
try:
|
35
|
+
cursor = self.db.find()
|
36
|
+
for document in cursor:
|
37
|
+
ret.append(pickle.loads(document["job_data"]))
|
38
|
+
self.db.delete_many({})
|
39
|
+
except Exception as e:
|
40
|
+
logging.error("Failed to get failed jobs!")
|
41
|
+
logging.exception(e)
|
42
|
+
return ret
|
warp_beacon/storage/__init__.py
CHANGED
@@ -4,7 +4,7 @@ from enum import Enum
|
|
4
4
|
|
5
5
|
from urllib.parse import urlparse, parse_qs
|
6
6
|
|
7
|
-
from
|
7
|
+
from warp_beacon.storage.mongo import DBClient
|
8
8
|
|
9
9
|
import logging
|
10
10
|
|
@@ -19,20 +19,14 @@ VIDEO_STORAGE_DIR = os.environ.get("VIDEO_STORAGE_DIR", default="/var/warp_beaco
|
|
19
19
|
class Storage(object):
|
20
20
|
client = None
|
21
21
|
db = None
|
22
|
-
def __init__(self) -> None:
|
22
|
+
def __init__(self, client: DBClient) -> None:
|
23
23
|
if not os.path.isdir(VIDEO_STORAGE_DIR):
|
24
24
|
os.mkdir(VIDEO_STORAGE_DIR)
|
25
|
-
|
26
|
-
self.
|
27
|
-
host=os.environ.get("MONGODB_HOST", default='127.0.0.1'),
|
28
|
-
port=int(os.environ.get("MONGODB_PORT", default=27017)),
|
29
|
-
username=os.environ.get("MONGODB_USER", default='root'),
|
30
|
-
password=os.environ.get("MONGODB_PASSWORD", default="changeme"))
|
31
|
-
self.db = self.client.media.media
|
25
|
+
self.client = client
|
26
|
+
self.db = self.client.client.media.media
|
32
27
|
|
33
28
|
def __del__(self) -> None:
|
34
|
-
|
35
|
-
self.client.close()
|
29
|
+
self.client.close()
|
36
30
|
|
37
31
|
@staticmethod
|
38
32
|
def compute_uniq(url: str) -> str:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from pymongo import MongoClient
|
4
|
+
|
5
|
+
class DBClient(object):
|
6
|
+
client = None
|
7
|
+
|
8
|
+
def __init__(self) -> None:
|
9
|
+
self.client = MongoClient(
|
10
|
+
host=os.environ.get("MONGODB_HOST", default='127.0.0.1'),
|
11
|
+
port=int(os.environ.get("MONGODB_PORT", default=27017)),
|
12
|
+
username=os.environ.get("MONGODB_USER", default='root'),
|
13
|
+
password=os.environ.get("MONGODB_PASSWORD", default="changeme")
|
14
|
+
)
|
15
|
+
|
16
|
+
def __del__(self) -> None:
|
17
|
+
self.close()
|
18
|
+
|
19
|
+
def close(self) -> None:
|
20
|
+
if self.client:
|
21
|
+
self.client.close()
|
22
|
+
self.client = None
|
warp_beacon/telegram/bot.py
CHANGED
@@ -15,6 +15,7 @@ import warp_beacon
|
|
15
15
|
from warp_beacon.__version__ import __version__
|
16
16
|
from warp_beacon.telegram.handlers import Handlers
|
17
17
|
from warp_beacon.telegram.placeholder_message import PlaceholderMessage
|
18
|
+
from warp_beacon.storage.mongo import DBClient
|
18
19
|
from warp_beacon.storage import Storage
|
19
20
|
from warp_beacon.uploader import AsyncUploader
|
20
21
|
from warp_beacon.jobs.upload_job import UploadJob
|
@@ -25,7 +26,7 @@ from warp_beacon.scheduler.scheduler import IGScheduler
|
|
25
26
|
import logging
|
26
27
|
|
27
28
|
class Bot(object):
|
28
|
-
storage =
|
29
|
+
storage = None
|
29
30
|
uploader = None
|
30
31
|
downloader = None
|
31
32
|
allow_loop = True
|
@@ -40,6 +41,9 @@ class Bot(object):
|
|
40
41
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
|
41
42
|
)
|
42
43
|
|
44
|
+
db_connect = DBClient()
|
45
|
+
self.storage = Storage(db_connect)
|
46
|
+
|
43
47
|
logging.info("Starting Warp Beacon version '%s' ...", __version__)
|
44
48
|
|
45
49
|
workers_amount = min(32, os.cpu_count() + 4)
|
@@ -71,7 +75,8 @@ class Bot(object):
|
|
71
75
|
)
|
72
76
|
self.downloader = warp_beacon.scraper.AsyncDownloader(
|
73
77
|
workers_count=int(os.environ.get("WORKERS_POOL_SIZE", default=workers_amount)),
|
74
|
-
uploader=self.uploader
|
78
|
+
uploader=self.uploader,
|
79
|
+
db_connect=db_connect
|
75
80
|
)
|
76
81
|
|
77
82
|
self.scheduler = IGScheduler(self.downloader)
|
@@ -3,7 +3,7 @@ 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=CUkyGXkge2AkmlYlXGiP1505b2K2nULur53nVaqxZL8,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
|
@@ -19,10 +19,11 @@ warp_beacon/mediainfo/silencer.py,sha256=MgUc9Ibbhjhg9GbJMNfJqrdDkMsQShZkQ1sCwvW
|
|
19
19
|
warp_beacon/mediainfo/video.py,sha256=UBZrhTN5IDI-aYu6tsJEILo9nFkjHhkldGVFmvV7tEI,2480
|
20
20
|
warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
warp_beacon/scheduler/scheduler.py,sha256=F9jF6myIHOI0TmC0-rBt2Un8gVvuhBW9zL-nEAEj0Bc,2585
|
22
|
-
warp_beacon/scraper/__init__.py,sha256=
|
22
|
+
warp_beacon/scraper/__init__.py,sha256=U6dtvsbAB-Wocvl72NrDrc_WcK4yqB9p4frLx98i5sA,16537
|
23
23
|
warp_beacon/scraper/abstract.py,sha256=aNZ9ypF9B8BjflcIwi-7wEzIqF-XPeF0xvfX9CP_iIw,2708
|
24
24
|
warp_beacon/scraper/account_selector.py,sha256=YUzLxfGGBvdTR9sJVcx9SDkYK4tWo3iRkGiPIg6IRn4,3649
|
25
25
|
warp_beacon/scraper/exceptions.py,sha256=fHywTm2-y2RkgM6hVz12CkDMBgHcEoN2a1TBLaVM2t4,1300
|
26
|
+
warp_beacon/scraper/fail_handler.py,sha256=n9Fm8n4KF-_2iozpUt2XfT150OdrnCNhOxgACAH0D88,947
|
26
27
|
warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
28
|
warp_beacon/scraper/instagram/instagram.py,sha256=m2bAqLu-_HchlF5CVZDlytB9cFGxrN7EEbQW-G1f5u4,12857
|
28
29
|
warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -30,16 +31,17 @@ warp_beacon/scraper/youtube/abstract.py,sha256=LqQRNjWY1S44nGvthuinnaRvyAKHfDwnI
|
|
30
31
|
warp_beacon/scraper/youtube/music.py,sha256=LzpnRVL0sa1S5KDy0C5iMwNPPXZnXhIrEUxFX2ro06c,1471
|
31
32
|
warp_beacon/scraper/youtube/shorts.py,sha256=WMjStmQz24zJwpzGak4-UuaVLo4-0hPtH_rAHQWgKdU,1322
|
32
33
|
warp_beacon/scraper/youtube/youtube.py,sha256=JvN5pVz0jtxCY9FGMl1dIg5Ccr2Kulaoxtym0Vb1QwQ,2224
|
33
|
-
warp_beacon/storage/__init__.py,sha256=
|
34
|
+
warp_beacon/storage/__init__.py,sha256=2uvyIR0APIW6gOxwJRvCji7wS2q6I7dghvLyWsRqRxo,3312
|
35
|
+
warp_beacon/storage/mongo.py,sha256=2ReAOskgeAlWsMYukH1_-PCjy8yN8eaasgBZ2FqQfu4,528
|
34
36
|
warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
|
-
warp_beacon/telegram/bot.py,sha256=
|
37
|
+
warp_beacon/telegram/bot.py,sha256=XCgZmC_EEjgdogt-X3lGC2LRh2uMb14EaM23EoQIiME,15578
|
36
38
|
warp_beacon/telegram/handlers.py,sha256=171BUNjcaqTM1QnJ9KTBzuJOX1tiDys0hnyuAkA1NiI,7262
|
37
39
|
warp_beacon/telegram/placeholder_message.py,sha256=N1fSL1xbFLF5alhnEvk-xbf3v2A_nLWg6xHtVZTaoiA,6396
|
38
40
|
warp_beacon/telegram/utils.py,sha256=9rNC1BqMZm-kKbzVonBOV8MYfMbcO68Bavq-K3Yj2KA,3115
|
39
41
|
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.
|
42
|
+
warp_beacon-2.2.64.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
43
|
+
warp_beacon-2.2.64.dist-info/METADATA,sha256=wVlnUMznHhaxp5krX4qDJU27Q053-Rne2KJ5SoC2PBE,21303
|
44
|
+
warp_beacon-2.2.64.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
45
|
+
warp_beacon-2.2.64.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
46
|
+
warp_beacon-2.2.64.dist-info/top_level.txt,sha256=q_ThNvU42NteyXqWlEBkaIJTSOK7t-eQ1XW-Fc3V0Eg,1030
|
47
|
+
warp_beacon-2.2.64.dist-info/RECORD,,
|
@@ -17,6 +17,7 @@ warp_beacon/scraper
|
|
17
17
|
warp_beacon/scraper/abstract
|
18
18
|
warp_beacon/scraper/account_selector
|
19
19
|
warp_beacon/scraper/exceptions
|
20
|
+
warp_beacon/scraper/fail_handler
|
20
21
|
warp_beacon/scraper/instagram
|
21
22
|
warp_beacon/scraper/instagram/instagram
|
22
23
|
warp_beacon/scraper/types
|
@@ -26,6 +27,7 @@ warp_beacon/scraper/youtube/music
|
|
26
27
|
warp_beacon/scraper/youtube/shorts
|
27
28
|
warp_beacon/scraper/youtube/youtube
|
28
29
|
warp_beacon/storage
|
30
|
+
warp_beacon/storage/mongo
|
29
31
|
warp_beacon/telegram
|
30
32
|
warp_beacon/telegram/bot
|
31
33
|
warp_beacon/telegram/handlers
|
File without changes
|
File without changes
|
File without changes
|