aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music/play_compressed.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cogs/music/play_compressed.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/cogs/music/play_compressed.py b/cogs/music/play_compressed.py
index 3297110..f14d75b 100644
--- a/cogs/music/play_compressed.py
+++ b/cogs/music/play_compressed.py
@@ -1,15 +1,18 @@
1import discord
2from discord.ext import commands
3import asyncio 1import asyncio
4import os 2import os
5import subprocess 3import subprocess
4
5import discord
6from discord.ext import commands
6from youtubesearchpython import VideosSearch 7from youtubesearchpython import VideosSearch
7 8
9
8class GrajcujZkompresowane(commands.Cog): 10class GrajcujZkompresowane(commands.Cog):
9 def __init__(self, bot): 11 def __init__(self, bot):
10 self.bot = bot 12 self.bot = bot
11 13
12 def prepend_title_to_file(self, file_path, title): 14 @staticmethod
15 def prepend_title_to_file(file_path, title):
13 try: 16 try:
14 with open(file_path, 'rb') as original: 17 with open(file_path, 'rb') as original:
15 data = original.read() 18 data = original.read()
@@ -19,7 +22,8 @@ class GrajcujZkompresowane(commands.Cog):
19 except Exception as e: 22 except Exception as e:
20 print(f"Failed to prepend title: {e}") 23 print(f"Failed to prepend title: {e}")
21 24
22 def compress_audio(self, input_path): 25 @staticmethod
26 def compress_audio(input_path):
23 base, ext = os.path.splitext(input_path) 27 base, ext = os.path.splitext(input_path)
24 output_path = f"{base}_compressed{ext}" 28 output_path = f"{base}_compressed{ext}"
25 ffmpeg_command = f"ffmpeg -i {input_path} -ar 8000 -ac 1 -b:a 500 -acodec libmp3lame -q:a 9 {output_path}" 29 ffmpeg_command = f"ffmpeg -i {input_path} -ar 8000 -ac 1 -b:a 500 -acodec libmp3lame -q:a 9 {output_path}"
@@ -84,5 +88,6 @@ class GrajcujZkompresowane(commands.Cog):
84 else: 88 else:
85 await ctx.followup.send(f"dodano do koleyjki (zkompresowane): {title}") 89 await ctx.followup.send(f"dodano do koleyjki (zkompresowane): {title}")
86 90
91
87def setup(bot): 92def setup(bot):
88 bot.add_cog(GrajcujZkompresowane(bot)) \ No newline at end of file 93 bot.add_cog(GrajcujZkompresowane(bot))