diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-18 00:24:50 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-18 00:24:50 +0200 |
| commit | a2b5b10625126b7e98643af9fe40569c9e004047 (patch) | |
| tree | 2b59a929d068bc28bbc21e8c8d8836e4d29270c0 /cogs/downloader.py | |
| parent | add mathematical plotting (diff) | |
| download | senator-sperma-a2b5b10625126b7e98643af9fe40569c9e004047.tar.gz senator-sperma-a2b5b10625126b7e98643af9fe40569c9e004047.zip | |
refactor + preparing bot for public use
Signed-off-by: salmonik <raisersoft@proton.me>
Diffstat (limited to 'cogs/downloader.py')
| -rw-r--r-- | cogs/downloader.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/cogs/downloader.py b/cogs/downloader.py index d2835d8..d364b3a 100644 --- a/cogs/downloader.py +++ b/cogs/downloader.py | |||
| @@ -11,14 +11,10 @@ import discord | |||
| 11 | import re | 11 | import re |
| 12 | import yt_dlp | 12 | import yt_dlp |
| 13 | from discord.ext import commands | 13 | from discord.ext import commands |
| 14 | from dotenv import load_dotenv | ||
| 15 | import aiofiles | 14 | import aiofiles |
| 16 | 15 | ||
| 17 | logger = logging.getLogger(__name__) | 16 | logger = logging.getLogger(__name__) |
| 18 | 17 | ||
| 19 | # Load environment variables | ||
| 20 | load_dotenv() | ||
| 21 | |||
| 22 | 18 | ||
| 23 | class Downloader(commands.Cog): | 19 | class Downloader(commands.Cog): |
| 24 | def __init__(self, bot): | 20 | def __init__(self, bot): |
| @@ -70,7 +66,7 @@ class Downloader(commands.Cog): | |||
| 70 | logger.error(f"Details: {response['details']}") | 66 | logger.error(f"Details: {response['details']}") |
| 71 | 67 | ||
| 72 | @staticmethod | 68 | @staticmethod |
| 73 | async def download_standalone(url: str, catbox: bool = False, fformat: str = "mp4", filename_user: str = None): | 69 | async def download_standalone(url: str, catbox: bool = False, fformat: str = "mp4", filename_user: str | None = None): |
| 74 | try: | 70 | try: |
| 75 | logger.info(f"Downloading {url} as {fformat}") | 71 | logger.info(f"Downloading {url} as {fformat}") |
| 76 | 72 | ||
| @@ -88,7 +84,7 @@ class Downloader(commands.Cog): | |||
| 88 | return Downloader._return_file_response(actual_file, filename, temp_dir) | 84 | return Downloader._return_file_response(actual_file, filename, temp_dir) |
| 89 | 85 | ||
| 90 | except Exception as e: | 86 | except Exception as e: |
| 91 | return Downloader._create_error_response("Download failed", str(e), temp_dir if 'temp_dir' in locals() else None) | 87 | return Downloader._create_error_response("Download failed", str(e), None) |
| 92 | 88 | ||
| 93 | @staticmethod | 89 | @staticmethod |
| 94 | def _get_ydl_options(fformat: str, temp_dir: str) -> dict: | 90 | def _get_ydl_options(fformat: str, temp_dir: str) -> dict: |
