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/music/audio_playback.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/music/audio_playback.py')
| -rw-r--r-- | cogs/music/audio_playback.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/cogs/music/audio_playback.py b/cogs/music/audio_playback.py index 75608b8..1267fa7 100644 --- a/cogs/music/audio_playback.py +++ b/cogs/music/audio_playback.py | |||
| @@ -81,11 +81,8 @@ class AudioPlaybackManager: | |||
| 81 | """Prepare audio source for playback. Returns (source, final_display_name).""" | 81 | """Prepare audio source for playback. Returns (source, final_display_name).""" |
| 82 | if is_url: | 82 | if is_url: |
| 83 | # For URLs, use FFmpeg with the direct URL and extract clean filename | 83 | # For URLs, use FFmpeg with the direct URL and extract clean filename |
| 84 | ffmpeg_options = { | 84 | before_options = "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5" |
| 85 | "options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", | 85 | audio_source = discord.FFmpegPCMAudio(source, before_options=before_options) |
| 86 | "before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", | ||
| 87 | } | ||
| 88 | audio_source = discord.FFmpegPCMAudio(source, **ffmpeg_options) | ||
| 89 | # Extract clean filename for URL (remove extension and decode URL encoding) | 86 | # Extract clean filename for URL (remove extension and decode URL encoding) |
| 90 | filename = os.path.basename(source.split("?")[0]) # Remove query parameters | 87 | filename = os.path.basename(source.split("?")[0]) # Remove query parameters |
| 91 | filename = urllib.parse.unquote(filename) # Decode URL encoding | 88 | filename = urllib.parse.unquote(filename) # Decode URL encoding |
| @@ -97,7 +94,7 @@ class AudioPlaybackManager: | |||
| 97 | 94 | ||
| 98 | # Try to get metadata for local files | 95 | # Try to get metadata for local files |
| 99 | try: | 96 | try: |
| 100 | metadata = mutagen.File(source) | 97 | metadata = mutagen.open(source) # type: ignore[call-overload] |
| 101 | if metadata: | 98 | if metadata: |
| 102 | title = ( | 99 | title = ( |
| 103 | metadata.get("title", [None])[0] | 100 | metadata.get("title", [None])[0] |
| @@ -152,8 +149,8 @@ class AudioPlaybackManager: | |||
| 152 | ) | 149 | ) |
| 153 | 150 | ||
| 154 | # Stop any currently playing audio | 151 | # Stop any currently playing audio |
| 155 | if vc.is_playing() or vc.is_paused(): | 152 | if vc.is_playing() or vc.is_paused(): # type: ignore[union-attr] |
| 156 | vc.stop() | 153 | vc.stop() # type: ignore[union-attr] |
| 157 | 154 | ||
| 158 | # Prepare audio source | 155 | # Prepare audio source |
| 159 | ( | 156 | ( |
