Spaces:
Paused
Paused
BinaryONe commited on
Commit ·
74c8219
1
Parent(s): e9d98bd
Version V2: Code Modification & Simplification
Browse files
YukkiMusic/plugins/play/Chat_Selecter.py
CHANGED
|
@@ -56,7 +56,7 @@ async def callback_query_handler(client, callback_query):
|
|
| 56 |
user_id= callback_query.from_user.id
|
| 57 |
language = await get_lang(callback_query.from_user.id)
|
| 58 |
_ = get_string(language)
|
| 59 |
-
details, track_id = await YouTube.track(id,True)
|
| 60 |
streamtype = "nodownload"
|
| 61 |
img = details["thumb"]
|
| 62 |
cap = _["play_19"].format(
|
|
|
|
| 56 |
user_id= callback_query.from_user.id
|
| 57 |
language = await get_lang(callback_query.from_user.id)
|
| 58 |
_ = get_string(language)
|
| 59 |
+
details, track_id = await YouTube.track(id, True)
|
| 60 |
streamtype = "nodownload"
|
| 61 |
img = details["thumb"]
|
| 62 |
cap = _["play_19"].format(
|
YukkiMusic/plugins/play/webapp.py
CHANGED
|
@@ -70,7 +70,6 @@ async def send_webapp_button(client, message: Message):
|
|
| 70 |
@app.on_message(filters.service
|
| 71 |
)
|
| 72 |
async def raw_update_handler(client, message: Message):
|
| 73 |
-
#print("Received a service message",message)
|
| 74 |
if message.web_app_data:
|
| 75 |
# Handling WebApp data
|
| 76 |
web_app_data = str(message.web_app_data.data)
|
|
@@ -78,9 +77,6 @@ async def raw_update_handler(client, message: Message):
|
|
| 78 |
id=split_data[1]
|
| 79 |
id=id.replace('"', '')
|
| 80 |
id=id.replace("'", "")
|
| 81 |
-
check=split_data[0].replace('"', '')
|
| 82 |
-
check=check.replace("'",'')
|
| 83 |
-
check=check.replace("/","")
|
| 84 |
#split_data = web_app_data.split(':')
|
| 85 |
print(f"WebApp data received: {web_app_data},{id}")
|
| 86 |
if message.chat.type == ChatType.PRIVATE:
|
|
@@ -93,25 +89,45 @@ async def raw_update_handler(client, message: Message):
|
|
| 93 |
_ = get_string(language)
|
| 94 |
user_id = message.from_user.id
|
| 95 |
user_name = message.from_user.first_name
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
button_list=await chat_selecter(client, {"check":check,"id":id} )
|
| 99 |
-
await client.send_message(chat_id=user_idx, text="Choose an option:", reply_markup=InlineKeyboardMarkup([button_list]))
|
| 100 |
#video_url=f'https://www.youtube.com/watch?v={id}'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
|
| 103 |
-
'''@app.on_raw_update()
|
| 104 |
-
async def handle_raw_updates(client, update, users, chats):
|
| 105 |
-
print("update",update)
|
| 106 |
-
if isinstance(update, types.UpdateWebViewResultSent):
|
| 107 |
-
# Handle the WebView result here
|
| 108 |
-
result = update.result
|
| 109 |
-
# Do something with the result
|
| 110 |
-
print(f"Received WebView result: {result}")
|
| 111 |
-
|
| 112 |
-
if isinstance(update, types.UpdateWebPage):
|
| 113 |
-
# Handle the WebPage update here
|
| 114 |
-
webpage = update.webpage
|
| 115 |
-
# Do something with the webpage
|
| 116 |
-
print(f"Received WebPage update: {webpage}")
|
| 117 |
-
'''
|
|
|
|
| 70 |
@app.on_message(filters.service
|
| 71 |
)
|
| 72 |
async def raw_update_handler(client, message: Message):
|
|
|
|
| 73 |
if message.web_app_data:
|
| 74 |
# Handling WebApp data
|
| 75 |
web_app_data = str(message.web_app_data.data)
|
|
|
|
| 77 |
id=split_data[1]
|
| 78 |
id=id.replace('"', '')
|
| 79 |
id=id.replace("'", "")
|
|
|
|
|
|
|
|
|
|
| 80 |
#split_data = web_app_data.split(':')
|
| 81 |
print(f"WebApp data received: {web_app_data},{id}")
|
| 82 |
if message.chat.type == ChatType.PRIVATE:
|
|
|
|
| 89 |
_ = get_string(language)
|
| 90 |
user_id = message.from_user.id
|
| 91 |
user_name = message.from_user.first_name
|
| 92 |
+
chat_id = config.LOG_GROUP_ID
|
|
|
|
|
|
|
|
|
|
| 93 |
#video_url=f'https://www.youtube.com/watch?v={id}'
|
| 94 |
+
details, track_id = await YouTube.track(id,True)
|
| 95 |
+
streamtype = "nodownload"
|
| 96 |
+
img = details["thumb"]
|
| 97 |
+
cap = _["play_19"].format(
|
| 98 |
+
details["title"],
|
| 99 |
+
details["duration_min"],
|
| 100 |
+
)
|
| 101 |
+
check=split_data[0].replace('"', '')
|
| 102 |
+
check=check.replace("'",'')
|
| 103 |
+
check=check.replace("/","")
|
| 104 |
+
video = True if check == "v" else None
|
| 105 |
+
#print(check,video)
|
| 106 |
+
buttons = InlineKeyboardButton("Go to Group", url='https://t.me/+MeO0kQmZ5ddiYmZl')
|
| 107 |
+
await message.reply_photo(
|
| 108 |
+
photo=img,
|
| 109 |
+
caption=cap,
|
| 110 |
+
reply_markup=InlineKeyboardMarkup([[buttons]]),
|
| 111 |
+
)
|
| 112 |
+
try:
|
| 113 |
+
await stream(
|
| 114 |
+
_,
|
| 115 |
+
'mystic',
|
| 116 |
+
user_id,
|
| 117 |
+
details,
|
| 118 |
+
chat_id,
|
| 119 |
+
user_name,
|
| 120 |
+
chat_id,
|
| 121 |
+
video=video,
|
| 122 |
+
streamtype=streamtype
|
| 123 |
+
)
|
| 124 |
+
except Exception as e:
|
| 125 |
+
ex_type = type(e).__name__
|
| 126 |
+
err = (
|
| 127 |
+
e
|
| 128 |
+
if ex_type == "AssistantErr"
|
| 129 |
+
else _["general_3"].format(ex_type)
|
| 130 |
+
)
|
| 131 |
+
return await client.send_message(user_idx, f"Received err: {err}")
|
| 132 |
|
| 133 |
+
await play_logs(message, streamtype=streamtype)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|