improvements

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

View File

@ -33,7 +33,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)
@ -49,6 +49,14 @@ async def ytdl(link: str):
return 0, stderr
def convert_seconds(seconds):
seconds = seconds % (24 * 3600)
seconds %= 3600
minutes = seconds // 60
seconds %= 60
return "%02d:%02d" % (minutes, seconds)
@Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters)
async def play(c: Client, m: Message):
await m.delete()
@ -130,10 +138,10 @@ async def play(c: Client, m: Message):
if replied.audio:
songname = replied.audio.title[:70]
songname = replied.audio.file_name[:70]
duration = replied.audio.duration
duration = convert_seconds(replied.audio.duration)
elif replied.voice:
songname = "Voice Note"
duration = replied.voice.duration
duration = convert_seconds(replied.voice.duration)
except BaseException:
songname = "Audio"