fix: more chatgpt fixes
This commit is contained in:
parent
fcbf9e3b9d
commit
cf6e86d93e
1 changed files with 6 additions and 5 deletions
|
@ -102,6 +102,11 @@ class MusicDownloader(commands.Cog):
|
||||||
previously_existed = False
|
previously_existed = False
|
||||||
return filename, previously_existed
|
return filename, previously_existed
|
||||||
|
|
||||||
|
async def download_file(self, url: str, path: str):
|
||||||
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||||
|
result = await self.bot.loop.run_in_executor(executor, self.youtube_download, url, path)
|
||||||
|
return result
|
||||||
|
|
||||||
@commands.command(aliases=["dl"])
|
@commands.command(aliases=["dl"])
|
||||||
async def download(self, ctx: commands.Context, url: str, delete: bool = False, subfolder: str = None):
|
async def download(self, ctx: commands.Context, url: str, delete: bool = False, subfolder: str = None):
|
||||||
"""This command downloads a YouTube Video as an `m4a` and uploads the file to discord.
|
"""This command downloads a YouTube Video as an `m4a` and uploads the file to discord.
|
||||||
|
@ -120,10 +125,6 @@ class MusicDownloader(commands.Cog):
|
||||||
except self.UserBlacklisted as e:
|
except self.UserBlacklisted as e:
|
||||||
await ctx.send(f"You are blacklisted from running this command!\nReason: `{e}`")
|
await ctx.send(f"You are blacklisted from running this command!\nReason: `{e}`")
|
||||||
return
|
return
|
||||||
async def download_file(self, url: str, path: str):
|
|
||||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
||||||
result = await self.bot.loop.run_in_executor(executor, self.youtube_download, url, path)
|
|
||||||
return result
|
|
||||||
data_path = await self.config.save_directory()
|
data_path = await self.config.save_directory()
|
||||||
if subfolder and await self.bot.is_owner(ctx.author):
|
if subfolder and await self.bot.is_owner(ctx.author):
|
||||||
data_path = os.path.join(data_path, subfolder)
|
data_path = os.path.join(data_path, subfolder)
|
||||||
|
@ -155,7 +156,7 @@ class MusicDownloader(commands.Cog):
|
||||||
msg = ctx.send
|
msg = ctx.send
|
||||||
message = await msg("YouTube Downloader started!")
|
message = await msg("YouTube Downloader started!")
|
||||||
try:
|
try:
|
||||||
ytdlp_output = await download_file(self, url, data_path)
|
ytdlp_output = await self.download_file(url, data_path)
|
||||||
except utils.DownloadError or utils.ExtractorError:
|
except utils.DownloadError or utils.ExtractorError:
|
||||||
await message.edit(content="Please provide a link to YouTube and not another site.\nThe site you've linked to is known for using DRM protection, so MusicDownloader cannot download from it.")
|
await message.edit(content="Please provide a link to YouTube and not another site.\nThe site you've linked to is known for using DRM protection, so MusicDownloader cannot download from it.")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue