From 66bbf3a1267090c1a929f613140a99eb3878081d Mon Sep 17 00:00:00 2001 From: Darshit Solanki Date: Sun, 8 Oct 2023 14:11:03 +0530 Subject: [PATCH] Update utils.py Microsoft updated 'Bing Image Search API' which created incompatibility with the search_images_bing() function. The issue is now resolved. --- utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 64cc2cf3b..6d5bf6f80 100644 --- a/utils.py +++ b/utils.py @@ -31,12 +31,12 @@ def get_image_files_sorted(path, recurse=True, folders=None): return get_image_f from msrest.authentication import CognitiveServicesCredentials as auth def search_images_bing(key, term, min_sz=128, max_images=150): - params = {'q':term, 'count':max_images, 'min_height':min_sz, 'min_width':min_sz} + params = {'q':term, 'count':max_images, 'minHeight':min_sz, 'minWidth':min_sz, 'imageType':'photo'} headers = {"Ocp-Apim-Subscription-Key":key} search_url = "https://api.bing.microsoft.com/v7.0/images/search" response = requests.get(search_url, headers=headers, params=params) response.raise_for_status() - search_results = response.json() + search_results = response.json() return L(search_results['value'])