2
0
mirror of https://github.com/Nick80835/microbot synced 2025-09-05 08:55:51 +00:00
Files
microbot/ubot/modules/youtube.py
2023-10-16 09:54:02 -04:00

28 lines
683 B
Python

# SPDX-License-Identifier: GPL-2.0-or-later
import pafy
from ubot.micro_bot import micro_bot
ldr = micro_bot.loader
@ldr.add("yt", userlocking=True)
async def youtube_cmd(event):
video = pafy.new(event.args)
video_stream = video.getbest()
try:
await event.reply(file=video_stream.url)
except:
await event.reply(f"Download failed: [URL]({video_stream.url})")
@ldr.add("yta", userlocking=True)
async def youtube_audio_cmd(event):
video = pafy.new(event.args)
video_stream = video.getbestaudio()
try:
await event.reply(file=video_stream.url)
except:
await event.reply(f"Download failed: [URL]({video_stream.url})")