@fre4x/gemini 1.0.49 → 1.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67523,6 +67523,24 @@ function getAi() {
|
|
|
67523
67523
|
}
|
|
67524
67524
|
return ai;
|
|
67525
67525
|
}
|
|
67526
|
+
function createVideoOperation(name) {
|
|
67527
|
+
const operation = new GenerateVideosOperation();
|
|
67528
|
+
operation.name = name;
|
|
67529
|
+
return operation;
|
|
67530
|
+
}
|
|
67531
|
+
function withApiKey(videoUrl) {
|
|
67532
|
+
const apiKey = getApiKey();
|
|
67533
|
+
try {
|
|
67534
|
+
const url2 = new URL(videoUrl);
|
|
67535
|
+
if (!url2.searchParams.has("key")) {
|
|
67536
|
+
url2.searchParams.set("key", apiKey);
|
|
67537
|
+
}
|
|
67538
|
+
return url2.toString();
|
|
67539
|
+
} catch {
|
|
67540
|
+
const separator = videoUrl.includes("?") ? "&" : "?";
|
|
67541
|
+
return `${videoUrl}${separator}key=${encodeURIComponent(apiKey)}`;
|
|
67542
|
+
}
|
|
67543
|
+
}
|
|
67526
67544
|
var FILE_EXT_TO_MIME = {
|
|
67527
67545
|
".png": "image/png",
|
|
67528
67546
|
".jpg": "image/jpeg",
|
|
@@ -68020,9 +68038,7 @@ async function getVideoStatus(rawArgs) {
|
|
|
68020
68038
|
return textResult(lines2.join("\n"));
|
|
68021
68039
|
}
|
|
68022
68040
|
const op = await getAi().operations.getVideosOperation({
|
|
68023
|
-
operation:
|
|
68024
|
-
name: operation_name
|
|
68025
|
-
}
|
|
68041
|
+
operation: createVideoOperation(operation_name)
|
|
68026
68042
|
});
|
|
68027
68043
|
if (!op.done) {
|
|
68028
68044
|
return textResult(
|
|
@@ -68054,7 +68070,7 @@ ${JSON.stringify(op.response, null, 2)}`
|
|
|
68054
68070
|
videos.map(async (url2, index) => {
|
|
68055
68071
|
const fname = `video-${Date.now()}-${index + 1}.mp4`;
|
|
68056
68072
|
const fpath = path2.join(output_dir, fname);
|
|
68057
|
-
const videoResp = await fetch(url2);
|
|
68073
|
+
const videoResp = await fetch(withApiKey(url2));
|
|
68058
68074
|
if (!videoResp.ok) {
|
|
68059
68075
|
throw new Error(
|
|
68060
68076
|
`Failed to download video: ${videoResp.status}`
|