diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-05-18 23:18:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-18 23:18:32 +0200 |
commit | 97ce36a217b7998aee460c62c926c0c1f6f3baf6 (patch) | |
tree | 4a137ca4958a81272e37f952b9330a197038f83f /g4f/Provider/you | |
parent | Merge pull request #1974 from hlohaus/leech (diff) | |
parent | Add get/set cookies dir, hide prompt option in gui (diff) | |
download | gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.gz gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.bz2 gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.lz gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.xz gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.zst gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.zip |
Diffstat (limited to 'g4f/Provider/you')
-rw-r--r-- | g4f/Provider/you/har_file.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/g4f/Provider/you/har_file.py b/g4f/Provider/you/har_file.py index 870c388e..71d741fd 100644 --- a/g4f/Provider/you/har_file.py +++ b/g4f/Provider/you/har_file.py @@ -7,6 +7,7 @@ import random import logging from ...requests import StreamSession, raise_for_status +from ...cookies import get_cookies_dir from ...errors import MissingRequirementsError from ... import debug @@ -28,10 +29,9 @@ public_token = "public-token-live-507a52ad-7e69-496b-aee0-1c9863c7c819" chatArks: list = None def readHAR(): - dirPath = "./" harPath = [] chatArks = [] - for root, dirs, files in os.walk(dirPath): + for root, dirs, files in os.walk(get_cookies_dir()): for file in files: if file.endswith(".har"): harPath.append(os.path.join(root, file)) @@ -65,16 +65,10 @@ def parseHAREntry(entry) -> arkReq: return tmpArk async def sendRequest(tmpArk: arkReq, proxy: str = None): - try: - async with StreamSession(headers=tmpArk.arkHeaders, cookies=tmpArk.arkCookies, proxy=proxy) as session: - async with session.post(tmpArk.arkURL, data=tmpArk.arkBody) as response: - await raise_for_status(response) - return await response.text() - except RuntimeError as e: - if str(e) == "Event loop is closed": - print("Event loop is closed error occurred in sendRequest.") - else: - raise + async with StreamSession(headers=tmpArk.arkHeaders, cookies=tmpArk.arkCookies, proxy=proxy) as session: + async with session.post(tmpArk.arkURL, data=tmpArk.arkBody) as response: + await raise_for_status(response) + return await response.text() async def create_telemetry_id(proxy: str = None): global chatArks |