-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: slash
Are you sure you want to change the base?
Add TAS2GIF #3
Conversation
Adds a way to convert .TAS files to GIFs.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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(",") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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") |
There was a problem hiding this comment.
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'] |
There was a problem hiding this comment.
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(",") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
Adds a way to convert .TAS files to GIFs.