genstava789 commited on
Commit ·
d88f0bb
1
Parent(s): 9e36c5f
init
Browse files
bot.py
CHANGED
|
@@ -46,6 +46,8 @@ os.makedirs(cookies_directory, exist_ok=True) # Ensure the directory exists
|
|
| 46 |
# Global variable to store the path to the cookies file
|
| 47 |
cookies_file = None
|
| 48 |
|
|
|
|
|
|
|
| 49 |
def fetch_ngrok_data(user_id):
|
| 50 |
api_key = user_api_keys.get(user_id, default_api_key)
|
| 51 |
if not api_key:
|
|
@@ -398,22 +400,20 @@ async def yt(client: Client, message: Message):
|
|
| 398 |
finally:
|
| 399 |
await load.delete()
|
| 400 |
|
|
|
|
| 401 |
@bot.on_message(filters.command("download"))
|
| 402 |
async def download_tiktok(client: Client, message: Message):
|
| 403 |
-
|
| 404 |
user_id = message.from_user.id
|
| 405 |
-
|
| 406 |
url = message.text.split(maxsplit=1)[1]
|
| 407 |
logging.debug(f"Received /download command from user {user_id} with URL {url}")
|
| 408 |
|
| 409 |
video_detail = await get_video_detail(url)
|
| 410 |
if video_detail:
|
| 411 |
video_id, author_id, author_username, video_url, images, cookies = video_detail
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
logging.debug(f"Video {file_path} sent to user {user_id}")
|
| 417 |
else:
|
| 418 |
await message.reply("Failed to download the video.")
|
| 419 |
logging.debug(f"Failed to download video from URL {url}")
|
|
|
|
| 46 |
# Global variable to store the path to the cookies file
|
| 47 |
cookies_file = None
|
| 48 |
|
| 49 |
+
cwd = Path.cwd()
|
| 50 |
+
|
| 51 |
def fetch_ngrok_data(user_id):
|
| 52 |
api_key = user_api_keys.get(user_id, default_api_key)
|
| 53 |
if not api_key:
|
|
|
|
| 400 |
finally:
|
| 401 |
await load.delete()
|
| 402 |
|
| 403 |
+
|
| 404 |
@bot.on_message(filters.command("download"))
|
| 405 |
async def download_tiktok(client: Client, message: Message):
|
|
|
|
| 406 |
user_id = message.from_user.id
|
|
|
|
| 407 |
url = message.text.split(maxsplit=1)[1]
|
| 408 |
logging.debug(f"Received /download command from user {user_id} with URL {url}")
|
| 409 |
|
| 410 |
video_detail = await get_video_detail(url)
|
| 411 |
if video_detail:
|
| 412 |
video_id, author_id, author_username, video_url, images, cookies = video_detail
|
| 413 |
+
video_bytes = await musicaldown(url)
|
| 414 |
+
if video_bytes:
|
| 415 |
+
await client.send_video(user_id, video_bytes, caption=f"Downloaded by {author_username}")
|
| 416 |
+
logging.debug(f"Video sent to user {user_id}")
|
|
|
|
| 417 |
else:
|
| 418 |
await message.reply("Failed to download the video.")
|
| 419 |
logging.debug(f"Failed to download video from URL {url}")
|