mirror of
https://github.com/runyanjake/memechain.git
synced 2025-10-04 23:57:29 -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}")
|
print(f"Meme created! URL: {meme_url}")
|
||||||
return meme_url
|
return meme_url
|
||||||
else:
|
else:
|
||||||
|
print(f"Meme could not be created. Response code: {result}")
|
||||||
return None
|
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
|
import json
|
||||||
|
|
||||||
def download_image(input_data):
|
def download_image(input_data):
|
||||||
|
print(f"Downloading image with input data: {input_data}")
|
||||||
input_data = input_data.replace("'", '"')
|
input_data = input_data.replace("'", '"')
|
||||||
|
|
||||||
data = json.loads(input_data)
|
data = json.loads(input_data)
|
||||||
|
@ -2,10 +2,11 @@ import requests
|
|||||||
|
|
||||||
GET_MEMES_URL = "https://api.imgflip.com/get_memes"
|
GET_MEMES_URL = "https://api.imgflip.com/get_memes"
|
||||||
|
|
||||||
def get_memes(ignored):
|
def get_memes(ignored="ignored"):
|
||||||
return get_memes_helper()
|
return get_memes_helper()
|
||||||
|
|
||||||
def get_memes_helper():
|
def get_memes_helper():
|
||||||
|
print("Retrieving meme options...")
|
||||||
response = requests.get(GET_MEMES_URL)
|
response = requests.get(GET_MEMES_URL)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
||||||
|
@ -1,8 +1,20 @@
|
|||||||
|
import json
|
||||||
from caption_image import caption_image
|
from caption_image import caption_image
|
||||||
from download_image import download_image
|
from download_image import download_image
|
||||||
from get_memes import get_memes
|
from get_memes import get_memes
|
||||||
|
|
||||||
get_memes()
|
# Utilities to determine the template_id
|
||||||
meme_url = caption_image(20007896, "Top text", "Bottom text")
|
# memes = get_memes()
|
||||||
download_image(meme_url)
|
# 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