added alt

This commit is contained in:
Juli 2024-09-20 12:50:09 +03:00
parent 76b08174d3
commit 6746af5c3a
5 changed files with 15 additions and 10 deletions

10
.env
View file

@ -1,7 +1,7 @@
baseurl=https://yourinstance.com/api baseurl=https://eepykitty.lol/api
secret=bot secret from get_apps.py here secret=u17dsYbrNtByjNHs4M6YE9kqNERF2Ppm
api_key=apikey generated from the misskey ui api_key=GiUvYKqXWw1WNXVcIVmBCwwwCiSzAmbj
searchquery=yaoi rating:general order:random searchquery=yaoi rating:general order:random
bannedtags=["meme", "nazi", "military", "war","nsfw","sex","penis","pussy"] bannedtags=["meme", "nazi", "military", "war","nsfw","sex","penis","pussy"]
danbooru_user=username of the bots danbooru account danbooru_user=Yaoibot
danbooru_apikey=api key for danbooru danbooru_apikey=VKiPjDiknJZB57yNHzFvEYXX

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.env

Binary file not shown.

View file

@ -54,6 +54,8 @@ def get_image_url(post):
else: else:
print("Image URL not found in the post data.") print("Image URL not found in the post data.")
return None return None
def get_artist_names(post): def get_artist_names(post):
return post['tag_string_artist'].split(',') if 'tag_string_artist' in post else [] return post['tag_string_artist'].split(',') if 'tag_string_artist' in post else []
@ -62,6 +64,7 @@ def main():
random_post = fetch_random_post() random_post = fetch_random_post()
if random_post: if random_post:
print(f"URL: https://danbooru.donmai.us/posts/{random_post['id']}") print(f"URL: https://danbooru.donmai.us/posts/{random_post['id']}")
print(random_post["tag_string_character"])
image_url = get_image_url(random_post) image_url = get_image_url(random_post)
# if image_url: # if image_url:
# r = requests.get(image_url) # r = requests.get(image_url)
@ -78,7 +81,7 @@ def main():
else: else:
artists = "Unknown" artists = "Unknown"
return f"https://danbooru.donmai.us/posts/{random_post['id']}", image_url, artists return f"https://danbooru.donmai.us/posts/{random_post['id']}", image_url, artists, random_post["tag_string_character"]
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View file

@ -33,13 +33,14 @@ def post(text,id):
def upload_url(fileurl): def upload_url(fileurl,comment):
path = "/drive/files/upload-from-url" path = "/drive/files/upload-from-url"
url = baseurl+path url = baseurl+path
data = { data = {
"url": fileurl, "url": fileurl,
"appSecret": os.getenv("secret") "appSecret": os.getenv("secret"),
"comment":comment
} }
@ -77,9 +78,9 @@ def get_id(filename):
return get_id(filename) return get_id(filename)
def main(): def main():
posturl, url, artists = image_source.main() posturl, url, artists, characters = image_source.main()
filename = url.split("/")[len(url.split("/"))-1] filename = url.split("/")[len(url.split("/"))-1]
upload_url(url) upload_url(url, f"SFW yaoi art of the following characters : {characters}")
post(f"Artist(s): {artists}\nSource: {posturl}",get_id(filename)) post(f"Artist(s): {artists}\nSource: {posturl}",get_id(filename))