<commit_before>import discord
import ffmpeg
import subprocess
from io import BytesIO
from discord.ext import commands

from acolyte.util.http import Http
from acolyte.util.fs import Filesystem
from acolyte.util.magic import Magic

UPLOAD_LIMIT_IN_BYTES = 8388119


class Audio(commands.Cog):
    """ Post-avant jazzcore"""

    def __init__(self, bot):
        self.bot = bot
        self.http = Http(self.bot.session)
        self.fs = Filesystem()
        self.magic = Magic()


    @commands.group()
    async def nightcore(self, ctx):
        """ Nightcore commands! """
        if ctx.invoked_subcommand is None:
            await ctx.send("Invalid nightcore command!!")

    @nightcore.group()
    async def images(self, ctx):
        """ COOL ANIME PICS commands! """
        if ctx.invoked_subcommand is None:
            await ctx.send("Invalid images command!!")

    @nightcore.command()
    async def generate(self, ctx):
        """ ONE TWO SEVEN THREE DOWN TO ROCKEFELLER STREET """
        if len(ctx.message.attachments) != 1:
            return await ctx.send("Only one song per upload please thanks ok bye!!")

        # Just get the first one for now
        attachment = ctx.message.attachments[0]
        filename = ''.join(attachment.filename.split('.')[:-1])

        path = self.fs.make_path(f"./assets/{filename}")
        song = await self.http.download(attachment.url)

        extension = self.magic.get_audio_extension(song)

        if song is None:
            return await ctx.send("Couldn't download the song! I think it's Discord's fault!!")
        
        if extension is None:
            return await ctx.send("What the HECK is this file, I don't think it's audio!!")

        await self.fs.write_binary_file(path, song)

        audio_input = (
            ffmpeg.input(path, format=extension)
                  .audio
                  .filter("atempo", 1.06)
                  .filter("asetrate", 44100 * 1.25)
        )

        video_input = ffmpeg.input(self.fs.get_random_file_path("./assets/cool_anime_pics"))

        stream = ffmpeg.output(audio_input, video_input, "pipe:", format="webm").get_args()
        process = subprocess.Popen(
            ["ffmpeg"] + ["-loglevel", "panic"] + stream,
            stdout=subprocess.PIPE
        )

        print(f"Generating nightcore for {ctx.author}...")

        nightcored = BytesIO(process.communicate(input=song)[0])
        filename = f"Nightcore - {filename}.webm"

        print("Done! Uploading...")<commit_msg>Add a reaction to valid requests<commit_after>import discord
import ffmpeg
import subprocess
from io import BytesIO
from discord.ext import commands

from acolyte.util.http import Http
from acolyte.util.fs import Filesystem
from acolyte.util.magic import Magic

UPLOAD_LIMIT_IN_BYTES = 8388119


class Audio(commands.Cog):
    """ Post-avant jazzcore"""

    def __init__(self, bot):
        self.bot = bot
        self.http = Http(self.bot.session)
        self.fs = Filesystem()
        self.magic = Magic()


    @commands.group()
    async def nightcore(self, ctx):
        """ Nightcore commands! """
        if ctx.invoked_subcommand is None:
            await ctx.send("Invalid nightcore command!!")

    @nightcore.group()
    async def images(self, ctx):
        """ COOL ANIME PICS commands! """
        if ctx.invoked_subcommand is None:
            await ctx.send("Invalid images command!!")

    @nightcore.command()
    async def generate(self, ctx):
        """ ONE TWO SEVEN THREE DOWN TO ROCKEFELLER STREET """
        message = ctx.message

        if len(message.attachments) < 1:
            return await ctx.send("Hey I need a song!!")

        # Just get the first one for now
        attachment = message.attachments[0]
        filename = ''.join(attachment.filename.split('.')[:-1])

        path = self.fs.make_path(f"./assets/{filename}")
        song = await self.http.download(attachment.url)
        extension = self.magic.get_audio_extension(song)

        if song is None:
            return await ctx.send("Couldn't download the song! I think it's Discord's fault!!")
        
        if extension is None:
            return await ctx.send("What the HECK is this file, I don't think it's audio!!")

        await message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
        await self.fs.write_binary_file(path, song)

        audio_input = (
            ffmpeg.input(path, format=extension)
                  .audio
                  .filter("atempo", 1.06)
                  .filter("asetrate", 44100 * 1.25)
        )

        video_input = ffmpeg.input(self.fs.get_random_file_path("./assets/cool_anime_pics"))

        stream = ffmpeg.output(audio_input, video_input, "pipe:", format="webm").get_args()
        process = subprocess.Popen(
            ["ffmpeg"] + ["-loglevel", "panic"] + stream,
            stdout=subprocess.PIPE
        )

        print(f"Generating nightcore for {ctx.author}...")

        nightcored = BytesIO(process.communicate(input=song)[0])
        filename = f"Nightcore - {filename}.webm"

        print("Done! Uploading...")
{'fraction_non_alphanumeric': 0.11894963746815598, 'fraction_numerical': 0.008622378992749364, 'mean_word_length': 2.4049366244162775, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7214138', 'n_tokens_mistral': 1594, 'n_tokens_neox': 1513, 'n_words': 385}