Update app.py
Browse files
app.py
CHANGED
|
@@ -20,8 +20,29 @@ from PIL import Image
|
|
| 20 |
api_key = "268976:66f4f58a2a905"
|
| 21 |
|
| 22 |
|
|
|
|
| 23 |
|
|
|
|
|
|
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def fetch_data(url):
|
| 26 |
try:
|
| 27 |
response = requests.get(url)
|
|
|
|
| 20 |
api_key = "268976:66f4f58a2a905"
|
| 21 |
|
| 22 |
|
| 23 |
+
#download from bale
|
| 24 |
|
| 25 |
+
from balethon import Client
|
| 26 |
+
from balethon.conditions import document
|
| 27 |
|
| 28 |
+
bot = Client("1261816176:T4jSrvlJiCfdV5UzUkpywN2HFrzef1IZJs5URAkz")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
@bot.on_message(document)
|
| 32 |
+
async def download_document(client, message):
|
| 33 |
+
downloading = await message.reply("Downloading...")
|
| 34 |
+
|
| 35 |
+
response = await client.download(message.document.id)
|
| 36 |
+
|
| 37 |
+
mime_type = message.document.mime_type.split("/")[-1]
|
| 38 |
+
file_format = mime_type.split(";")[0]
|
| 39 |
+
with open(f"downloaded file.{file_format}", "wb") as file:
|
| 40 |
+
file.write(response)
|
| 41 |
+
|
| 42 |
+
await downloading.edit_text("Download completed")
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
bot.run()
|
| 46 |
def fetch_data(url):
|
| 47 |
try:
|
| 48 |
response = requests.get(url)
|