Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

Commit 47cd8a5

Browse files
committed
add jimeng-video-3.0-fast for Asia international sites
1 parent 7922bc9 commit 47cd8a5

8 files changed

Lines changed: 1262 additions & 1211 deletions

File tree

README.CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ A: 可以。现在支持直接上传本地文件。请参考上方的“本地
448448
- `jimeng-video-sora2` - Sora2模型,仅亚洲国际站 (HK/JP/SG) 支持
449449
- `jimeng-video-3.0-pro` - 专业版,国内站和亚洲国际站 (HK/JP/SG) 支持
450450
- `jimeng-video-3.0` - 标准版,国内/国际站均支持
451-
- `jimeng-video-3.0-fast` - 极速版(仅国内站支持)
451+
- `jimeng-video-3.0-fast` - 极速版,国内站和亚洲国际站 (HK/JP/SG) 支持
452452
- `jimeng-video-2.0-pro` - 专业版v2,国内站和亚洲国际站 (HK/JP/SG) 支持
453453
- `jimeng-video-2.0` - 标准版v2,国内站和亚洲国际站 (HK/JP/SG) 支持
454454

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ Generate a video from a text prompt (Text-to-Video) or from start/end frame imag
427427
- `jimeng-video-sora2` - Sora2 model, Asia international sites only (HK/JP/SG)
428428
- `jimeng-video-3.0-pro` - Professional Edition, China and Asia international sites (HK/JP/SG)
429429
- `jimeng-video-3.0` - Standard Edition, works on all sites
430-
- `jimeng-video-3.0-fast` - Fast Edition (China site only)
430+
- `jimeng-video-3.0-fast` - Fast Edition, China and Asia international sites (HK/JP/SG)
431431
- `jimeng-video-2.0-pro` - Professional Edition v2, China and Asia international sites (HK/JP/SG)
432432
- `jimeng-video-2.0` - Standard Edition v2, China and Asia international sites (HK/JP/SG)
433433

package-lock.json

Lines changed: 54 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/consts/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const VIDEO_MODEL_MAP_ASIA = {
8585
"jimeng-video-3.5-pro": "dreamina_ic_generate_video_model_vgfm_3.5_pro",
8686
"jimeng-video-3.0-pro": "dreamina_ic_generate_video_model_vgfm_3.0_pro",
8787
"jimeng-video-3.0": "dreamina_ic_generate_video_model_vgfm_3.0",
88+
"jimeng-video-3.0-fast": "dreamina_ic_generate_video_model_vgfm_3.0_fast",
8889
"jimeng-video-2.0": "dreamina_ic_generate_video_model_vgfm_lite",
8990
"jimeng-video-2.0-pro": "dreamina_ic_generate_video_model_vgfm1.0"
9091
};

src/api/controllers/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import logger from "@/lib/logger.ts";
99
import util from "@/lib/util.ts";
1010
import { JimengErrorHandler, JimengErrorResponse } from "@/lib/error-handler.ts";
1111
import { BASE_URL_DREAMINA_US, BASE_URL_DREAMINA_HK } from "@/api/consts/dreamina.ts";
12+
1213
import {
1314
BASE_URL_CN,
1415
BASE_URL_US_COMMERCE,

src/api/controllers/videos.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import _ from "lodash";
22
import fs from "fs-extra";
3+
import axios from "axios";
34

45
import APIException from "@/lib/exceptions/APIException.ts";
6+
57
import EX from "@/api/consts/exceptions.ts";
68
import util from "@/lib/util.ts";
79
import { getCredit, receiveCredit, request, parseRegionFromToken, getAssistantId, RegionInfo } from "./core.ts";
@@ -64,11 +66,13 @@ async function uploadImageFromFile(file: any, refreshToken: string, regionInfo:
6466
async function uploadImageFromUrl(imageUrl: string, refreshToken: string, regionInfo: RegionInfo): Promise<string> {
6567
try {
6668
logger.info(`开始从URL下载并上传视频图片: ${imageUrl}`);
67-
const imageResponse = await fetch(imageUrl);
68-
if (!imageResponse.ok) {
69+
const imageResponse = await axios.get(imageUrl, {
70+
responseType: 'arraybuffer',
71+
});
72+
if (imageResponse.status < 200 || imageResponse.status >= 300) {
6973
throw new Error(`下载图片失败: ${imageResponse.status}`);
7074
}
71-
const imageBuffer = await imageResponse.arrayBuffer();
75+
const imageBuffer = imageResponse.data;
7276
return await uploadImageBuffer(imageBuffer, refreshToken, regionInfo);
7377
} catch (error: any) {
7478
logger.error(`从URL上传视频图片失败: ${error.message}`);

src/lib/image-uploader.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import crypto from "crypto";
2+
import axios from "axios";
23
import { RegionInfo, request } from "@/api/controllers/core.ts";
34
import { RegionUtils } from "@/lib/region-utils.ts";
45
import { createSignature } from "@/lib/aws-signature.ts";
@@ -69,8 +70,9 @@ export async function uploadImageBuffer(
6970

7071
let applyResponse;
7172
try {
72-
applyResponse = await fetch(applyUrl, {
73+
applyResponse = await axios({
7374
method: 'GET',
75+
url: applyUrl,
7476
headers: {
7577
'accept': '*/*',
7678
'accept-language': 'zh-CN,zh;q=0.9',
@@ -87,19 +89,20 @@ export async function uploadImageBuffer(
8789
'x-amz-date': timestamp,
8890
'x-amz-security-token': session_token,
8991
},
92+
validateStatus: () => true,
9093
});
9194
} catch (fetchError: any) {
9295
logger.error(`Fetch请求失败,目标URL: ${applyUrl}`);
9396
logger.error(`错误详情: ${fetchError.message}`);
9497
throw new Error(`网络请求失败 (${applyUrlHost}): ${fetchError.message}. 请检查: 1) 网络连接是否正常 2) 是否需要配置代理 3) DNS是否能解析该域名`);
9598
}
9699

97-
if (!applyResponse.ok) {
98-
const errorText = await applyResponse.text();
100+
if (applyResponse.status < 200 || applyResponse.status >= 300) {
101+
const errorText = typeof applyResponse.data === 'string' ? applyResponse.data : JSON.stringify(applyResponse.data);
99102
throw new Error(`申请上传权限失败: ${applyResponse.status} - ${errorText}`);
100103
}
101104

102-
const applyResult = await applyResponse.json();
105+
const applyResult = applyResponse.data;
103106

104107
if (applyResult?.ResponseMetadata?.Error) {
105108
throw new Error(`申请上传权限失败: ${JSON.stringify(applyResult.ResponseMetadata.Error)}`);
@@ -123,8 +126,9 @@ export async function uploadImageBuffer(
123126
// 第三步:上传图片文件
124127
let uploadResponse;
125128
try {
126-
uploadResponse = await fetch(uploadUrl, {
129+
uploadResponse = await axios({
127130
method: 'POST',
131+
url: uploadUrl,
128132
headers: {
129133
'Accept': '*/*',
130134
'Accept-Language': 'zh-CN,zh;q=0.9',
@@ -140,16 +144,17 @@ export async function uploadImageBuffer(
140144
'Sec-Fetch-Site': 'cross-site',
141145
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36',
142146
},
143-
body: imageBuffer,
147+
data: imageBuffer,
148+
validateStatus: () => true,
144149
});
145150
} catch (fetchError: any) {
146151
logger.error(`图片文件上传fetch请求失败,目标URL: ${uploadUrl}`);
147152
logger.error(`错误详情: ${fetchError.message}`);
148153
throw new Error(`图片上传网络请求失败 (${uploadHost}): ${fetchError.message}. 请检查网络连接`);
149154
}
150155

151-
if (!uploadResponse.ok) {
152-
const errorText = await uploadResponse.text();
156+
if (uploadResponse.status < 200 || uploadResponse.status >= 300) {
157+
const errorText = typeof uploadResponse.data === 'string' ? uploadResponse.data : JSON.stringify(uploadResponse.data);
153158
throw new Error(`图片上传失败: ${uploadResponse.status} - ${errorText}`);
154159
}
155160

@@ -174,8 +179,9 @@ export async function uploadImageBuffer(
174179

175180
let commitResponse;
176181
try {
177-
commitResponse = await fetch(commitUrl, {
182+
commitResponse = await axios({
178183
method: 'POST',
184+
url: commitUrl,
179185
headers: {
180186
'accept': '*/*',
181187
'accept-language': 'zh-CN,zh;q=0.9',
@@ -194,20 +200,21 @@ export async function uploadImageBuffer(
194200
'x-amz-security-token': session_token,
195201
'x-amz-content-sha256': payloadHash,
196202
},
197-
body: commitPayload,
203+
data: commitPayload,
204+
validateStatus: () => true,
198205
});
199206
} catch (fetchError: any) {
200207
logger.error(`提交上传fetch请求失败,目标URL: ${commitUrl}`);
201208
logger.error(`错误详情: ${fetchError.message}`);
202209
throw new Error(`提交上传网络请求失败 (${applyUrlHost}): ${fetchError.message}. 请检查网络连接`);
203210
}
204211

205-
if (!commitResponse.ok) {
206-
const errorText = await commitResponse.text();
212+
if (commitResponse.status < 200 || commitResponse.status >= 300) {
213+
const errorText = typeof commitResponse.data === 'string' ? commitResponse.data : JSON.stringify(commitResponse.data);
207214
throw new Error(`提交上传失败: ${commitResponse.status} - ${errorText}`);
208215
}
209216

210-
const commitResult = await commitResponse.json();
217+
const commitResult = commitResponse.data;
211218

212219
if (commitResult?.ResponseMetadata?.Error) {
213220
throw new Error(`提交上传失败: ${JSON.stringify(commitResult.ResponseMetadata.Error)}`);
@@ -247,12 +254,14 @@ export async function uploadImageFromUrl(
247254
try {
248255
logger.info(`开始从URL下载并上传图片: ${imageUrl}`);
249256

250-
const imageResponse = await fetch(imageUrl);
251-
if (!imageResponse.ok) {
257+
const imageResponse = await axios.get(imageUrl, {
258+
responseType: 'arraybuffer',
259+
});
260+
if (imageResponse.status < 200 || imageResponse.status >= 300) {
252261
throw new Error(`下载图片失败: ${imageResponse.status}`);
253262
}
254263

255-
const imageBuffer = await imageResponse.arrayBuffer();
264+
const imageBuffer = imageResponse.data;
256265
return await uploadImageBuffer(imageBuffer, refreshToken, regionInfo);
257266
} catch (error: any) {
258267
logger.error(`从URL上传图片失败: ${error.message}`);

0 commit comments

Comments
 (0)