add xmr.pm upload

This commit is contained in:
dsc 2022-09-05 23:02:42 +03:00
parent e6d773f70a
commit 7b12c98b07

20
main.py
View file

@ -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)