added thumbnail support

This commit is contained in:
levina 2022-01-08 22:25:30 +07:00 committed by GitHub
parent fd794f7b73
commit 587a3b62c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import re
import asyncio import asyncio
from config import ASSISTANT_NAME, BOT_USERNAME, IMG_1, IMG_2 from config import ASSISTANT_NAME, BOT_USERNAME, IMG_1, IMG_2
from driver.design.thumbnail import thumb
from driver.filters import command, other_filters from driver.filters import command, other_filters
from driver.queues import QUEUE, add_to_queue from driver.queues import QUEUE, add_to_queue
from driver.veez import call_py, user from driver.veez import call_py, user
@ -165,9 +166,14 @@ async def play(c: Client, m: Message):
await suhu.edit("❌ **no results found.**") await suhu.edit("❌ **no results found.**")
else: else:
songname = search[0] songname = search[0]
title = search[0]
url = search[1] url = search[1]
duration = search[2] duration = search[2]
thumbnail = search[3] thumbnail = search[3]
userid = m.from_user.id
gcname = m.chat.title
ctitle = await CHAT_TITLE(gcname)
image = await thumb(thumbnail, title, userid, ctitle)
format = "bestaudio[ext=m4a]" format = "bestaudio[ext=m4a]"
veez, ytlink = await ytdl(format, url) veez, ytlink = await ytdl(format, url)
if veez == 0: if veez == 0:
@ -180,7 +186,7 @@ async def play(c: Client, m: Message):
await suhu.delete() await suhu.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
await m.reply_photo( await m.reply_photo(
photo=thumbnail, photo=image,
caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🎧 **Request by:** {requester}", caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🎧 **Request by:** {requester}",
reply_markup=keyboard, reply_markup=keyboard,
) )
@ -198,7 +204,7 @@ async def play(c: Client, m: Message):
await suhu.delete() await suhu.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
await m.reply_photo( await m.reply_photo(
photo=thumbnail, photo=image,
caption=f"🏷 **Name:** [{songname}]({url})\n**⏱ Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Music`", caption=f"🏷 **Name:** [{songname}]({url})\n**⏱ Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Music`",
reply_markup=keyboard, reply_markup=keyboard,
) )
@ -219,9 +225,14 @@ async def play(c: Client, m: Message):
await suhu.edit("❌ **no results found.**") await suhu.edit("❌ **no results found.**")
else: else:
songname = search[0] songname = search[0]
title = search[0]
url = search[1] url = search[1]
duration = search[2] duration = search[2]
thumbnail = search[3] thumbnail = search[3]
userid = m.from_user.id
gcname = m.chat.title
ctitle = await CHAT_TITLE(gcname)
image = await thumb(thumbnail, title, userid, ctitle)
format = "bestaudio[ext=m4a]" format = "bestaudio[ext=m4a]"
veez, ytlink = await ytdl(format, url) veez, ytlink = await ytdl(format, url)
if veez == 0: if veez == 0:
@ -234,7 +245,7 @@ async def play(c: Client, m: Message):
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
) )
await m.reply_photo( await m.reply_photo(
photo=thumbnail, photo=image,
caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🎧 **Request by:** {requester}", caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🎧 **Request by:** {requester}",
reply_markup=keyboard, reply_markup=keyboard,
) )
@ -252,7 +263,7 @@ async def play(c: Client, m: Message):
await suhu.delete() await suhu.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
await m.reply_photo( await m.reply_photo(
photo=thumbnail, photo=image,
caption=f"🏷 **Name:** [{songname}]({url})\n**⏱ Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Music`", caption=f"🏷 **Name:** [{songname}]({url})\n**⏱ Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Music`",
reply_markup=keyboard, reply_markup=keyboard,
) )