warp-beacon 2.8.5__py3-none-any.whl → 2.8.7__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/X/X.py +32 -7
- warp_beacon/telegram/bot.py +12 -2
- {warp_beacon-2.8.5.dist-info → warp_beacon-2.8.7.dist-info}/METADATA +1 -1
- {warp_beacon-2.8.5.dist-info → warp_beacon-2.8.7.dist-info}/RECORD +9 -9
- {warp_beacon-2.8.5.dist-info → warp_beacon-2.8.7.dist-info}/WHEEL +0 -0
- {warp_beacon-2.8.5.dist-info → warp_beacon-2.8.7.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.8.5.dist-info → warp_beacon-2.8.7.dist-info}/licenses/LICENSE +0 -0
- {warp_beacon-2.8.5.dist-info → warp_beacon-2.8.7.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.8.
|
1
|
+
__version__ = "2.8.7"
|
2
2
|
|
warp_beacon/scraper/X/X.py
CHANGED
@@ -5,7 +5,7 @@ from mimetypes import guess_extension
|
|
5
5
|
from urllib.parse import urlparse
|
6
6
|
import requests
|
7
7
|
import yt_dlp
|
8
|
-
from playwright.sync_api import sync_playwright
|
8
|
+
from playwright.sync_api import sync_playwright, Page
|
9
9
|
|
10
10
|
from warp_beacon.telegram.utils import Utils
|
11
11
|
from warp_beacon.scraper.utils import ScraperUtils
|
@@ -100,7 +100,7 @@ class XScraper(XAbstract):
|
|
100
100
|
chunk = []
|
101
101
|
for media in media_chunk:
|
102
102
|
chunk.append({
|
103
|
-
"local_media_path": media,
|
103
|
+
"local_media_path": self.rename_local_file(media),
|
104
104
|
"canonical_name": post_text,
|
105
105
|
"media_type": JobType.IMAGE
|
106
106
|
})
|
@@ -112,7 +112,7 @@ class XScraper(XAbstract):
|
|
112
112
|
else:
|
113
113
|
if local_file:
|
114
114
|
res.append({
|
115
|
-
"local_media_path": local_file,
|
115
|
+
"local_media_path": self.rename_local_file(local_file),
|
116
116
|
"performer": media_info.get("uploader", "Unknown"),
|
117
117
|
"canonical_name": post_text,
|
118
118
|
"media_type": job_type
|
@@ -200,7 +200,34 @@ class XScraper(XAbstract):
|
|
200
200
|
downloaded_imgs.append(filepath)
|
201
201
|
|
202
202
|
return downloaded_imgs, post_text
|
203
|
-
|
203
|
+
|
204
|
+
def extract_post_text(self, page: Page) -> str:
|
205
|
+
try:
|
206
|
+
tweet_texts = []
|
207
|
+
# collecting text blocks from post
|
208
|
+
containers = page.query_selector_all('div[data-testid="tweetText"]')
|
209
|
+
for container in containers:
|
210
|
+
try:
|
211
|
+
spans = container.query_selector_all("span")
|
212
|
+
if spans:
|
213
|
+
for span in spans:
|
214
|
+
text = span.inner_text().strip()
|
215
|
+
if text:
|
216
|
+
tweet_texts.append(text)
|
217
|
+
else:
|
218
|
+
# to span's try container itself
|
219
|
+
text = container.inner_text().strip()
|
220
|
+
if text:
|
221
|
+
tweet_texts.append(text)
|
222
|
+
except Exception:
|
223
|
+
continue
|
224
|
+
|
225
|
+
return " ".join(tweet_texts).strip()
|
226
|
+
except Exception as e:
|
227
|
+
logging.warning("Failed to extract tweet text.", exc_info=e)
|
228
|
+
|
229
|
+
return ""
|
230
|
+
|
204
231
|
def extract_image_urls_from_x_post(self, url: str, timeout: int = 60) -> tuple[list[str], str]:
|
205
232
|
img_urls, post_text = [], ''
|
206
233
|
|
@@ -224,9 +251,7 @@ class XScraper(XAbstract):
|
|
224
251
|
|
225
252
|
#page.wait_for_timeout(3000)
|
226
253
|
page.wait_for_selector("img[src*='pbs.twimg.com/media']", timeout=(timeout*1000))
|
227
|
-
|
228
|
-
if text_element:
|
229
|
-
post_text = str(text_element.inner_text())
|
254
|
+
post_text = self.extract_post_text(page)
|
230
255
|
|
231
256
|
image_elements = page.query_selector_all("img")
|
232
257
|
image_urls = []
|
warp_beacon/telegram/bot.py
CHANGED
@@ -371,15 +371,25 @@ class Bot(object):
|
|
371
371
|
height=j.media_info["height"],
|
372
372
|
duration=round(j.media_info["duration"]),
|
373
373
|
thumb=j.media_info["thumb"],
|
374
|
-
caption=self.build_signature_caption(
|
374
|
+
caption=self.build_signature_caption(j)
|
375
375
|
)
|
376
376
|
tg_chunk.append(vid)
|
377
377
|
elif j.media_type == JobType.IMAGE:
|
378
378
|
photo = InputMediaPhoto(
|
379
379
|
media=j.local_media_path,
|
380
|
-
caption=self.build_signature_caption(
|
380
|
+
caption=self.build_signature_caption(j)
|
381
381
|
)
|
382
382
|
tg_chunk.append(photo)
|
383
|
+
elif j.media_type == JobType.ANIMATION:
|
384
|
+
anim = InputMediaAnimation(
|
385
|
+
media=j.local_media_path,
|
386
|
+
thumb=j.media_info["thumb"],
|
387
|
+
caption=self.build_signature_caption(j),
|
388
|
+
width=j.media_info["width"],
|
389
|
+
height=j.media_info["height"],
|
390
|
+
duration=round(j.media_info["duration"])
|
391
|
+
)
|
392
|
+
tg_chunk.append(anim)
|
383
393
|
mediafs.append(tg_chunk)
|
384
394
|
args["media"] = mediafs
|
385
395
|
|
@@ -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=00A1M6wv0dduOTCIML8mGO3RbFgrzMpBdelbbE01C5s,23
|
8
8
|
warp_beacon/warp_beacon.py,sha256=ADCR30uGXIsDrt9WoiI9Ghu2QtWs0qZIK6x3pQKM_B4,1109
|
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
|
@@ -29,7 +29,7 @@ warp_beacon/scraper/exceptions.py,sha256=EKwoF0oH2xZWbNU-v8DOaWK5skKwa3s1yTIBdlc
|
|
29
29
|
warp_beacon/scraper/fail_handler.py,sha256=5ODu4b8ndZWAcHIXrcUufsWFihetzNUoAi8IgAkreyQ,998
|
30
30
|
warp_beacon/scraper/link_resolver.py,sha256=Rc9ZuMyOo3iPywDHwjngy-WRQ2SXhJwxcg-5ripx7tM,2447
|
31
31
|
warp_beacon/scraper/utils.py,sha256=AOZmDki2Pbr84IG-j_wN2UghKCiWFVDYdx6HJl0JTBs,1258
|
32
|
-
warp_beacon/scraper/X/X.py,sha256=
|
32
|
+
warp_beacon/scraper/X/X.py,sha256=KSAXBqIbm5gMbYHYcIXjc7dx3ZW_Qkz2mV-kQ6CrrfM,7953
|
33
33
|
warp_beacon/scraper/X/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
34
|
warp_beacon/scraper/X/abstract.py,sha256=pCzZPTCtn8pRbBx2SeuBUpMkEHqnOLtwLBAHYceL12Q,5475
|
35
35
|
warp_beacon/scraper/X/types.py,sha256=i36Nu2cHpHCkvoeobBQC3B13Ke_N40tgCCApcm_FBFY,76
|
@@ -45,7 +45,7 @@ warp_beacon/scraper/youtube/youtube.py,sha256=uYR7XpfP6ZnSvw1Gc4qG_M8jkCyv3maEyt
|
|
45
45
|
warp_beacon/storage/__init__.py,sha256=NaKKPXjwa8LvWsqnVJVz0riXj765lGswG9piKgI2lkY,3389
|
46
46
|
warp_beacon/storage/mongo.py,sha256=qC4ZiO8XXvPnP0rJwz4CJx42pqFsyAjCiW10W5QdT6E,527
|
47
47
|
warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
|
-
warp_beacon/telegram/bot.py,sha256=
|
48
|
+
warp_beacon/telegram/bot.py,sha256=ZuHHTvyL_9OVcmS_Xm2YIwjot6nd-3JTOMex9sfLQd8,19572
|
49
49
|
warp_beacon/telegram/caption_shortener.py,sha256=EnguNCF52ne7y4P-iJAbI6K3sqoJqJbND_dX5Fhwkv0,1549
|
50
50
|
warp_beacon/telegram/download_status.py,sha256=N-Qg13LVcPskyQNKG1lw50K1lhFtXu003muCRzZ7wiE,1561
|
51
51
|
warp_beacon/telegram/edit_message.py,sha256=6DX8eJV70MG_b79WbuJG55qLBs66boElzYdCr8zpMeI,5380
|
@@ -56,9 +56,9 @@ warp_beacon/telegram/progress_file_reader.py,sha256=e3equyNKlKs764AD-iE9QRsh3YDH
|
|
56
56
|
warp_beacon/telegram/types.py,sha256=Kvdng6uCF1HRoqQgGW1ZYYPJoVuYkFb-LDvMBbW5Hjk,89
|
57
57
|
warp_beacon/telegram/utils.py,sha256=zTF8VQfAWetBSjAPbmNe_Zi_LN5fAcWptJKjLaFNHaE,5073
|
58
58
|
warp_beacon/uploader/__init__.py,sha256=1enK6qMWaTZEaK456JwaKOfvCvznHA8cjgceOsrF6Po,5732
|
59
|
-
warp_beacon-2.8.
|
60
|
-
warp_beacon-2.8.
|
61
|
-
warp_beacon-2.8.
|
62
|
-
warp_beacon-2.8.
|
63
|
-
warp_beacon-2.8.
|
64
|
-
warp_beacon-2.8.
|
59
|
+
warp_beacon-2.8.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
60
|
+
warp_beacon-2.8.7.dist-info/METADATA,sha256=girgsQc8A85LcGI1wMhVKoQkhKUaO4gHsWtQApuHZy0,23214
|
61
|
+
warp_beacon-2.8.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
62
|
+
warp_beacon-2.8.7.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
63
|
+
warp_beacon-2.8.7.dist-info/top_level.txt,sha256=RraB0PWGvRK2zPYkuICKNgStLG1C5s7rPHHJEHJbkgA,1510
|
64
|
+
warp_beacon-2.8.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|