diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-19 15:43:32 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-19 15:43:32 +0200 |
| commit | 1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0 (patch) | |
| tree | f11dc45777d8b3c8ff0e2ca16be83f85b272bd48 /cogs/music/play_commands.py | |
| parent | test: add cron tests + improve existing tests (diff) | |
| download | senator-sperma-1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0.tar.gz senator-sperma-1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0.zip | |
refactor: simplify cogs, reduce complexity
- Remove unused imports and dead code
- Cleaner error handling
- Reduce cognitive complexity
Diffstat (limited to '')
| -rw-r--r-- | cogs/music/play_commands.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/cogs/music/play_commands.py b/cogs/music/play_commands.py index fd5113a..a82fa9d 100644 --- a/cogs/music/play_commands.py +++ b/cogs/music/play_commands.py | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | import logging | 6 | import logging |
| 7 | import os | 7 | import os |
| 8 | import urllib.parse | 8 | import urllib.parse |
| 9 | import asyncio | ||
| 9 | from os import PathLike | 10 | from os import PathLike |
| 10 | from typing import Awaitable, Callable, List, Tuple | 11 | from typing import Awaitable, Callable, List, Tuple |
| 11 | 12 | ||
| @@ -139,9 +140,10 @@ class PlayCommands(commands.Cog): | |||
| 139 | local_path = os.path.join(self.temp_dir, filename) | 140 | local_path = os.path.join(self.temp_dir, filename) |
| 140 | os.makedirs(self.temp_dir, exist_ok=True) | 141 | os.makedirs(self.temp_dir, exist_ok=True) |
| 141 | 142 | ||
| 143 | loop = asyncio.get_event_loop() | ||
| 142 | with open(local_path, "wb") as f: | 144 | with open(local_path, "wb") as f: |
| 143 | async for chunk in response.content.iter_chunked(8192): | 145 | async for chunk in response.content.iter_chunked(8192): |
| 144 | f.write(chunk) | 146 | await loop.run_in_executor(None, f.write, chunk) |
| 145 | 147 | ||
| 146 | compressed_path = await media_processing.AudioCompressor.compress( | 148 | compressed_path = await media_processing.AudioCompressor.compress( |
| 147 | ctx, local_path | 149 | ctx, local_path |
