improvements
This commit is contained in:
parent
8e3966b5c1
commit
94f3d664fc
@ -33,7 +33,7 @@ def ytsearch(query: str):
|
|||||||
songname = data["title"]
|
songname = data["title"]
|
||||||
url = data["link"]
|
url = data["link"]
|
||||||
duration = data["duration"]
|
duration = data["duration"]
|
||||||
thumbnail = f"https://i.ytimg.com/vi/{data['id']}/hqdefault.jpg"
|
thumbnail = data["thumbnails"][0]["url"]
|
||||||
return [songname, url, duration, thumbnail]
|
return [songname, url, duration, thumbnail]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
@ -49,6 +49,14 @@ async def ytdl(link: str):
|
|||||||
return 0, stderr
|
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)
|
@Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters)
|
||||||
async def play(c: Client, m: Message):
|
async def play(c: Client, m: Message):
|
||||||
await m.delete()
|
await m.delete()
|
||||||
@ -130,10 +138,10 @@ async def play(c: Client, m: Message):
|
|||||||
if replied.audio:
|
if replied.audio:
|
||||||
songname = replied.audio.title[:70]
|
songname = replied.audio.title[:70]
|
||||||
songname = replied.audio.file_name[:70]
|
songname = replied.audio.file_name[:70]
|
||||||
duration = replied.audio.duration
|
duration = convert_seconds(replied.audio.duration)
|
||||||
elif replied.voice:
|
elif replied.voice:
|
||||||
songname = "Voice Note"
|
songname = "Voice Note"
|
||||||
duration = replied.voice.duration
|
duration = convert_seconds(replied.voice.duration)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
songname = "Audio"
|
songname = "Audio"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user