warp-beacon 2.3.13__tar.gz → 2.3.15__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.3.13/warp_beacon.egg-info → warp_beacon-2.3.15}/PKG-INFO +1 -1
- warp_beacon-2.3.15/warp_beacon/__version__.py +2 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/instagram/instagram.py +22 -8
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/telegram/bot.py +0 -1
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/telegram/utils.py +17 -14
- {warp_beacon-2.3.13 → warp_beacon-2.3.15/warp_beacon.egg-info}/PKG-INFO +1 -1
- warp_beacon-2.3.13/warp_beacon/__version__.py +0 -2
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/LICENSE +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/MANIFEST.in +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/README.md +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/assets/placeholder.gif +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/etc/.gitignore +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/etc/accounts.json +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/etc/proxies.json +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/etc/warp_beacon.conf +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/etc/warp_beacon.service +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/pyproject.toml +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/setup.cfg +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/setup.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/compress/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/compress/video.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/jobs/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/jobs/abstract.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/jobs/download_job.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/jobs/types.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/jobs/upload_job.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/mediainfo/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/mediainfo/abstract.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/mediainfo/audio.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/mediainfo/silencer.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/mediainfo/video.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scheduler/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scheduler/scheduler.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/abstract.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/account_selector.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/exceptions.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/fail_handler.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/instagram/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/link_resolver.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/youtube/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/youtube/abstract.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/youtube/music.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/youtube/shorts.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/scraper/youtube/youtube.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/storage/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/storage/mongo.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/telegram/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/telegram/handlers.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/telegram/placeholder_message.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/uploader/__init__.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon/warp_beacon.py +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon.egg-info/SOURCES.txt +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon.egg-info/dependency_links.txt +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon.egg-info/entry_points.txt +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon.egg-info/requires.txt +0 -0
- {warp_beacon-2.3.13 → warp_beacon-2.3.15}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -14,7 +14,7 @@ import urllib3
|
|
14
14
|
from urllib.parse import urljoin, urlparse
|
15
15
|
|
16
16
|
from instagrapi.mixins.story import Story
|
17
|
-
|
17
|
+
from instagrapi.types import Media
|
18
18
|
from instagrapi import Client
|
19
19
|
from instagrapi.mixins.challenge import ChallengeChoice
|
20
20
|
from instagrapi.exceptions import LoginRequired, PleaseWaitFewMinutes, MediaNotFound, ClientNotFoundError, UserNotFound, ChallengeRequired, \
|
@@ -187,19 +187,20 @@ class InstagramScraper(ScraperAbstract):
|
|
187
187
|
|
188
188
|
return ret_val
|
189
189
|
|
190
|
-
def download_video(self, url: str, media_info:
|
190
|
+
def download_video(self, url: str, media_info: Media) -> dict:
|
191
191
|
self.cl.request_timeout = int(os.environ.get("IG_REQUEST_TIMEOUT", default=60))
|
192
192
|
path = self._download_hndlr(self.cl.video_download_by_url, url, folder='/tmp')
|
193
|
-
return {"local_media_path": str(path), "
|
193
|
+
return {"local_media_path": str(path), "canonical_name": self.extract_canonical_name(media_info), \
|
194
|
+
"media_type": JobType.VIDEO, "media_info": {"duration": round(media_info.video_duration)}}
|
194
195
|
|
195
|
-
def download_photo(self, url: str) -> dict:
|
196
|
+
def download_photo(self, url: str, media_info: Media) -> dict:
|
196
197
|
path = str(self._download_hndlr(self.cl.photo_download_by_url, url, folder='/tmp'))
|
197
198
|
path_lowered = path.lower()
|
198
199
|
if ".webp" in path_lowered:
|
199
200
|
path = InstagramScraper.convert_webp_to_png(path)
|
200
201
|
if ".heic" in path_lowered:
|
201
202
|
path = InstagramScraper.convert_heic_to_png(path)
|
202
|
-
return {"local_media_path": path, "media_type": JobType.IMAGE}
|
203
|
+
return {"local_media_path": path, "canonical_name": self.extract_canonical_name(media_info), "media_type": JobType.IMAGE}
|
203
204
|
|
204
205
|
def download_story(self, story_info: Story) -> dict:
|
205
206
|
path, media_type, media_info = "", JobType.UNKNOWN, {}
|
@@ -236,20 +237,33 @@ class InstagramScraper(ScraperAbstract):
|
|
236
237
|
|
237
238
|
return {"media_type": JobType.COLLECTION, "save_items": True, "items": chunks}
|
238
239
|
|
239
|
-
def download_album(self, media_info:
|
240
|
+
def download_album(self, media_info: Media) -> dict:
|
240
241
|
chunks = []
|
241
242
|
for media_chunk in Utils.chunker(media_info.resources, 10):
|
242
243
|
chunk = []
|
243
244
|
for media in media_chunk:
|
244
245
|
_media_info = self._download_hndlr(self.cl.media_info, media.pk)
|
245
246
|
if media.media_type == 1: # photo
|
246
|
-
chunk.append(self.download_photo(url=_media_info.thumbnail_url))
|
247
|
+
chunk.append(self.download_photo(url=_media_info.thumbnail_url, media_info=_media_info))
|
247
248
|
elif media.media_type == 2: # video
|
248
249
|
chunk.append(self.download_video(url=_media_info.video_url, media_info=_media_info))
|
249
250
|
chunks.append(chunk)
|
250
251
|
|
251
252
|
return {"media_type": JobType.COLLECTION, "items": chunks}
|
252
253
|
|
254
|
+
def extract_canonical_name(self, media: Media) -> str:
|
255
|
+
ret = ""
|
256
|
+
try:
|
257
|
+
if media.title:
|
258
|
+
ret = media.title
|
259
|
+
if media.caption_text:
|
260
|
+
ret += "\n" + media.caption_text
|
261
|
+
except Exception as e:
|
262
|
+
logging.warning("Failed to extract canonical media name!")
|
263
|
+
logging.exception(e)
|
264
|
+
|
265
|
+
return ret
|
266
|
+
|
253
267
|
def download(self, job: DownloadJob) -> Optional[list[dict]]:
|
254
268
|
res = []
|
255
269
|
while True:
|
@@ -261,7 +275,7 @@ class InstagramScraper(ScraperAbstract):
|
|
261
275
|
if media_info.media_type == 2 and media_info.product_type == "clips": # Reels
|
262
276
|
res.append(self.download_video(url=media_info.video_url, media_info=media_info))
|
263
277
|
elif media_info.media_type == 1: # Photo
|
264
|
-
res.append(self.download_photo(url=media_info.thumbnail_url))
|
278
|
+
res.append(self.download_photo(url=media_info.thumbnail_url, media_info=media_info))
|
265
279
|
elif media_info.media_type == 8: # Album
|
266
280
|
res.append(self.download_album(media_info=media_info))
|
267
281
|
elif scrap_type == "story":
|
@@ -257,7 +257,6 @@ class Bot(object):
|
|
257
257
|
args["duration"] = round(job.media_info["duration"])
|
258
258
|
args["title"] = job.canonical_name
|
259
259
|
args["caption"] = self.build_signature_caption(job)
|
260
|
-
#args["file_name"] = "%s%s" % (job.canonical_name, os.path.splitext(job.local_media_path)[-1]),
|
261
260
|
elif job.media_type == JobType.ANIMATION:
|
262
261
|
if job.tg_file_id:
|
263
262
|
if job.placeholder_message_id:
|
@@ -71,19 +71,19 @@ class Utils(object):
|
|
71
71
|
|
72
72
|
@staticmethod
|
73
73
|
def extract_message_author(message: Message) -> str:
|
74
|
-
if message.from_user:
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
if message.sender_chat:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
return ''
|
74
|
+
#if message.from_user:
|
75
|
+
# if message.from_user.username:
|
76
|
+
# return message.from_user.username
|
77
|
+
# if message.from_user.first_name:
|
78
|
+
# return message.from_user.first_name
|
79
|
+
# if message.from_user.id:
|
80
|
+
return str(message.from_user.mention(style=enums.ParseMode.HTML))
|
81
|
+
#if message.sender_chat:
|
82
|
+
# if message.sender_chat.username:
|
83
|
+
# return message.sender_chat.username
|
84
|
+
# if message.sender_chat.title:
|
85
|
+
# return message.sender_chat.title
|
86
|
+
#return ''
|
87
87
|
|
88
88
|
@staticmethod
|
89
89
|
def compute_leftover(urls: list, message: str) -> str:
|
@@ -107,6 +107,10 @@ class Utils(object):
|
|
107
107
|
@staticmethod
|
108
108
|
async def handle_mentions(chat_id: int, client: Client, message: str) -> str:
|
109
109
|
try:
|
110
|
+
mentions = Utils.mention_re.findall(message)
|
111
|
+
if not mentions:
|
112
|
+
return message
|
113
|
+
|
110
114
|
logging.info("Processing chat_id: '%s'", str(chat_id))
|
111
115
|
chat = await client.get_chat(chat_id)
|
112
116
|
chat_id = chat.id
|
@@ -118,7 +122,6 @@ class Utils(object):
|
|
118
122
|
|
119
123
|
username = ''
|
120
124
|
members = [member async for member in client.get_chat_members(chat_id)]
|
121
|
-
mentions = Utils.mention_re.findall(message)
|
122
125
|
for mention in mentions:
|
123
126
|
username = mention[1:].strip()
|
124
127
|
if username:
|
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
|