UNPKG

n8n-nodes-piapi

Version:

Community n8n nodes for PiAPI - integrate generative AI capabilities (image, video, audio, 3D) into your workflows

93 lines 3.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KlingVideoExtend = void 0; const GenericFunctions_1 = require("../shared/GenericFunctions"); class KlingVideoExtend { constructor() { this.description = { displayName: 'PiAPI Kling Video Extend', name: 'klingVideoExtend', icon: 'file:../piapi.svg', group: ['transform'], version: 1, description: 'Extend an existing Kling video', defaults: { name: 'Kling Video Extend', }, inputs: ["main"], outputs: ["main"], credentials: [ { name: 'piAPIApi', required: true, }, ], properties: [ { displayName: 'Original Task ID', name: 'originTaskId', type: 'string', default: '', required: true, description: 'The task ID of the original Kling video to extend', }, { displayName: 'Wait for Completion', name: 'waitForCompletion', type: 'boolean', default: false, description: 'Whether to wait for the task to complete before returning', }, ], }; } async execute() { const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { try { const originTaskId = this.getNodeParameter('originTaskId', i); const waitForCompletion = this.getNodeParameter('waitForCompletion', i, false); const body = { model: 'kling', task_type: 'extend_video', input: { origin_task_id: originTaskId, }, config: { webhook_config: { endpoint: '', secret: '', }, }, }; const response = await GenericFunctions_1.piApiRequest.call(this, 'POST', '/api/v1/task', body); if (response.code !== 200) { throw new Error(`API Error: ${response.message}`); } const taskId = response.data.task_id; let taskData = response.data; if (waitForCompletion) { taskData = await GenericFunctions_1.waitForTaskCompletion.call(this, taskId); } returnData.push({ json: taskData, }); } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message, }, }); continue; } throw error; } } return [returnData]; } } exports.KlingVideoExtend = KlingVideoExtend; //# sourceMappingURL=KlingVideoExtend.node.js.map