Ejemplo n.º 1
0
    async def save(self, ctx, *, label : str = ''):
        dirty_label = label.strip()
        label = self.cleanup_label(dirty_label)
        
        video = media_cache.get_from_cache(str(ctx.channel.id))
        if(video is None):
            await ctx.send("There is no video to bookmark, upload one and try again")
            return
        video = video[-1]

        query = {'user':ctx.author.id, 'label':label}
        new_values = {'$set': {'video':video}}
        result = db.inv.update_one(query, new_values, upsert=True)
        if(dirty_label != label): # Needed to remove some invalid chars from label
            await ctx.send(f'I saved your bookmark as `{label}`')
        else: # Label was clean from the start!
            await ctx.message.add_reaction('\U0001F44D')
Ejemplo n.º 2
0
    async def img2vid(self, ctx):
        await video_creator.set_progress_bar(ctx.message, 0)
        input_filepath = media_cache.get_from_cache(str(ctx.message.channel.id))[-1]
        output_filename = 'vids/' + str(ctx.message.channel.id) + '.mp4'
        await video_creator.set_progress_bar(ctx.message, 1)

        await video_creator.set_progress_bar(ctx.message, 2)
        subprocess.run([
            'ffmpeg',
            '-loop', '1',
            '-i', f'{input_filepath}',
            '-t', '1',
            output_filename
        ])
        await video_creator.set_progress_bar(ctx.message, 3)
        if(os.path.isfile(output_filename)):
            await ctx.send(file=discord.File(output_filename))
            os.remove(output_filename)
        else:
            await ctx.send(f'There was an error converting the image (`{input_filepath}`) to a video.')
        await ctx.message.clear_reactions()
Ejemplo n.º 3
0
 async def link(self, ctx):
     vid_link = media_cache.get_from_cache(str(ctx.message.channel.id))[0]
     await ctx.send(f'`{vid_link}`')