Initial commit
This commit is contained in:
commit
1a6725c839
4 changed files with 66 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
post.sh
|
||||
.venv
|
||||
.env
|
4
example.env
Normal file
4
example.env
Normal file
|
@ -0,0 +1,4 @@
|
|||
GELBOORU_API_UID=42069
|
||||
GELBOORU_API_KEY=api-key
|
||||
PLEROMA_INSTANCE=https://incest.world
|
||||
PLEROMA_ACCESS_TOKEN=access-token
|
36
post.py
Normal file
36
post.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import anyio
|
||||
from mastodon import Mastodon
|
||||
from pygelbooru import Gelbooru
|
||||
from dotenv import dotenv_values
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
config = dotenv_values(".env")
|
||||
gelbooru = Gelbooru(config["GELBOORU_API_KEY"], config["GELBOORU_API_UID"])
|
||||
|
||||
async def main():
|
||||
masto = Mastodon(api_base_url = config["PLEROMA_INSTANCE"], access_token = config["PLEROMA_ACCESS_TOKEN"], feature_set = "pleroma")
|
||||
|
||||
try:
|
||||
posts = await gelbooru.search_posts(tags=["sort:random", "rating:s", "yuri", "sisters"], exclude_tags=["ai_generated"])
|
||||
result = posts[0]
|
||||
|
||||
req = Request(url=result.file_url, headers={"User-Agent": "Mozilla/5.0"})
|
||||
data = urlopen(req).read()
|
||||
|
||||
file = open("/tmp/" + result.filename, "wb")
|
||||
file.write(data)
|
||||
file.close()
|
||||
|
||||
tags = " ".join(result.tags)
|
||||
medias = masto.media_post("/tmp/" + result.filename, description=tags)
|
||||
|
||||
source = ""
|
||||
if result.source != None:
|
||||
source = "[source](" + result.source + ")"
|
||||
|
||||
masto.status_post(source, content_type="text/markdown", media_ids=medias)
|
||||
except Exception:
|
||||
import traceback
|
||||
masto.status_post("@ashley@incest.world\n\n" + traceback.format_exc(), visibility="direct", spoiler_text="error!!!")
|
||||
|
||||
anyio.run(main)
|
23
requirements.txt
Normal file
23
requirements.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
aiohappyeyeballs==2.4.2
|
||||
aiohttp==3.10.7
|
||||
aiosignal==1.3.1
|
||||
attrs==24.2.0
|
||||
blurhash==1.1.4
|
||||
certifi==2024.8.30
|
||||
charset-normalizer==3.3.2
|
||||
decorator==5.1.1
|
||||
frozenlist==1.4.1
|
||||
furl==2.1.3
|
||||
idna==3.10
|
||||
Mastodon.py==1.8.1
|
||||
multidict==6.1.0
|
||||
orderedmultidict==1.0.1
|
||||
pygelbooru==0.5.0
|
||||
python-dateutil==2.9.0.post0
|
||||
python-dotenv==1.0.1
|
||||
python-magic==0.4.27
|
||||
requests==2.32.3
|
||||
six==1.16.0
|
||||
urllib3==2.2.3
|
||||
xmltodict==0.13.0
|
||||
yarl==1.13.1
|
Loading…
Reference in a new issue