返回提交历史
Modified
g4f/Provider/needs_auth/Video.py
+7
-7
XFEstudio/gpt4free
Fix video api
e8d7fccf
代码差异
1 个文件
+7
-7
@@ -33,7 +33,7 @@ class Video(AsyncGeneratorProvider):
33
33
#"https://aistudio.google.com/generate-video"
34
34
]
35
35
pub_url = "https://home.g4f.dev"
36
api_url = f"{pub_url}/backend-api/v2/create"
36
api_url = f"{pub_url}/backend-api/v2/create?provider=Video&cache=true&prompt="
37
37
search_url = f"{pub_url}/search/video+"
38
38
drive_url = "https://www.googleapis.com/drive/v3/"
39
39
@@ -64,16 +64,16 @@ class Video(AsyncGeneratorProvider):
64
64
async with ClientSession() as session:
65
65
async with session.get(cls.search_url + quote_plus(prompt), timeout=ClientTimeout(total=10)) as response:
66
66
if response.status == 200:
67
if response.headers.get("content-type", "text/plain").startswith("text/pain"):
68
data = (await response.text()).split("\n")
69
yield VideoResponse([f"{cls.pub_url}{url}" if url.startswith("/") else url for url in data], prompt)
70
return
71
67
yield VideoResponse(str(response.url), prompt)
72
68
return
73
async with session.post(cls.api_url.format(prompt=quote(prompt)), timeout=ClientTimeout(total=10)) as response:
74
if response.status != 200:
69
async with session.post(cls.api_url + quote(prompt)) as response:
70
if not response.ok:
75
71
debug.error(f"Failed to connect to Video API: {response.status}")
76
72
else:
73
if response.headers.get("content-type", "text/plain").startswith("text/pain"):
74
data = (await response.text()).split("\n")
75
yield VideoResponse([f"{cls.pub_url}{url}" if url.startswith("/") else url for url in data], prompt)
76
return
77
77
yield VideoResponse(str(response.url), prompt)
78
78
return
79
79
raise MissingRequirementsError("Video provider requires a browser to be installed.")