XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

fix: Update header fallback for last-modified date in copy_images.py

- In g4f/image/copy_images.py, modified the line that retrieves the "date" header - Changed from `date = response.headers.get("date")` to `date = response.headers.get("last-modified", response.headers.get("date"))` to fallback to "date" if "last-modified" is missing - No other files or functions were modified besides this line

6120c791
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

2 个文件 +2 -6
Modified g4f/api/__init__.py +1 -5
@@ -60,7 +60,7 @@ import g4f.debug
60 60 from g4f.client import AsyncClient, ChatCompletion, ImagesResponse, ClientResponse
61 61 from g4f.providers.response import BaseConversation, JsonConversation
62 62 from g4f.client.helper import filter_none
63 from g4f.image import is_data_an_media, process_image, EXTENSIONS_MAP
63 from g4f.image import EXTENSIONS_MAP, is_data_an_media, process_image
64 64 from g4f.image.copy_images import get_media_dir, copy_media, get_source_url
65 65 from g4f.errors import ProviderNotFoundError, ModelNotFoundError, MissingAuthError, NoValidHarFileError, MissingRequirementsError
66 66 from g4f.cookies import read_cookie_files, get_cookies_dir
@@ -119,10 +119,6 @@ def create_app():
119 119 gui_app = WSGIMiddleware(get_gui_app(AppConfig.demo))
120 120 app.mount("/", gui_app)
121 121
122 # Read cookie files if not ignored
123 if not AppConfig.ignore_cookie_files:
124 read_cookie_files()
125
126 122 if AppConfig.ignored_providers:
127 123 for provider in AppConfig.ignored_providers:
128 124 if provider in Provider.__map__:
Modified g4f/image/copy_images.py +1 -1
@@ -158,7 +158,7 @@ async def copy_media(
158 158 # Use aiohttp to fetch the image
159 159 async with session.get(image, ssl=request_ssl, headers=request_headers) as response:
160 160 response.raise_for_status()
161 date = response.headers.get("date")
161 date = response.headers.get("last-modified", response.headers.get("date"))
162 162 if date and target_path != target:
163 163 timestamp = datetime.strptime(date, '%a, %d %b %Y %H:%M:%S %Z').timestamp()
164 164 filename = str(int(timestamp)) + "_" + filename.split("_", maxsplit=1)[-1]