added a youtube-dl command
This commit is contained in:
parent
8a3c18b857
commit
3964ec0fc2
2 changed files with 80 additions and 0 deletions
26
cogs/ytdl.py
Normal file
26
cogs/ytdl.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import os
|
||||
import subprocess
|
||||
|
||||
from discord.ext import commands
|
||||
from cogs.base_cog.bot_base_cog import BotBaseCog
|
||||
|
||||
class YoutubeDL(BotBaseCog):
|
||||
|
||||
def __init__(self, bot):
|
||||
super().__init__(bot)
|
||||
self.setup(__class__.__name__)
|
||||
|
||||
@commands.command()
|
||||
async def youtubedl(self, ctx):
|
||||
try:
|
||||
url = f"\"{ctx.message.content.split(" ", 1)[1]}\""
|
||||
video_or_audio = ctx.message.content.split(" ", 2)[2]
|
||||
process = subprocess.Popen(["python3", "data/ytdl/youtubedl.py", url, video_or_audio])
|
||||
process.wait()
|
||||
output = process.returncode
|
||||
await ctx.send(f"Downloaded {video_or_audio} from {url}, output: {output}")
|
||||
except:
|
||||
await ctx.send("Usage: !youtubedl <url> <video|audio>")
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(YoutubeDL(bot))
|
||||
Loading…
Add table
Add a link
Reference in a new issue