Merge pull request #1809 from ochen1/patch-1

Don't give up searching for accessToken in HAR file
This commit is contained in:
H Lohaus 2024-04-09 18:18:58 +02:00 committed by GitHub
commit af03693204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,7 +54,10 @@ def readHAR():
if arkPreURL in v['request']['url']: if arkPreURL in v['request']['url']:
chatArks.append(parseHAREntry(v)) chatArks.append(parseHAREntry(v))
elif v['request']['url'] == sessionUrl: elif v['request']['url'] == sessionUrl:
accessToken = json.loads(v["response"]["content"]["text"]).get("accessToken") try:
accessToken = json.loads(v["response"]["content"]["text"]).get("accessToken")
except KeyError:
continue
cookies = {c['name']: c['value'] for c in v['request']['cookies']} cookies = {c['name']: c['value'] for c in v['request']['cookies']}
if not accessToken: if not accessToken:
raise NoValidHarFileError("No accessToken found in .har files") raise NoValidHarFileError("No accessToken found in .har files")
@ -127,4 +130,4 @@ async def getArkoseAndAccessToken(proxy: str):
if chatArk is None: if chatArk is None:
return None, accessToken, cookies return None, accessToken, cookies
newReq = genArkReq(chatArk) newReq = genArkReq(chatArk)
return await sendRequest(newReq, proxy), accessToken, cookies return await sendRequest(newReq, proxy), accessToken, cookies