diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-29 14:22:03 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-29 14:22:03 +0200 |
| commit | dba3388567818cb5c60be9d406d3e1cccc84b3ea (patch) | |
| tree | 53a0903f7a4c381c7ad12e3e632ef8dd8ebba39f /cogs/music | |
| parent | multitude of changes. (diff) | |
| download | senator-sperma-dba3388567818cb5c60be9d406d3e1cccc84b3ea.tar.gz senator-sperma-dba3388567818cb5c60be9d406d3e1cccc84b3ea.zip | |
Refactor database connections and add integration tests
- Use context managers for sqlite3 connections in cron, vclogs, and database utils
- Add URL helper utility for yt-dlp with clean_url_for_ytdlp function
- Add slow integration test markers and new integration test files
- Fix test imports to use conftest directly instead of tests.conftest
- Improve downloader error handling and use COPYPARTY_URL_UPLOAD env var
- Update pytest.ini with slow test markers and warning filters
- Document slow test usage in AGENTS.md
Diffstat (limited to '')
| -rw-r--r-- | cogs/music/media_processing.py | 2 | ||||
| -rw-r--r-- | cogs/music/play_commands.py | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/cogs/music/media_processing.py b/cogs/music/media_processing.py index b9b814c..91bd406 100644 --- a/cogs/music/media_processing.py +++ b/cogs/music/media_processing.py | |||
| @@ -9,6 +9,7 @@ import os | |||
| 9 | 9 | ||
| 10 | import yt_dlp | 10 | import yt_dlp |
| 11 | from youtubesearchpython import VideosSearch | 11 | from youtubesearchpython import VideosSearch |
| 12 | from cogs.utils.url_helper import clean_url_for_ytdlp | ||
| 12 | 13 | ||
| 13 | logger = logging.getLogger(__name__) | 14 | logger = logging.getLogger(__name__) |
| 14 | 15 | ||
| @@ -36,6 +37,7 @@ class MediaDownloader: | |||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | try: | 39 | try: |
| 40 | url = clean_url_for_ytdlp(url) | ||
| 39 | with yt_dlp.YoutubeDL(ytdl_opts) as ydl: | 41 | with yt_dlp.YoutubeDL(ytdl_opts) as ydl: |
| 40 | info_dict = ydl.extract_info(url, download=True) | 42 | info_dict = ydl.extract_info(url, download=True) |
| 41 | # Get the base filename without extension | 43 | # Get the base filename without extension |
diff --git a/cogs/music/play_commands.py b/cogs/music/play_commands.py index c53dbc7..bdb021d 100644 --- a/cogs/music/play_commands.py +++ b/cogs/music/play_commands.py | |||
| @@ -19,6 +19,7 @@ from discord.ext import commands | |||
| 19 | from cogs.music import audio_playback, media_processing | 19 | from cogs.music import audio_playback, media_processing |
| 20 | from cogs.utils.file_search import UniversalSearcher | 20 | from cogs.utils.file_search import UniversalSearcher |
| 21 | from cogs.utils.settings import get_uploadurl | 21 | from cogs.utils.settings import get_uploadurl |
| 22 | from cogs.utils.url_helper import clean_url_for_ytdlp | ||
| 22 | 23 | ||
| 23 | logger = logging.getLogger(__name__) | 24 | logger = logging.getLogger(__name__) |
| 24 | 25 | ||
| @@ -193,6 +194,7 @@ class PlayCommands(commands.Cog): | |||
| 193 | } | 194 | } |
| 194 | 195 | ||
| 195 | loop = asyncio.get_event_loop() | 196 | loop = asyncio.get_event_loop() |
| 197 | url = clean_url_for_ytdlp(url) | ||
| 196 | with YoutubeDL(ytdl_opts) as ydl: | 198 | with YoutubeDL(ytdl_opts) as ydl: |
| 197 | info_dict = await loop.run_in_executor( | 199 | info_dict = await loop.run_in_executor( |
| 198 | None, lambda: ydl.extract_info(url, download=True) | 200 | None, lambda: ydl.extract_info(url, download=True) |
