genstava789 commited on
Commit ·
20dc2e2
1
Parent(s): 4543651
init
Browse files
bot.py
CHANGED
|
@@ -412,14 +412,17 @@ async def download_tiktok(client: Client, message: Message):
|
|
| 412 |
video_id, author_id, author_username, video_url, images, cookies = video_detail
|
| 413 |
if images:
|
| 414 |
await message.reply("Downloading image content...")
|
| 415 |
-
|
|
|
|
|
|
|
| 416 |
image_bytes = await get_content(image_url, cookies)
|
| 417 |
if image_bytes:
|
| 418 |
image_bytes.name = "image.jpg"
|
| 419 |
-
|
| 420 |
else:
|
| 421 |
await message.reply(f"Failed to download image from URL {image_url}")
|
| 422 |
-
|
|
|
|
| 423 |
else:
|
| 424 |
await message.reply("Downloading video content...")
|
| 425 |
video_bytes = await musicaldown(url)
|
|
@@ -433,7 +436,6 @@ async def download_tiktok(client: Client, message: Message):
|
|
| 433 |
except Exception as e:
|
| 434 |
await message.reply(f"An error occurred: {str(e)}")
|
| 435 |
|
| 436 |
-
|
| 437 |
def run_bot():
|
| 438 |
loop = asyncio.new_event_loop()
|
| 439 |
asyncio.set_event_loop(loop)
|
|
|
|
| 412 |
video_id, author_id, author_username, video_url, images, cookies = video_detail
|
| 413 |
if images:
|
| 414 |
await message.reply("Downloading image content...")
|
| 415 |
+
media_group = []
|
| 416 |
+
for image_info in images:
|
| 417 |
+
image_url = image_info['imageURL']['urlList'][0]
|
| 418 |
image_bytes = await get_content(image_url, cookies)
|
| 419 |
if image_bytes:
|
| 420 |
image_bytes.name = "image.jpg"
|
| 421 |
+
media_group.append(InputMediaPhoto(image_bytes, caption=f"Downloaded by {author_username}"))
|
| 422 |
else:
|
| 423 |
await message.reply(f"Failed to download image from URL {image_url}")
|
| 424 |
+
if media_group:
|
| 425 |
+
await client.send_media_group(user_id, media_group)
|
| 426 |
else:
|
| 427 |
await message.reply("Downloading video content...")
|
| 428 |
video_bytes = await musicaldown(url)
|
|
|
|
| 436 |
except Exception as e:
|
| 437 |
await message.reply(f"An error occurred: {str(e)}")
|
| 438 |
|
|
|
|
| 439 |
def run_bot():
|
| 440 |
loop = asyncio.new_event_loop()
|
| 441 |
asyncio.set_event_loop(loop)
|