diff options
Diffstat (limited to '')
| -rw-r--r-- | cogs/music/play_compressed.py | 15 |
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 @@ | |||
| 1 | import discord | ||
| 2 | from discord.ext import commands | ||
| 3 | import asyncio | 1 | import asyncio |
| 4 | import os | 2 | import os |
| 5 | import subprocess | 3 | import subprocess |
| 4 | |||
| 5 | import discord | ||
| 6 | from discord.ext import commands | ||
| 6 | from youtubesearchpython import VideosSearch | 7 | from youtubesearchpython import VideosSearch |
| 7 | 8 | ||
| 9 | |||
| 8 | class GrajcujZkompresowane(commands.Cog): | 10 | class 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 | |||
| 87 | def setup(bot): | 92 | def setup(bot): |
| 88 | bot.add_cog(GrajcujZkompresowane(bot)) \ No newline at end of file | 93 | bot.add_cog(GrajcujZkompresowane(bot)) |
