Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -3,14 +3,14 @@ import re
|
|
3 |
from pyrogram import Client, filters
|
4 |
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
|
5 |
from pyrogram.types import *
|
6 |
-
from
|
7 |
from config import API_ID, API_HASH, BOT_TOKEN
|
8 |
import hashlib
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
logger.setLevel(logging.DEBUG)
|
13 |
|
|
|
14 |
WELCOME_TEXT = """
|
15 |
Halo {}
|
16 |
Saya adalah bot untuk mengunduh video tiktok di telegram.
|
@@ -26,8 +26,6 @@ client = Client(
|
|
26 |
)
|
27 |
|
28 |
link_storage = {}
|
29 |
-
DEMO_API_KEY = "akeno_OSrXhljIomunACd5JY18jFIeIuuB6Pdx"
|
30 |
-
|
31 |
|
32 |
def generate_callback_data(user_id, query):
|
33 |
identifier = hashlib.md5(query.encode()).hexdigest()
|
@@ -59,15 +57,8 @@ async def callback_button(client: Client, cb: CallbackQuery):
|
|
59 |
user_id = cb.from_user.id
|
60 |
query = link_storage.get(data)
|
61 |
if query:
|
62 |
-
response = await
|
63 |
-
|
64 |
-
api_key=DEMO_API_KEY,
|
65 |
-
custom_dev=True,
|
66 |
-
url=query
|
67 |
-
)
|
68 |
-
LOGS.info(response)
|
69 |
-
music_tiktok = response.results.data.music_info.get("play")
|
70 |
-
await client.send_audio(user_id, music_tiktok)
|
71 |
await cb.answer("Audio sent successfully!")
|
72 |
else:
|
73 |
await cb.answer("Invalid or expired link.", show_alert=True)
|
@@ -99,17 +90,8 @@ async def tiktok_downloader(client: Client, message: Message):
|
|
99 |
try:
|
100 |
dll = await message.reply_text("Processing....")
|
101 |
await message.delete()
|
102 |
-
response = await
|
103 |
-
|
104 |
-
api_key=DEMO_API_KEY,
|
105 |
-
custom_dev=True,
|
106 |
-
url=query_url
|
107 |
-
)
|
108 |
-
LOGS.info(response)
|
109 |
-
await message.reply_video(
|
110 |
-
response.results.data.get("play"),
|
111 |
-
reply_markup=keyboard
|
112 |
-
)
|
113 |
await dll.delete()
|
114 |
except Exception as e:
|
115 |
await dll.delete()
|
|
|
3 |
from pyrogram import Client, filters
|
4 |
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
|
5 |
from pyrogram.types import *
|
6 |
+
from RyuzakiLib import Tiktok
|
7 |
from config import API_ID, API_HASH, BOT_TOKEN
|
8 |
import hashlib
|
9 |
|
10 |
+
logging.getLogger("pyrogram").setLevel(logging.WARNING)
|
11 |
+
logging.basicConfig(level=logging.INFO)
|
|
|
12 |
|
13 |
+
TIKTOK_WEB = "https://www.tikwm.com"
|
14 |
WELCOME_TEXT = """
|
15 |
Halo {}
|
16 |
Saya adalah bot untuk mengunduh video tiktok di telegram.
|
|
|
26 |
)
|
27 |
|
28 |
link_storage = {}
|
|
|
|
|
29 |
|
30 |
def generate_callback_data(user_id, query):
|
31 |
identifier = hashlib.md5(query.encode()).hexdigest()
|
|
|
57 |
user_id = cb.from_user.id
|
58 |
query = link_storage.get(data)
|
59 |
if query:
|
60 |
+
response = await Tiktok.download(TIKTOK_WEB, query)
|
61 |
+
await client.send_audio(user_id, response[1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
await cb.answer("Audio sent successfully!")
|
63 |
else:
|
64 |
await cb.answer("Invalid or expired link.", show_alert=True)
|
|
|
90 |
try:
|
91 |
dll = await message.reply_text("Processing....")
|
92 |
await message.delete()
|
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()
|