diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index 885aa85..ceb1860 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -37,7 +37,7 @@ jobs: images: lanqian528/chat2api tags: | type=raw,value=latest,enable={{is_default_branch}} - type=raw,value=v1.4.10 + type=raw,value=v1.4.11 - name: Build and push uses: docker/build-push-action@v5 diff --git a/README.md b/README.md index 7979362..0e13101 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ ## 功能 -### 最新版 v1.4.10 +### 最新版 v1.4.11 > 已完成 > - [x] 流式、非流式传输 diff --git a/chatgpt/proofofWork.py b/chatgpt/proofofWork.py index 3b024e9..7ab56bc 100644 --- a/chatgpt/proofofWork.py +++ b/chatgpt/proofofWork.py @@ -388,7 +388,6 @@ class ScriptSrcParser(HTMLParser): if "src" in attrs_dict: src = attrs_dict["src"] cached_scripts.append(src) - print(cached_scripts) match = re.search(r"c/[^/]*/_", src) if match: cached_dpl = match.group(0) @@ -396,19 +395,18 @@ class ScriptSrcParser(HTMLParser): def get_data_build_from_html(html_content): + global cached_scripts, cached_dpl, cached_time parser = ScriptSrcParser() parser.feed(html_content) - get_data_build_from_document_element(html_content) - return cached_dpl - - -def get_data_build_from_document_element(html_content): - global cached_dpl, cached_time - match = re.search(r']*data-build="([^"]*)"', html_content) - if match: - data_build = match.group(1) - cached_time = int(time.time()) - logger.info(f"Found dpl: {data_build}") + if not cached_scripts: + cached_scripts.append("https://chatgpt.com/backend-api/sentinel/sdk.js") + if not cached_dpl: + match = re.search(r']*data-build="([^"]*)"', html_content) + if match: + data_build = match.group(1) + cached_dpl = data_build + cached_time = int(time.time()) + logger.info(f"Found dpl: {cached_dpl}") async def get_dpl(service): @@ -428,8 +426,9 @@ async def get_dpl(service): raise Exception("No Cached DPL") else: return True - except Exception: - cached_dpl = "remix-prod-14f2d9d20b1dff8b7a6ecf23d472dbc30191dfaa" + except Exception as e: + logger.info(f"Failed to get dpl: {e}") + cached_dpl = None cached_time = int(time.time()) return False diff --git a/utils/config.py b/utils/config.py index ba542d9..598128b 100644 --- a/utils/config.py +++ b/utils/config.py @@ -49,7 +49,7 @@ proxy_url_list = proxy_url.split(',') if proxy_url else [] user_agents_list = ast.literal_eval(user_agents) logger.info("-" * 60) -logger.info("Chat2Api 1.4.10 | https://github.com/lanqian528/chat2api") +logger.info("Chat2Api 1.4.11 | https://github.com/lanqian528/chat2api") logger.info("-" * 60) logger.info("Environment variables:") logger.info("API_PREFIX: " + str(api_prefix))