|
|
@ -69,7 +69,19 @@ def post_img_local(mastodon, text, log, config): |
|
|
|
return media_dict; |
|
|
|
|
|
|
|
def post_unsplash_random_image(mastodon, log, config): |
|
|
|
response = requests.get('https://api.unsplash.com/photos/random?client_id=03ad5bfbaa0acd6c96a728d425e533683ec25e5fb7fcf99f6461720b3d0d75a1') |
|
|
|
collection_url = get_parameter("collection_url", config) |
|
|
|
unsplash_client_id = get_parameter("unsplash_client_id", config) |
|
|
|
collecion_file = open(collection_filepath,'r') |
|
|
|
collections = json.loads(collecion_file.read()) |
|
|
|
collecion_file.close() |
|
|
|
|
|
|
|
count_collection = len(collections)-1 |
|
|
|
if count_collection > -1: |
|
|
|
id_collection = randint(0,count_collection) |
|
|
|
collection_url="&collections="+str(collections[id_collection]) |
|
|
|
else: |
|
|
|
collection_url='' |
|
|
|
response = requests.get("https://api.unsplash.com/photos/random?client_id="+unsplash_client_id+collection_url) |
|
|
|
randim_json = json.loads(response.text) |
|
|
|
randim_url = "{}&q=85&crop=entropy&cs=tinysrgb&w=2048&fit=max".format(randim_json['urls']['raw']) |
|
|
|
|
|
|
|