mirror of
https://github.com/runyanjake/memechain.git
synced 2025-10-04 15:57:28 -07:00
Update toolsg
This commit is contained in:
parent
f6c3640b5f
commit
90769ea58a
@ -37,4 +37,5 @@ def caption_image(input_data):
|
||||
print(f"Meme created! URL: {meme_url}")
|
||||
return meme_url
|
||||
else:
|
||||
print(f"Meme could not be created. Response code: {result}")
|
||||
return None
|
||||
|
4
tools/config.json.example
Normal file
4
tools/config.json.example
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"username":"imgflip_username",
|
||||
"password":"imgflip_password"
|
||||
}
|
@ -3,6 +3,7 @@ import requests
|
||||
import json
|
||||
|
||||
def download_image(input_data):
|
||||
print(f"Downloading image with input data: {input_data}")
|
||||
input_data = input_data.replace("'", '"')
|
||||
|
||||
data = json.loads(input_data)
|
||||
|
@ -2,10 +2,11 @@ import requests
|
||||
|
||||
GET_MEMES_URL = "https://api.imgflip.com/get_memes"
|
||||
|
||||
def get_memes(ignored):
|
||||
def get_memes(ignored="ignored"):
|
||||
return get_memes_helper()
|
||||
|
||||
def get_memes_helper():
|
||||
print("Retrieving meme options...")
|
||||
response = requests.get(GET_MEMES_URL)
|
||||
result = response.json()
|
||||
|
||||
|
@ -1,8 +1,20 @@
|
||||
import json
|
||||
from caption_image import caption_image
|
||||
from download_image import download_image
|
||||
from get_memes import get_memes
|
||||
|
||||
get_memes()
|
||||
meme_url = caption_image(20007896, "Top text", "Bottom text")
|
||||
download_image(meme_url)
|
||||
# Utilities to determine the template_id
|
||||
# memes = get_memes()
|
||||
# print(memes)
|
||||
|
||||
# After determining the template_id, manually add it to the below json.
|
||||
input_data = """
|
||||
{
|
||||
"template_id": 87743020,
|
||||
"text": ["generated meme", "langchain error"]
|
||||
}
|
||||
"""
|
||||
meme_url = caption_image(input_data)
|
||||
input_data = json.dumps({"url": meme_url})
|
||||
download_image(input_data)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user