diff --git a/main.py b/main.py index f57ca74..a5d68fb 100644 --- a/main.py +++ b/main.py @@ -54,14 +54,14 @@ async def send_post(post: E621Post, tag_list: List[str]): file.write((await client.get(post.file.url)).content) file.name = f'file.{post.file.ext}' file.seek(0) - if post.file.ext == 'webm': + if post.file.ext in ('webm', 'gif'): with TemporaryDirectory() as td: - webm_path = Path(td) / 'video.webm' + src_path = Path(td) / f'video.{post.file.ext}' mp4_path = Path(td) / 'video.mp4' - with open(webm_path, 'wb') as webm: + with open(src_path, 'wb') as webm: webm.write(file.read()) ffmpeg\ - .input(str(webm_path))\ + .input(str(src_path))\ .output(str(mp4_path), vcodec='libx264', crf='26')\ .run() s3 = boto3.client('s3', aws_access_key_id=os.environ['AWS_ACCESS_KEY'], aws_secret_access_key=os.environ['AWS_SECRET_KEY']) @@ -71,16 +71,8 @@ async def send_post(post: E621Post, tag_list: List[str]): await bot.send_message(int(os.environ['SEND_CHAT']), f'https://{bucket}.s3.amazonaws.com/{upload_filename}\n\n' + caption, parse_mode=ParseMode.HTML) - webm_path.unlink() + src_path.unlink() mp4_path.unlink() - elif post.file.ext == 'gif': - await bot.send_animation(int(os.environ['SEND_CHAT']), - file, - width=post.file.width, - height=post.file.height, - thumb=post.preview.url, - caption=caption, - parse_mode=ParseMode.HTML) elif post.file.ext in ('png', 'jpg'): if post.file.size > 10000000: logging.warning('compressing')