warp-beacon 2.7.5__py3-none-any.whl → 2.7.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.
@@ -1,2 +1,2 @@
1
- __version__ = "2.7.5"
1
+ __version__ = "2.7.7"
2
2
 
@@ -1,4 +1,5 @@
1
1
  #from typing import TypedDict
2
+ import copy
2
3
  from typing_extensions import Unpack
3
4
 
4
5
  from warp_beacon.jobs.upload_job import UploadJob
@@ -16,7 +17,7 @@ class DownloadJob(AbstractJob):
16
17
 
17
18
  def to_upload_job(self, **kwargs: Unpack[JobSettings]) -> AbstractJob:
18
19
  d = self.to_dict()
19
- d.update(kwargs)
20
+ d.update(copy.deepcopy(kwargs))
20
21
  if "media_collection" in d:
21
22
  for index, _ in enumerate(d["media_collection"]):
22
23
  for k, _ in enumerate(d["media_collection"][index]):
@@ -290,14 +290,14 @@ class AsyncDownloader(object):
290
290
  break
291
291
  self.send_message_to_admin(
292
292
  f"Task <code>{job.job_id}</code> failed. URL: {job.url}. Reason: '<b>UnknownError</b>'."
293
- f"Exception:\n<pre code=\"python\">{exception_msg}<br></pre>"
293
+ f"Exception:\n<pre code=\"python\">{exception_msg}\n</pre>"
294
294
  )
295
295
  self.uploader.queue_task(job.to_upload_job(
296
296
  job_failed=True,
297
- job_failed_msg=f"Unknown error occured. Please <a href=\"https://github.com/sb0y/warp_beacon/issues\">create issue</a> with service logs.<br>"
298
- f"Task <code>{job.job_id}</code> failed. URL: {job.url}.<br>"
299
- f"Reason: '<b>UnknownError</b>'.<br>"
300
- f"Exception:<br><pre code=\"python\">{exception_msg}</pre>"
297
+ job_failed_msg=f"Unknown error occurred. Please <a href=\"https://github.com/sb0y/warp_beacon/issues\">create issue</a> with service logs.\n"
298
+ f"Task <code>{job.job_id}</code> failed. URL: {job.url}.\n"
299
+ f"Reason: '<b>UnknownError</b>'.\n"
300
+ f"Exception:\n<pre code=\"python\">{exception_msg}</pre>"
301
301
  ))
302
302
  break
303
303
  finally:
@@ -145,17 +145,18 @@ class InstagramScraper(ScraperAbstract):
145
145
  def scrap(self, url: str) -> tuple[str]:
146
146
  self.load_session()
147
147
  def _scrap() -> tuple[str]:
148
- if "stories" in url:
148
+ path = urlparse(url).path
149
+ slash_count = path.count('/')
150
+ if "stories" in url or slash_count == 1:
149
151
  # remove URL options
150
- _url = urljoin(url, urlparse(url).path)
152
+ _url = urljoin(url, path)
151
153
  url_last_part = list(filter(None, _url.split('/')))[-1]
152
154
  logging.debug("url last part: '%s'", url_last_part)
153
155
  if url_last_part.isnumeric():
154
156
  return "story", self.scrap_story(url)
155
- else:
157
+ elif slash_count in (1, 2):
156
158
  return "stories", url_last_part
157
- else:
158
- return "media", self.scrap_media(url)
159
+ return "media", self.scrap_media(url)
159
160
  try:
160
161
  return _scrap()
161
162
  except exceptions.LoginRequired as e:
@@ -148,10 +148,12 @@ class Handlers(object):
148
148
  msg_leftover = await Utils.handle_mentions(chat.id, client, msg_leftover)
149
149
  # remove duplicates
150
150
  urls = list(set(urls_raw))
151
+ # remove links without paths
152
+ urls = Utils.remove_links_wo_paths(urls)
151
153
 
152
154
  reply_text = "Wut?"
153
155
  if not urls:
154
- reply_text = "Your message should contains URLs"
156
+ reply_text = "Your message should contain URLs"
155
157
  else:
156
158
  for url in urls:
157
159
  origin = Utils.extract_origin(url)
@@ -9,7 +9,7 @@ from pyrogram import Client
9
9
  from warp_beacon.telegram.types import ReportType
10
10
 
11
11
  class ProgressBar(object):
12
- MAX_PROGRESS_RENDER_SIZE = 500_000 # 500 kB
12
+ MAX_PROGRESS_RENDER_SIZE = 1_500_000 # 1 MB
13
13
 
14
14
  def __init__(self, client: Client) -> None:
15
15
  self._next_threshold = 5
@@ -1,6 +1,6 @@
1
- from typing import Union, Optional
2
-
1
+ from typing import Optional
3
2
  import re
3
+ from urllib.parse import urlparse
4
4
 
5
5
  from pyrogram import Client
6
6
  from pyrogram.types import Message, ChatMember
@@ -154,3 +154,18 @@ class Utils(object):
154
154
  return
155
155
  if not client.me or not client.me.is_premium:
156
156
  client.me = await client.get_me()
157
+
158
+ @staticmethod
159
+ def remove_links_wo_paths(urls: list[str]) -> list[str]:
160
+ try:
161
+ new_urls = []
162
+ for url in urls:
163
+ url = url.rstrip('/')
164
+ path = urlparse(url).path
165
+ sc = path.count('/')
166
+ if sc > 0:
167
+ new_urls.append(url)
168
+ return new_urls
169
+ except Exception as e:
170
+ logging.warning("Failed to remove links without path!", exc_info=e)
171
+ return urls
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.7.5
3
+ Version: 2.7.7
4
4
  Summary: Telegram bot for expanding external media links
5
5
  Home-page: https://github.com/sb0y/warp_beacon
6
6
  Author: Andrey Bagrintsev
@@ -4,14 +4,14 @@ 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=kvIAlwPLWbb1-76WKES6wpdLYyO-U4V_rglHAGDsFEw,23
7
+ warp_beacon/__version__.py,sha256=9pDiAEgs23e-mAdeaqy12UU64Qz3LVP8z7ZQGDAvshE,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
11
11
  warp_beacon/compress/video.py,sha256=_PDMVYCyzLYxHv1uZmmzGcG_8rjaZr7BTXsXTTy_oS4,2846
12
12
  warp_beacon/jobs/__init__.py,sha256=ED8_tPle4iL4kqNW0apAVkgNQtRRTnYfAJwBjO1g0JY,180
13
13
  warp_beacon/jobs/abstract.py,sha256=x8shgG1So1g-Yqu_uzij7yuqherJTIhVhdslOrq69Z4,3263
14
- warp_beacon/jobs/download_job.py,sha256=tz_4rKEqnJ9yrtHeDwPGjxoDrePrGhhjCTG5CK5rr-Q,817
14
+ warp_beacon/jobs/download_job.py,sha256=pfSEZpWVzya0hddU5794p2uQYfm4lHrtM1Ck0T-UrLk,844
15
15
  warp_beacon/jobs/types.py,sha256=Ae8zINgbs7cOcYkYoOCOACA7duyhnIGMQAJ_SJB1QRQ,176
16
16
  warp_beacon/jobs/upload_job.py,sha256=_ul4psPej1jLEs-BMcMR80GbXDSmm38jE9yoZtecclY,741
17
17
  warp_beacon/mediainfo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -22,7 +22,7 @@ warp_beacon/mediainfo/video.py,sha256=UBZrhTN5IDI-aYu6tsJEILo9nFkjHhkldGVFmvV7tE
22
22
  warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  warp_beacon/scheduler/instagram_human.py,sha256=gqayCcn0xRYSNSFxeSpCGhBJyIwNAbk4Fnt1SCd61iA,11259
24
24
  warp_beacon/scheduler/scheduler.py,sha256=Bf4sGXjX75Dox3q-yzUHhagtzUAj3hl5GzfnZya-_io,4995
25
- warp_beacon/scraper/__init__.py,sha256=KTmch6hUXuXSI7Br8yjgZHf2ET9NRBhcXhl2SQ6De48,20258
25
+ warp_beacon/scraper/__init__.py,sha256=gQOcBvZNnlxt0Rbbrkl4PLh7eQe2y3igJbx-87hAvrA,20249
26
26
  warp_beacon/scraper/abstract.py,sha256=pWbaTu-gDZgi-iFjqMR_uGzPl5KLv-4gTdJ9w6cD4sk,3802
27
27
  warp_beacon/scraper/account_selector.py,sha256=vxIVesGPQKVtL3uSn5CFlZB1eAYowUN7lTeiGUFmtDk,10067
28
28
  warp_beacon/scraper/exceptions.py,sha256=EKwoF0oH2xZWbNU-v8DOaWK5skKwa3s1yTIBdlcfMpc,1452
@@ -31,7 +31,7 @@ warp_beacon/scraper/link_resolver.py,sha256=Rc9ZuMyOo3iPywDHwjngy-WRQ2SXhJwxcg-5
31
31
  warp_beacon/scraper/utils.py,sha256=yL-nrdCOAXNZgmIFPurIYFHfPsxHDl8pqif6BYKrzJI,1218
32
32
  warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  warp_beacon/scraper/instagram/captcha.py,sha256=9UYziuqB3Tsat_ET6ex-cnZDbi6yCnsXHSpmE8MuUHk,4651
34
- warp_beacon/scraper/instagram/instagram.py,sha256=6ZEJAoAiB32BywE-On_kQdOoBe2iUWJ6wJqhuGAKmYk,18548
34
+ warp_beacon/scraper/instagram/instagram.py,sha256=OQflbpGZXOH8_z2B3J6AGQucg6BOzKvMo1kmTlzRVcc,18628
35
35
  warp_beacon/scraper/instagram/wb_instagrapi.py,sha256=M5NCtLwdUvByjmDBZMWljgB275R0LSBFblsGpapluD0,5968
36
36
  warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  warp_beacon/scraper/youtube/abstract.py,sha256=lJCmtXYwEB8exTFr_uSA0MCyjVcoSdVHGDRxwZPvEv8,15276
@@ -45,16 +45,16 @@ warp_beacon/telegram/bot.py,sha256=HJxouCxc85EzC8lTaqnP-5agvkdvlxKR6Etg5LjYcoA,1
45
45
  warp_beacon/telegram/caption_shortener.py,sha256=EnguNCF52ne7y4P-iJAbI6K3sqoJqJbND_dX5Fhwkv0,1549
46
46
  warp_beacon/telegram/download_status.py,sha256=N-Qg13LVcPskyQNKG1lw50K1lhFtXu003muCRzZ7wiE,1561
47
47
  warp_beacon/telegram/edit_message.py,sha256=6DX8eJV70MG_b79WbuJG55qLBs66boElzYdCr8zpMeI,5380
48
- warp_beacon/telegram/handlers.py,sha256=uvR6TPHSqdSxigp3wR-ewiE6t3TvVcbVLVcYGwkgD2s,9559
48
+ warp_beacon/telegram/handlers.py,sha256=PaO90370v-S90nwr4PYMzrlHRFBU0VBO6YkqDqTbnjw,9634
49
49
  warp_beacon/telegram/placeholder_message.py,sha256=wN9-BRiyrtHG-EvXtZkGJHt2CX71munQ57ITttjt0mw,6400
50
- warp_beacon/telegram/progress_bar.py,sha256=dqMZFSqxRCOPPRlahkz0L37mqMhfr5rvg9bg-sqAP4Q,4997
50
+ warp_beacon/telegram/progress_bar.py,sha256=WLasAysPB_0buh-N6FOuDcz2QHiuaogC9ILAt0a59Lc,4996
51
51
  warp_beacon/telegram/progress_file_reader.py,sha256=e3equyNKlKs764AD-iE9QRsh3YDHTzP78Mx5tdvPPWs,969
52
52
  warp_beacon/telegram/types.py,sha256=Kvdng6uCF1HRoqQgGW1ZYYPJoVuYkFb-LDvMBbW5Hjk,89
53
- warp_beacon/telegram/utils.py,sha256=1Lq67aRylVJzbwSyvAgjPAGjJZFATkICvAj3TJGuJiM,4635
53
+ warp_beacon/telegram/utils.py,sha256=S1N_JbHM_ExiM5tS0CeYKWIlvaJMlyq85TQNbK_GVds,5029
54
54
  warp_beacon/uploader/__init__.py,sha256=ewvR60k9osJxw_kb5U-TlZkCGR_574biq3w_aR1tjIU,5689
55
- warp_beacon-2.7.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
- warp_beacon-2.7.5.dist-info/METADATA,sha256=EAbVMEWj43GP-wOMTBoRFaqD7LSWS90OKImnddQxOMk,23214
57
- warp_beacon-2.7.5.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
58
- warp_beacon-2.7.5.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
59
- warp_beacon-2.7.5.dist-info/top_level.txt,sha256=5YQRN46STNg81V_3jdzZ6bftkMxhe1hTPSFvJugDu84,1405
60
- warp_beacon-2.7.5.dist-info/RECORD,,
55
+ warp_beacon-2.7.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
+ warp_beacon-2.7.7.dist-info/METADATA,sha256=oMwOpi0Wt49O6btPBoxgyN1RJo16mq5gk10-YOZeGDg,23214
57
+ warp_beacon-2.7.7.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
58
+ warp_beacon-2.7.7.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
59
+ warp_beacon-2.7.7.dist-info/top_level.txt,sha256=5YQRN46STNg81V_3jdzZ6bftkMxhe1hTPSFvJugDu84,1405
60
+ warp_beacon-2.7.7.dist-info/RECORD,,