mirror of
https://github.com/hibobmaster/matrix_chatgpt_bot.git
synced 2024-10-01 05:35:36 -04:00
Fix redirect failed
This commit is contained in:
parent
f5f8ef8429
commit
6f1420f484
@ -46,10 +46,15 @@ class ImageGen:
|
|||||||
url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=4&FORM=GENCRE"
|
url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=4&FORM=GENCRE"
|
||||||
response = self.session.post(url, allow_redirects=False)
|
response = self.session.post(url, allow_redirects=False)
|
||||||
if response.status_code != 302:
|
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, allow_redirects=False)
|
||||||
|
if response3.status_code != 302:
|
||||||
logger.error(f"ERROR: {response.text}")
|
logger.error(f"ERROR: {response.text}")
|
||||||
return []
|
return []
|
||||||
|
response=response3
|
||||||
# Get redirect URL
|
# Get redirect URL
|
||||||
redirect_url = response.headers["Location"]
|
redirect_url = response.headers["Location"].replace("&nfy=1", "")
|
||||||
request_id = redirect_url.split("id=")[-1]
|
request_id = redirect_url.split("id=")[-1]
|
||||||
self.session.get(f"{BING_URL}{redirect_url}")
|
self.session.get(f"{BING_URL}{redirect_url}")
|
||||||
# https://www.bing.com/images/create/async/results/{ID}?q={PROMPT}
|
# https://www.bing.com/images/create/async/results/{ID}?q={PROMPT}
|
||||||
|
@ -6,6 +6,7 @@ RUN pip3 install --user -r /requirements.txt && rm /requirements.txt
|
|||||||
|
|
||||||
|
|
||||||
FROM python:3.11-alpine as runner
|
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
|
RUN apk update && apk add olm-dev libmagic
|
||||||
COPY --from=pybuilder /root/.local /usr/local
|
COPY --from=pybuilder /root/.local /usr/local
|
||||||
COPY --from=pybuilder /usr/share/zoneinfo /usr/share/zoneinfo
|
COPY --from=pybuilder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||||
|
Loading…
Reference in New Issue
Block a user