aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/music')
-rw-r--r--cogs/music/play.py7
-rw-r--r--cogs/music/play_compressed.py9
2 files changed, 11 insertions, 5 deletions
diff --git a/cogs/music/play.py b/cogs/music/play.py
index 5d82127..d902cdc 100644
--- a/cogs/music/play.py
+++ b/cogs/music/play.py
@@ -1,10 +1,13 @@
1import asyncio 1import asyncio
2import logging
2 3
3import discord 4import discord
4import yt_dlp 5import yt_dlp
5from discord.ext import commands 6from discord.ext import commands
6from youtubesearchpython import VideosSearch 7from youtubesearchpython import VideosSearch
7 8
9logger = logging.getLogger(__name__)
10
8# Suppress noise about console usage from yt-dlp 11# Suppress noise about console usage from yt-dlp
9yt_dlp.utils.bug_reports_message = lambda: '' 12yt_dlp.utils.bug_reports_message = lambda: ''
10 13
@@ -45,13 +48,13 @@ class Play(commands.Cog):
45 48
46 def after_playing(error): 49 def after_playing(error):
47 if error: 50 if error:
48 print(f'Player error: {error}') 51 logger.error(f'Player error: {error}')
49 coro = vc.disconnect() 52 coro = vc.disconnect()
50 fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop) 53 fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop)
51 try: 54 try:
52 fut.result() 55 fut.result()
53 except Exception as e: 56 except Exception as e:
54 print(f'Error disconnecting: {e}') 57 logger.error(f'Error disconnecting: {e}', exc_info=True)
55 58
56 source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) 59 source = discord.FFmpegPCMAudio(url2, **ffmpeg_options)
57 vc.play(source, after=after_playing) 60 vc.play(source, after=after_playing)
diff --git a/cogs/music/play_compressed.py b/cogs/music/play_compressed.py
index 0d4901c..038a15e 100644
--- a/cogs/music/play_compressed.py
+++ b/cogs/music/play_compressed.py
@@ -1,4 +1,5 @@
1import asyncio 1import asyncio
2import logging
2import os 3import os
3import subprocess 4import subprocess
4 5
@@ -6,6 +7,8 @@ import discord
6from discord.ext import commands 7from discord.ext import commands
7from youtubesearchpython import VideosSearch 8from youtubesearchpython import VideosSearch
8 9
10logger = logging.getLogger(__name__)
11
9 12
10class GrajcujZkompresowane(commands.Cog): 13class GrajcujZkompresowane(commands.Cog):
11 def __init__(self, bot): 14 def __init__(self, bot):
@@ -20,7 +23,7 @@ class GrajcujZkompresowane(commands.Cog):
20 modified.write(f"{title}\n".encode('utf-8')) 23 modified.write(f"{title}\n".encode('utf-8'))
21 modified.write(data) 24 modified.write(data)
22 except Exception as e: 25 except Exception as e:
23 print(f"Failed to prepend title: {e}") 26 logger.error(f"Failed to prepend title: {e}", exc_info=True)
24 27
25 @staticmethod 28 @staticmethod
26 def compress_audio(input_path): 29 def compress_audio(input_path):
@@ -84,13 +87,13 @@ class GrajcujZkompresowane(commands.Cog):
84 title = found_title 87 title = found_title
85 def after_playing(error): 88 def after_playing(error):
86 if error: 89 if error:
87 print(f'Player error: {error}') 90 logger.error(f'Player error: {error}')
88 coro = vc.disconnect() 91 coro = vc.disconnect()
89 fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop) 92 fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop)
90 try: 93 try:
91 fut.result() 94 fut.result()
92 except Exception as e: 95 except Exception as e:
93 print(f'Error disconnecting: {e}') 96 logger.error(f'Error disconnecting: {e}', exc_info=True)
94 97
95 if vc.is_playing() or vc.is_paused(): 98 if vc.is_playing() or vc.is_paused():
96 vc.stop() 99 vc.stop()