@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
100 lines • 4.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dreamactor = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class Dreamactor {
constructor() {
this.description = {
displayName: 'Wiro - DreamActor - Image-to-Video Generation',
name: 'dreamactor',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'Generate videos from images with DreamActor AI by ByteDance. Perfect for creating animated cont',
defaults: {
name: 'Wiro - DreamActor - Image-to-Video Generation',
},
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
usableAsTool: true,
credentials: [
{
name: 'wiroApi',
required: true,
},
],
properties: [
{
displayName: 'Input Image URL',
name: 'inputImageUrl',
type: 'string',
default: '',
required: true,
description: 'Format: jpeg, jpg or png. Size: maximum 4.7 MB. Resolution: between 480✖️480 and 1920✖️1080 (anything larger will be proportionally reduced) Image supports driving for real people, animation, pets, etc.; overly abstract subjects may fail to generate',
},
{
displayName: 'Video URL',
name: 'inputVideoUrl',
type: 'string',
default: '',
required: true,
description: 'Format: mp4 or webm. Duration: maximum 30 seconds. Resolution: between 200✖️200 and 2048✖️1440(2K) supports both facial expressions and body movement driving, and can handle full-body, half-body, or portrait driving: source: Video (supports real people, animation, pets) range: Full face + body',
},
],
};
}
async execute() {
const returnData = [];
const inputImageUrl = this.getNodeParameter('inputImageUrl', 0);
const inputVideoUrl = this.getNodeParameter('inputVideoUrl', 0);
const credentials = await this.getCredentials('wiroApi');
const apiKey = credentials.apiKey;
const apiSecret = credentials.apiSecret;
const headers = (0, auth_1.generateWiroAuthHeaders)(apiKey, apiSecret);
const response = await this.helpers.httpRequest({
method: 'POST',
url: 'https://api.wiro.ai/v1/Run/ByteDance/DreamActor',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
inputImageUrl,
inputVideoUrl,
},
});
if (!(response === null || response === void 0 ? void 0 : response.taskid) || !(response === null || response === void 0 ? void 0 : response.socketaccesstoken)) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
message: 'Wiro API did not return a valid task ID or socket access token ' +
JSON.stringify(response),
});
}
const taskid = response.taskid;
const socketaccesstoken = response.socketaccesstoken;
const result = await polling_1.pollTaskUntilComplete.call(this, socketaccesstoken, headers);
const responseJSON = {
taskid: taskid,
url: '',
status: '',
};
switch (result) {
case '-1':
case '-2':
case '-3':
case '-4':
responseJSON.status = 'failed';
break;
default:
responseJSON.status = 'completed';
responseJSON.url = result !== null && result !== void 0 ? result : '';
}
returnData.push({
json: responseJSON,
});
return [returnData];
}
}
exports.Dreamactor = Dreamactor;
//# sourceMappingURL=Dreamactor.node.js.map