diff --git a/BingImageGen.py b/BingImageGen.py index ba7a081..75fe7cd 100644 --- a/BingImageGen.py +++ b/BingImageGen.py @@ -46,10 +46,15 @@ class ImageGen: url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=4&FORM=GENCRE" response = self.session.post(url, allow_redirects=False) if response.status_code != 302: - logger.error(f"ERROR: {response.text}") - return [] + #if rt4 fails, try rt3 + url= f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=3&FORM=GENCRE" + response3 = self.session.post(url, allow_redirects=False) + if response3.status_code != 302: + logger.error(f"ERROR: {response.text}") + return [] + response=response3 # Get redirect URL - redirect_url = response.headers["Location"] + redirect_url = response.headers["Location"].replace("&nfy=1", "") request_id = redirect_url.split("id=")[-1] self.session.get(f"{BING_URL}{redirect_url}") # https://www.bing.com/images/create/async/results/{ID}?q={PROMPT} diff --git a/Dockerfile b/Dockerfile index edee77e..fbe1d73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN pip3 install --user -r /requirements.txt && rm /requirements.txt FROM python:3.11-alpine as runner +LABEL "org.opencontainers.image.source"="https://github.com/hibobmaster/matrix_chatgpt_bot" RUN apk update && apk add olm-dev libmagic COPY --from=pybuilder /root/.local /usr/local COPY --from=pybuilder /usr/share/zoneinfo /usr/share/zoneinfo