From 7b12c98b07a6489eb2f0715698af834f13ca901c Mon Sep 17 00:00:00 2001 From: dsc Date: Mon, 5 Sep 2022 23:02:42 +0300 Subject: [PATCH] add xmr.pm upload --- main.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 1679e02..74333ba 100644 --- a/main.py +++ b/main.py @@ -85,6 +85,24 @@ class Task: bg.paste(img, (x_start + x_offset, y_start + y_offset)) return bg + async def post_image_xmr(self, image) -> str: + url = 'https://dumb.ai.xmr.pm/paste/img' + timeout = aiohttp.ClientTimeout(total=10) + + data = aiohttp.FormData() + data.add_field('files[]', image, filename='lol.jpg', content_type='image/jpg') + + try: + async with aiohttp.ClientSession( + timeout=timeout, + headers={"User-Agent": "w0w"}) as session: + async with session.post(url, data=data) as resp: + blob = await resp.json() + return f"https://dumb.ai.xmr.pm{blob['redirect']}" + + except Exception as ex: + raise Exception("Could not upload file to xmr.pm :((") + async def post_image_lewd(self, image) -> str: timeout = aiohttp.ClientTimeout(total=5) @@ -273,7 +291,7 @@ async def main(): image_bytes.seek(0) try: - url = await task.post_image_lewd(image_bytes) + url = await task.post_image_xmr(image_bytes) except Exception as ex: _err(task, err=f"image upload: {ex}") _lower_author_task_count(task.author)