2020-04-02 12:15:15 -04:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
import pafy
|
|
|
|
|
|
|
|
from ubot.micro_bot import micro_bot
|
|
|
|
|
|
|
|
ldr = micro_bot.loader
|
|
|
|
|
|
|
|
|
2020-06-16 19:16:06 -04:00
|
|
|
@ldr.add("yt", userlocking=True)
|
2020-04-02 12:15:15 -04:00
|
|
|
async def youtube_cmd(event):
|
2020-05-02 16:40:26 -04:00
|
|
|
video = pafy.new(event.args)
|
2020-04-02 12:15:15 -04:00
|
|
|
video_stream = video.getbest()
|
|
|
|
try:
|
2020-04-02 12:22:35 -04:00
|
|
|
await event.reply(file=video_stream.url)
|
2020-04-02 12:15:15 -04:00
|
|
|
except:
|
2020-06-06 11:04:14 -04:00
|
|
|
await event.reply(f"Download failed: [URL]({video_stream.url})")
|
2020-04-02 12:15:15 -04:00
|
|
|
|
|
|
|
|
2020-06-16 19:16:06 -04:00
|
|
|
@ldr.add("yta", userlocking=True)
|
2020-04-02 12:15:15 -04:00
|
|
|
async def youtube_audio_cmd(event):
|
2020-05-02 16:40:26 -04:00
|
|
|
video = pafy.new(event.args)
|
2020-04-02 12:15:15 -04:00
|
|
|
video_stream = video.getbestaudio()
|
|
|
|
try:
|
2020-04-02 12:22:35 -04:00
|
|
|
await event.reply(file=video_stream.url)
|
2020-04-02 12:15:15 -04:00
|
|
|
except:
|
2020-06-06 11:04:14 -04:00
|
|
|
await event.reply(f"Download failed: [URL]({video_stream.url})")
|