From 587a3b62c9d78a56d1914c10b7aeae903f291c59 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 8 Jan 2022 22:25:30 +0700 Subject: [PATCH] added thumbnail support --- program/music.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/program/music.py b/program/music.py index 2542efa..fd1b319 100644 --- a/program/music.py +++ b/program/music.py @@ -6,6 +6,7 @@ import re import asyncio 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.queues import QUEUE, add_to_queue from driver.veez import call_py, user @@ -165,9 +166,14 @@ async def play(c: Client, m: Message): await suhu.edit("āŒ **no results found.**") else: songname = search[0] + title = search[0] url = search[1] duration = search[2] 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]" veez, ytlink = await ytdl(format, url) if veez == 0: @@ -180,7 +186,7 @@ async def play(c: Client, m: Message): await suhu.delete() requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" 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}", reply_markup=keyboard, ) @@ -198,7 +204,7 @@ async def play(c: Client, m: Message): await suhu.delete() requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" 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`", reply_markup=keyboard, ) @@ -219,9 +225,14 @@ async def play(c: Client, m: Message): await suhu.edit("āŒ **no results found.**") else: songname = search[0] + title = search[0] url = search[1] duration = search[2] 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]" veez, ytlink = await ytdl(format, url) 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})" ) 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}", reply_markup=keyboard, ) @@ -252,7 +263,7 @@ async def play(c: Client, m: Message): await suhu.delete() requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" 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`", reply_markup=keyboard, )