Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Decode Error #4

Open
PythonX-001 opened this issue Nov 28, 2023 · 14 comments
Open

JSON Decode Error #4

PythonX-001 opened this issue Nov 28, 2023 · 14 comments

Comments

@PythonX-001
Copy link

Traceback (most recent call last):
File "e:\FILES\Documents\Web-Dev-Project\Chat-Bot\api\test2.py", line 5, in
lex = Lexica(query="icecream",cookie=cookie).generate()
File "e:\FILES\Documents\Web-Dev-Project\Chat-Bot\api\Lex.py", line 50, in generate
return [f"https://image.lexica.art/full_jpg/{ids['id']}" for ids in response.json()["images"]]
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx_models.py", line 756, in json
return jsonlib.loads(self.text, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@dimaischenko
Copy link

@PythonX-001 @NotCookey It seems that the format of their backend api has changed, I tried to track it but I still don’t understand the reason.

The endpoint itself has changed from https://z.lexica.art/api/generator to https://lexica.art/api/generator

And it seems that payload has a new parameter s that is some kind of secret key string.

Screenshot 2023-12-12 at 09 53 50

@dimaischenko
Copy link

@NotCookey

I spent several hours fiddling around with reverse engineering. So far no success. I tried repeating one-to-one session GET and generate POST requests using curl (copied requests, headers and payloads from Chrome Developer Tools), with passing cookies but it didn’t work. In the best case it gives the response with text message refresh the page and try again on generate request. I will be glad if you try it too and say something, to be honest, I’m not a big expert in web queries.

@NotCookey
Copy link
Owner

@NotCookey

I spent several hours fiddling around with reverse engineering. So far no success. I tried repeating one-to-one session GET and generate POST requests using curl (copied requests, headers and payloads from Chrome Developer Tools), with passing cookies but it didn’t work. In the best case it gives the response with text message refresh the page and try again on generate request. I will be glad if you try it too and say something, to be honest, I’m not a big expert in web queries.

Hey @dimaischenko , thanks for digging into this! Turns out the API revamped its encryption logic, making user access a no-go. Personal stuff kept me swamped, but I'm free after tomorrow to check their new logic. Thank you for giving your time to look into this!

@FranRguez
Copy link

I spent a few hours with this but no sucess. Please update us if there's any development, this is very interesting! Thank you

@dimaischenko
Copy link

Looks like they've added more security. But in general there should be an approach that would allow generating, we just need to better understand web requests 🤔

In general it’s strange that they themselves don’t provide an official API, that would be cool.

@NotCookey
Copy link
Owner

I found the logic behind the webapp's new security system but it seems they removed the free trial generation so I can't test to see if it works. Let me find some workarounds.

@dimaischenko
Copy link

dimaischenko commented Jan 22, 2024

@NotCookey Hey-hey, no chance?

@NotCookey
Copy link
Owner

@NotCookey Hey-hey, no chance?

I've tired but apparently I can't seem to get access to the generator so I can't really check if the new code works. They have the subscription thing they prevents people for trying it for free.

@dimaischenko
Copy link

@NotCookey if you want i can share my account with you for testing

@NotCookey
Copy link
Owner

@NotCookey if you want i can share my account with you for testing

That would be a big help, I'm open to collaborations but currently I'm a little inactive for this project due to some personal stuffs. I will get back to this soon but till then i will provide the resources I've found and extracted from the site.

Opening inspect tool and go to sources tab and then if you expand __next/static->chunks->app->aperture then open the js file starting with page-3db and search for b = { you will find that codeblock that makes the request and it has most of the logic. You can try tracing back where the logic comes from aka the functions that provide the value most of it is already in this repos script all we need is the new values like s, sourceActions, etc.

image

@dimaischenko
Copy link

That would be a big help, I'm open to collaborations but currently I'm a little inactive for this project due to some personal stuffs.

Nice! Thank you! I'll try to figure it out soon, if it works out I'll make a pull request

@dimaischenko
Copy link

I can't figure out how to get s is some variable value that is obtained by encrypt function, which in turn depends on some other function imported from outside. Not easy 🤔

@dimaischenko
Copy link

And in general, it seems that Lexica project is "frozen". In their Discord in all channels in the latest messages people ask to add API, but all messages without response.

@NotCookey
Copy link
Owner

I can't figure out how to get s is some variable value that is obtained by encrypt function, which in turn depends on some other function imported from outside. Not easy 🤔

Thank you for trying out. At this point I've realized lexica was once an usable free to generate site with now it went entirely paid so I don't think there would be much point in making an api for it. I checked the encrypt function and traced it back to different files where everything is from a function that is a. But honestly the userbase of lexica is mostly paid and I'm thinking of reverse engineering an entirely different ai that offers thousands and not just some exclusive models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants