18 lines
527 B
Python
18 lines
527 B
Python
import requests
|
|
|
|
import get_from_reddit
|
|
|
|
def change_avatar():
|
|
image = None
|
|
while not image:
|
|
image = get_from_reddit.get_image(boards='smuganimegirls')
|
|
extension = image.split('.')[-1]
|
|
local_smug = "/tmp/smug.{}".format(extension)
|
|
|
|
# save an image locally
|
|
if extension.lower() in ['png', 'jpg']:
|
|
with open(local_smug, 'wb') as f:
|
|
f.write(requests.get(image).content)
|
|
return open(local_smug, 'rb').read()
|
|
else:
|
|
image = None |