FireHead90544 / craiyon.py

Unofficial API Wrapper for craiyon.com (DAL-E-MINI). Generate awesome images from text tokens.
Apache License 2.0
69 stars 22 forks source link

Mimetype error with async functions #17

Closed brett-cohen closed 9 months ago

brett-cohen commented 1 year ago

The switch to CloudScraper worked for the standard generate function. However, the async functions are still throwing Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'.

Recommend using a library like aiocfscrape to support CloudScraper's functionality for the async functions.

mdm9300404 commented 1 year ago

I have been looking for something similar to aiocfscrape for such a long time. Thanks for the suggestion!

@FireHead90544 Think we should implement it?

FireHead90544 commented 1 year ago

The switch to CloudScraper worked for the standard generate function. However, the async functions are still throwing Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'.

Recommend using a library like aiocfscrape to support CloudScraper's functionality for the async functions.

Oh so that's it, I totally forgot about the async-calls. That's a great idea.

FireHead90544 commented 1 year ago

I have been looking for something similar to aiocfscrape for such a long time. Thanks for the suggestion!

@FireHead90544 Think we should implement it?

Yea, I guess we should go with it.

sionit1337 commented 1 year ago

How to solve this problem if my discord bot returns this error?

FireHead90544 commented 1 year ago

How to solve this problem if my discord bot returns this error?

Will be updating the logic for async calls soon using aiocfscrape or alternative probably

sionit1337 commented 1 year ago

Will be updating the logic for async calls soon using aiocfscrape or alternative probably

And when will the fix be released?

truongquangtung2020 commented 1 year ago

Can you make an example for me pls?

FireHead90544 commented 9 months ago

Refer to this comment regarding more details: https://github.com/FireHead90544/craiyon.py/issues/19#issuecomment-1906038250

TL;DR: Removed the cloudscraper dependency and switched to using headers. v3 works normally, v1 sometimes fails.

Update the wrapper by running: pip install -U craiyon.py

Reopen the issue if this issue still persists