improvements
This commit is contained in:
parent
94f3d664fc
commit
74bc2ace00
@ -39,7 +39,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)
|
||||||
@ -63,6 +63,14 @@ async def ytdl(link):
|
|||||||
return 0, stderr.decode()
|
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)
|
@Client.on_message(command(["vplay", f"vplay@{BOT_USERNAME}"]) & other_filters)
|
||||||
async def vplay(c: Client, m: Message):
|
async def vplay(c: Client, m: Message):
|
||||||
await m.delete()
|
await m.delete()
|
||||||
@ -154,10 +162,10 @@ async def vplay(c: Client, m: Message):
|
|||||||
try:
|
try:
|
||||||
if replied.video:
|
if replied.video:
|
||||||
songname = replied.video.file_name[:70]
|
songname = replied.video.file_name[:70]
|
||||||
duration = replied.video.duration
|
duration = convert_seconds(replied.video.duration)
|
||||||
elif replied.document:
|
elif replied.document:
|
||||||
songname = replied.document.file_name[:70]
|
songname = replied.document.file_name[:70]
|
||||||
duration = replied.document.duration
|
duration = convert_seconds(replied.document.duration)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
songname = "Video"
|
songname = "Video"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user