-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy pathstreamtape.py
25 lines (22 loc) · 1.42 KB
/
streamtape.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# (c) @AbirHasan2005
import aiohttp
from configs import Config
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
from helpers.display_progress import humanbytes
async def UploadToStreamtape(file: str, editable: Message, file_size: int):
try:
async with aiohttp.ClientSession() as session:
Main_API = "https://api.streamtape.com/file/ul?login={}&key={}"
hit_api = await session.get(Main_API.format(Config.STREAMTAPE_API_USERNAME, Config.STREAMTAPE_API_PASS))
json_data = await hit_api.json()
temp_api = json_data["result"]["url"]
files = {'file1': open(file, 'rb')}
response = await session.post(temp_api, data=files)
data_f = await response.json(content_type=None)
download_link = data_f["result"]["url"]
filename = file.split("/")[-1].replace("_", " ")
text_edit = f"File Uploaded to Streamtape!\n\n**File Name:** `{filename}`\n**Size:** `{humanbytes(file_size)}`\n**Link:** `{download_link}`"
await editable.edit(text_edit, parse_mode="Markdown", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Open Link", url=download_link)]]))
except Exception as e:
print(f"Error: {e}")
await editable.edit("Sorry, Something went wrong!\n\nCan't Upload to Streamtape. You can report at [Support Group](https://t.me/linux_repo)")