Add cat says stuff (untested)
This commit is contained in:
1 parent
8d26043c93
commit
aa8b8937c0
2 files changed
+11
-3
No files matched your search
@@ -7,7 +7,14 @@ import urllib.request
|
||||
from io import BytesIO
|
||||
|
||||
def cat(w, h):
|
||||
url = f'https://cataas.com/cat/says/henlo?size=100&width={w}?height={h}?text=cat'
|
||||
url = f'https://cataas.com/cat/width={w}?height={h}?text=cat'
|
||||
resp = urllib.request.urlopen(url)
|
||||
im_data = resp.read()
|
||||
im = Image.open(BytesIO(im_data))
|
||||
return im
|
||||
|
||||
def cat_says(text,w, h):
|
||||
url = f'https://cataas.com/cat/says/{text}?size=100&width={w}?height={h}?text=cat'
|
||||
resp = urllib.request.urlopen(url)
|
||||
im_data = resp.read()
|
||||
im = Image.open(BytesIO(im_data))
|
||||
|
||||
+3
-2
@@ -6,7 +6,7 @@ from itertools import product
|
||||
import string
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from cat import cat
|
||||
from cat import cat, cat_says
|
||||
import argparse
|
||||
|
||||
# parser stuff
|
||||
@@ -18,10 +18,10 @@ parser.add_argument('port')
|
||||
parser.add_argument('-i','--image')
|
||||
parser.add_argument('-r','--random', action='store_true')
|
||||
parser.add_argument('-c','--cat', action='store_true')
|
||||
parser.add_argument('-cs','--catsays')
|
||||
parser.add_argument('-wd','--width', default=0)
|
||||
parser.add_argument('-ht','--height', default=0)
|
||||
args = parser.parse_args()
|
||||
|
||||
HOST, PORT = args.hostname, int(args.port)
|
||||
|
||||
# change start point if requested
|
||||
@@ -44,6 +44,7 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
|
||||
# open image to be sent or query a cat image
|
||||
if args.cat: im = cat(sizew,sizeh)
|
||||
elif args.catsays: im = cat_says(args.catsays,sizew,sizeh)
|
||||
elif image in args: im = Image.open(args.image)
|
||||
|
||||
pixels = list(im.getdata())
|
||||
|
||||
Reference in new issue
Block a user