Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -70,31 +70,31 @@ def is_tiktok_url(url):
|
|
70 |
match = re.search(pattern, url)
|
71 |
return bool(match)
|
72 |
|
73 |
-
@client.on_message(filters.
|
74 |
async def tiktok_downloader(client: Client, message: Message):
|
75 |
-
if message.
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
81 |
[
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
)
|
87 |
-
]
|
88 |
]
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
|
100 |
client.run()
|
|
|
70 |
match = re.search(pattern, url)
|
71 |
return bool(match)
|
72 |
|
73 |
+
@client.on_message(filters.command(["tt"]) & (filters.private | filters.group))
|
74 |
async def tiktok_downloader(client: Client, message: Message):
|
75 |
+
query_url = message.text.split(" ", 1)[1] if len(message.command) > 1 else None:
|
76 |
+
if not query_url:
|
77 |
+
return await message.reply_text("?")
|
78 |
+
if not is_tiktok_url(query_url):
|
79 |
+
return await message.reply_text("Invalid link")
|
80 |
+
callback_data = generate_callback_data(message.from_user.id, query_url)
|
81 |
+
keyboard = InlineKeyboardMarkup(
|
82 |
+
[
|
83 |
[
|
84 |
+
InlineKeyboardButton(
|
85 |
+
text="Audio Download",
|
86 |
+
callback_data=callback_data
|
87 |
+
)
|
|
|
|
|
88 |
]
|
89 |
+
]
|
90 |
+
)
|
91 |
+
try:
|
92 |
+
dll = await message.reply_text("Processing....")
|
93 |
+
response = await Tiktok.download(TIKTOK_WEB, query_url)
|
94 |
+
await message.reply_video(response[0], reply_markup=keyboard)
|
95 |
+
await dll.delete()
|
96 |
+
except Exception as e:
|
97 |
+
await dll.delete()
|
98 |
+
await message.reply_text(f"Error: {str(e)}")
|
99 |
|
100 |
client.run()
|