Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio committed Jun 2, 2023
1 parent f01728b commit a82fdf9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/BingImageCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def get_images(self, prompt: str) -> list:
url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=4&FORM=GENCRE"
response = self.session.post(
url,
follow_redirects=False,
allow_redirects=False,
data=payload,
timeout=200,
)
Expand All @@ -126,13 +126,12 @@ def get_images(self, prompt: str) -> list:
if response.status_code != 302:
# if rt4 fails, try rt3
url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=3&FORM=GENCRE"
response3 = self.session.post(url, follow_redirects=False, timeout=200)
if response3.status_code != 302:
response = self.session.post(url, allow_redirects=False, timeout=200)
if response.status_code != 302:
if self.debug_file:
self.debug(f"ERROR: {error_redirect}")
print(f"ERROR: {response3.text}")
print(f"ERROR: {response.text}")
raise Exception(error_redirect)
response = response3
# Get redirect URL
redirect_url = response.headers["Location"].replace("&nfy=1", "")
request_id = redirect_url.split("id=")[-1]
Expand Down

0 comments on commit a82fdf9

Please sign in to comment.