improvements

This commit is contained in:
levina 2022-02-08 08:54:18 +07:00 committed by GitHub
parent 94f3d664fc
commit 74bc2ace00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,7 @@ def ytsearch(query: str):
songname = data["title"]
url = data["link"]
duration = data["duration"]
thumbnail = f"https://i.ytimg.com/vi/{data['id']}/hqdefault.jpg"
thumbnail = data["thumbnails"][0]["url"]
return [songname, url, duration, thumbnail]
except Exception as e:
print(e)
@ -63,6 +63,14 @@ async def ytdl(link):
return 0, stderr.decode()
def convert_seconds(seconds):
seconds = seconds % (24 * 3600)
seconds %= 3600
minutes = seconds // 60
seconds %= 60
return "%02d:%02d" % (minutes, seconds)
@Client.on_message(command(["vplay", f"vplay@{BOT_USERNAME}"]) & other_filters)
async def vplay(c: Client, m: Message):
await m.delete()
@ -154,10 +162,10 @@ async def vplay(c: Client, m: Message):
try:
if replied.video:
songname = replied.video.file_name[:70]
duration = replied.video.duration
duration = convert_seconds(replied.video.duration)
elif replied.document:
songname = replied.document.file_name[:70]
duration = replied.document.duration
duration = convert_seconds(replied.document.duration)
except BaseException:
songname = "Video"