Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TAS2GIF #3

Open
wants to merge 1 commit into
base: slash
Choose a base branch
from

Conversation

probablypablito
Copy link

Adds a way to convert .TAS files to GIFs.

Adds a way to convert .TAS files to GIFs.
Copy link
Member

@ZatFinn ZatFinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this looks good to me.

from discord.ext import tasks
import discord
import requests
from config import celia_home
Copy link
Member

@ZatFinn ZatFinn Sep 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code assumes that celia_home ends with a "/", but paths aren't usually specified like that in configuration. This should either be communicated clearly or preferably the code should assume that it doesn't end in a "/". After all /directory//file usually results in the same thing as /directory/file but /directoryfile will definitely result in an error.

await asyncio.wait_for(process.wait(), max_seconds)
except asyncio.TimeoutError:
process.terminate()
print("yuh")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably forgot to remove this


# Estimate length of TAS file
try:
total_frames = attachment_file.decode("utf-8").count(",")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Balloon seeding (the stuff in []) will break this, as it also contains commas

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the process_inputs function in tas.py since it does something similar

@ZatFinn
Copy link
Member

ZatFinn commented Jun 8, 2024

Note that this uses pablito's fork of an outdated version of celia-web which in and of itself is outdated compared to gonen's upstream (wasn't the case at the time of this pr). The changes in the fork aren't major though I think it shouldn't be difficult to update it if someone took the time


async def setup(bot):
if not os.path.exists("files"): os.mkdir("files")
if not os.path.exists(celia_home + "files"): os.mkdir(celia_home + "/files")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably meant for these to be consistent (see acedic's comments about celia_home)

return r

async def run_celia(celia_home, cartname, max_seconds, ctx):
cmd = [f'{celia_home}love', '.', 'cctas', f'{cartname}', '-producegif']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should the love executable be inside the celia_home? I'd say it's better to assume that it's in PATH already


# Estimate length of TAS file
try:
total_frames = attachment_file.decode("utf-8").count(",")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the process_inputs function in tas.py since it does something similar

level = args[1]

# Download file
attachment_url = args[2] if len(args) > 2 else ctx.message.attachments[0].url
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having an attachment or a url causes the command to fail silently (and worse, gif_processing stays True forever)

async def tas2gif(self, ctx, *args):

global gif_processing
if (gif_processing):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not use this global variable at all here, instead @commands.cooldown of ~1 minute (which is the longest file you can upload) with a global bucket should work just as well while being simpler and less prone to bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants