Add wetransfer

This commit is contained in:
yasir 2022-12-05 12:18:06 +07:00
parent 7e3b81bb76
commit c5f77e9840

View file

@ -5,7 +5,8 @@
* @projectName MissKatyPyro
* Copyright @YasirPedia All rights reserved
"""
import re
import re, requests
import urllib.parse
from misskaty.helper.http import http
from misskaty import app
from pyrogram import filters
@ -19,6 +20,7 @@ from misskaty.helper.human_read import get_readable_file_size
LIST_LINK = """
- Pling and all aliases.
- Wetransfer
- Other link soon...
"""
@ -28,6 +30,8 @@ __HELP__ = f"""
Supported Link:
{LIST_LINK}
Credit: <a href='https://github.com/sanjit-sinha/PyBypass'>PyBypass</a>
"""
@ -47,6 +51,42 @@ async def pling_bypass(url):
return e
def wetransfer_bypass(url: str) -> str:
if url.startswith("https://we.tl/"):
r = requests.head(url, allow_redirects=True)
url = r.url
recipient_id = None
params = urllib.parse.urlparse(url).path.split("/")[2:]
if len(params) == 2:
transfer_id, security_hash = params
elif len(params) == 3:
transfer_id, recipient_id, security_hash = params
else:
return None
j = {
"intent": "entire_transfer",
"security_hash": security_hash,
}
if recipient_id:
j["recipient_id"] = recipient_id
s = requests.Session()
r = s.get("https://wetransfer.com/")
m = re.search('name="csrf-token" content="([^"]+)"', r.text)
s.headers.update({"x-csrf-token": m[1], "x-requested-with": "XMLHttpRequest"})
r = s.post(
f"https://wetransfer.com/api/v4/transfers/{transfer_id}/download", json=j
)
j = r.json()
dl_url = j["direct_link"]
return f"\n**Source Link** :\n`{url}`\n**Direct Link :**\n{dl_url}"
@app.on_message(filters.command(["directurl"], COMMAND_HANDLER))
@capture_err
async def bypass(_, message):
@ -55,6 +95,7 @@ async def bypass(_, message):
f"Gunakan perintah /{message.command[0]} untuk bypass url"
)
url = message.command[1]
host = urllib.parse.urlparse(url).netloc
msg = await message.reply("Bypassing URL..", quote=True)
mention = f"**Bypasser:** {message.from_user.mention} ({message.from_user.id})"
if re.match(r"https?://(store.kde.org|www.pling.com)\/p\/(\d+)", url):
@ -76,5 +117,7 @@ async def bypass(_, message):
reply_markup=markup,
disable_web_page_preview=True,
)
elif "we.tl" or "wetransfer.com" in host:
await msg.edit(f"{data}\n\n{mention}")
else:
await msg.edit("Unsupported link..")