@gannochenko/staticstripes 0.0.12 → 0.0.14
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/Makefile +20 -0
- package/dist/asset-manager.d.ts +1 -0
- package/dist/asset-manager.d.ts.map +1 -1
- package/dist/asset-manager.js +3 -0
- package/dist/asset-manager.js.map +1 -1
- package/dist/cli/ai-generation-strategy-factory.d.ts +23 -0
- package/dist/cli/ai-generation-strategy-factory.d.ts.map +1 -0
- package/dist/cli/ai-generation-strategy-factory.js +44 -0
- package/dist/cli/ai-generation-strategy-factory.js.map +1 -0
- package/dist/cli/ai-generation-strategy.d.ts +33 -0
- package/dist/cli/ai-generation-strategy.d.ts.map +1 -0
- package/dist/cli/ai-generation-strategy.js +3 -0
- package/dist/cli/ai-generation-strategy.js.map +1 -0
- package/dist/cli/ai-music-api-ai/ai-music-api-ai-generation-strategy.d.ts +38 -0
- package/dist/cli/ai-music-api-ai/ai-music-api-ai-generation-strategy.d.ts.map +1 -0
- package/dist/cli/ai-music-api-ai/ai-music-api-ai-generation-strategy.js +174 -0
- package/dist/cli/ai-music-api-ai/ai-music-api-ai-generation-strategy.js.map +1 -0
- package/dist/cli/auth-strategy-factory.d.ts +31 -0
- package/dist/cli/auth-strategy-factory.d.ts.map +1 -0
- package/dist/cli/auth-strategy-factory.js +61 -0
- package/dist/cli/auth-strategy-factory.js.map +1 -0
- package/dist/cli/auth-strategy.d.ts +31 -0
- package/dist/cli/auth-strategy.d.ts.map +1 -0
- package/dist/cli/auth-strategy.js +3 -0
- package/dist/cli/auth-strategy.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +6 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +103 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +69 -2
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/instagram/instagram-auth-strategy.d.ts +31 -0
- package/dist/cli/instagram/instagram-auth-strategy.d.ts.map +1 -0
- package/dist/cli/instagram/instagram-auth-strategy.js +505 -0
- package/dist/cli/instagram/instagram-auth-strategy.js.map +1 -0
- package/dist/cli/instagram/instagram-upload-strategy.d.ts +45 -0
- package/dist/cli/instagram/instagram-upload-strategy.d.ts.map +1 -0
- package/dist/cli/instagram/instagram-upload-strategy.js +303 -0
- package/dist/cli/instagram/instagram-upload-strategy.js.map +1 -0
- package/dist/cli/s3/s3-upload-strategy.d.ts.map +1 -1
- package/dist/cli/s3/s3-upload-strategy.js +7 -3
- package/dist/cli/s3/s3-upload-strategy.js.map +1 -1
- package/dist/cli/upload-strategy-factory.d.ts +1 -1
- package/dist/cli/upload-strategy-factory.d.ts.map +1 -1
- package/dist/cli/upload-strategy-factory.js +5 -5
- package/dist/cli/upload-strategy-factory.js.map +1 -1
- package/dist/cli/youtube/youtube-auth-strategy.d.ts +11 -0
- package/dist/cli/youtube/youtube-auth-strategy.d.ts.map +1 -0
- package/dist/cli/youtube/youtube-auth-strategy.js +320 -0
- package/dist/cli/youtube/youtube-auth-strategy.js.map +1 -0
- package/dist/cli/youtube/youtube-upload-strategy.d.ts +10 -3
- package/dist/cli/youtube/youtube-upload-strategy.d.ts.map +1 -1
- package/dist/cli/youtube/youtube-upload-strategy.js +96 -16
- package/dist/cli/youtube/youtube-upload-strategy.js.map +1 -1
- package/dist/cli.js +2 -3
- package/dist/cli.js.map +1 -1
- package/dist/html-project-parser.d.ts +40 -1
- package/dist/html-project-parser.d.ts.map +1 -1
- package/dist/html-project-parser.js +343 -9
- package/dist/html-project-parser.js.map +1 -1
- package/dist/lib/file.d.ts +2 -0
- package/dist/lib/file.d.ts.map +1 -0
- package/dist/lib/file.js +13 -0
- package/dist/lib/file.js.map +1 -0
- package/dist/lib/net.d.ts +19 -0
- package/dist/lib/net.d.ts.map +1 -0
- package/dist/lib/net.js +101 -0
- package/dist/lib/net.js.map +1 -0
- package/dist/project.d.ts +5 -2
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +9 -1
- package/dist/project.js.map +1 -1
- package/dist/type.d.ts +17 -0
- package/dist/type.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/asset-manager.ts +4 -0
- package/src/cli/ai-generation-strategy-factory.ts +48 -0
- package/src/cli/ai-generation-strategy.ts +35 -0
- package/src/cli/ai-music-api-ai/ai-music-api-ai-generation-strategy.ts +266 -0
- package/src/cli/auth-strategy-factory.ts +67 -0
- package/src/cli/auth-strategy.ts +37 -0
- package/src/cli/commands/auth.ts +120 -0
- package/src/cli/commands/generate.ts +55 -2
- package/src/cli/instagram/instagram-auth-strategy.ts +569 -0
- package/src/cli/instagram/instagram-upload-strategy.ts +398 -0
- package/src/cli/s3/s3-upload-strategy.ts +7 -3
- package/src/cli/upload-strategy-factory.ts +6 -9
- package/src/cli/youtube/youtube-auth-strategy.ts +323 -0
- package/src/cli/youtube/youtube-upload-strategy.ts +147 -16
- package/src/cli.ts +2 -4
- package/src/html-project-parser.ts +429 -8
- package/src/lib/file.ts +11 -0
- package/src/lib/net.ts +120 -0
- package/src/project.ts +10 -0
- package/src/type.ts +19 -0
- package/dist/cli/youtube/auth-commands.d.ts +0 -3
- package/dist/cli/youtube/auth-commands.d.ts.map +0 -1
- package/dist/cli/youtube/auth-commands.js +0 -273
- package/dist/cli/youtube/auth-commands.js.map +0 -1
- package/dist/cli/youtube/cli.d.ts +0 -7
- package/dist/cli/youtube/cli.d.ts.map +0 -1
- package/dist/cli/youtube/cli.js +0 -13
- package/dist/cli/youtube/cli.js.map +0 -1
- package/dist/cli/youtube/upload-handler.d.ts +0 -12
- package/dist/cli/youtube/upload-handler.d.ts.map +0 -1
- package/dist/cli/youtube/upload-handler.js +0 -66
- package/dist/cli/youtube/upload-handler.js.map +0 -1
- package/src/cli/youtube/auth-commands.ts +0 -312
- package/src/cli/youtube/cli.ts +0 -11
- package/src/cli/youtube/upload-handler.ts +0 -101
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface HttpRequestOptions {
|
|
2
|
+
url: string;
|
|
3
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
body?: unknown | URLSearchParams;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Makes an HTTP/HTTPS request
|
|
9
|
+
* @param options Request options
|
|
10
|
+
* @returns Parsed JSON response
|
|
11
|
+
*/
|
|
12
|
+
export declare function makeRequest<T>(options: HttpRequestOptions): Promise<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Downloads a file from URL to buffer
|
|
15
|
+
* @param url URL to download from
|
|
16
|
+
* @returns Buffer containing the file data
|
|
17
|
+
*/
|
|
18
|
+
export declare function downloadFile(url: string): Promise<Buffer>;
|
|
19
|
+
//# sourceMappingURL=net.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../../src/lib/net.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,CAuE5E;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B/D"}
|
package/dist/lib/net.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeRequest = makeRequest;
|
|
7
|
+
exports.downloadFile = downloadFile;
|
|
8
|
+
const https_1 = __importDefault(require("https"));
|
|
9
|
+
const http_1 = __importDefault(require("http"));
|
|
10
|
+
/**
|
|
11
|
+
* Makes an HTTP/HTTPS request
|
|
12
|
+
* @param options Request options
|
|
13
|
+
* @returns Parsed JSON response
|
|
14
|
+
*/
|
|
15
|
+
async function makeRequest(options) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const urlObj = new URL(options.url);
|
|
18
|
+
const protocol = urlObj.protocol === 'https:' ? https_1.default : http_1.default;
|
|
19
|
+
// Determine content type and serialize body
|
|
20
|
+
let bodyString;
|
|
21
|
+
let defaultContentType;
|
|
22
|
+
if (options.body) {
|
|
23
|
+
if (options.body instanceof URLSearchParams) {
|
|
24
|
+
bodyString = options.body.toString();
|
|
25
|
+
defaultContentType = 'application/x-www-form-urlencoded';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
bodyString = JSON.stringify(options.body);
|
|
29
|
+
defaultContentType = 'application/json';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
defaultContentType = 'application/json';
|
|
34
|
+
}
|
|
35
|
+
const requestOptions = {
|
|
36
|
+
hostname: urlObj.hostname,
|
|
37
|
+
port: urlObj.port || (protocol === https_1.default ? 443 : 80),
|
|
38
|
+
path: urlObj.pathname + urlObj.search,
|
|
39
|
+
method: options.method,
|
|
40
|
+
headers: {
|
|
41
|
+
'Content-Type': defaultContentType,
|
|
42
|
+
...options.headers,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const req = protocol.request(requestOptions, (res) => {
|
|
46
|
+
const chunks = [];
|
|
47
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
48
|
+
res.on('end', () => {
|
|
49
|
+
try {
|
|
50
|
+
const responseText = Buffer.concat(chunks).toString('utf-8');
|
|
51
|
+
const data = JSON.parse(responseText);
|
|
52
|
+
if (res.statusCode && res.statusCode >= 400) {
|
|
53
|
+
reject(new Error(`HTTP request failed with status ${res.statusCode}: ${responseText}`));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
resolve(data);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
reject(new Error(`Failed to parse response: ${error instanceof Error ? error.message : String(error)}`));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
req.on('error', (error) => {
|
|
64
|
+
reject(new Error(`Request failed: ${error.message}`));
|
|
65
|
+
});
|
|
66
|
+
if (bodyString) {
|
|
67
|
+
req.write(bodyString);
|
|
68
|
+
}
|
|
69
|
+
req.end();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Downloads a file from URL to buffer
|
|
74
|
+
* @param url URL to download from
|
|
75
|
+
* @returns Buffer containing the file data
|
|
76
|
+
*/
|
|
77
|
+
async function downloadFile(url) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const protocol = url.startsWith('https') ? https_1.default : http_1.default;
|
|
80
|
+
protocol
|
|
81
|
+
.get(url, (response) => {
|
|
82
|
+
if (response.statusCode !== 200) {
|
|
83
|
+
reject(new Error(`Download failed: HTTP ${response.statusCode}`));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const chunks = [];
|
|
87
|
+
response.on('data', (chunk) => chunks.push(chunk));
|
|
88
|
+
response.on('end', () => {
|
|
89
|
+
try {
|
|
90
|
+
const buffer = Buffer.concat(chunks);
|
|
91
|
+
resolve(buffer);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
reject(error);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
.on('error', reject);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//# sourceMapp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ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Asset, Output, SequenceDefinition, FFmpegOption, Upload } from './type';
|
|
1
|
+
import { Asset, Output, SequenceDefinition, FFmpegOption, Upload, AIProvider } from './type';
|
|
2
2
|
import { Label } from './ffmpeg';
|
|
3
3
|
import { AssetManager } from './asset-manager';
|
|
4
4
|
import { FilterBuffer } from './stream';
|
|
@@ -7,12 +7,13 @@ export declare class Project {
|
|
|
7
7
|
private outputs;
|
|
8
8
|
private ffmpegOptions;
|
|
9
9
|
private uploads;
|
|
10
|
+
private aiProviders;
|
|
10
11
|
private title;
|
|
11
12
|
private cssText;
|
|
12
13
|
private projectPath;
|
|
13
14
|
private assetManager;
|
|
14
15
|
private expressionContext;
|
|
15
|
-
constructor(sequencesDefinitions: SequenceDefinition[], assets: Asset[], outputs: Map<string, Output>, ffmpegOptions: Map<string, FFmpegOption>, uploads: Map<string, Upload>, title: string, cssText: string, projectPath: string);
|
|
16
|
+
constructor(sequencesDefinitions: SequenceDefinition[], assets: Asset[], outputs: Map<string, Output>, ffmpegOptions: Map<string, FFmpegOption>, uploads: Map<string, Upload>, aiProviders: Map<string, AIProvider>, title: string, cssText: string, projectPath: string);
|
|
16
17
|
build(outputName: string): Promise<FilterBuffer>;
|
|
17
18
|
printStats(): void;
|
|
18
19
|
getAssetManager(): AssetManager;
|
|
@@ -24,6 +25,8 @@ export declare class Project {
|
|
|
24
25
|
getUpload(name: string): Upload | undefined;
|
|
25
26
|
getYouTubeUploads(): Map<string, Upload>;
|
|
26
27
|
getYouTubeUpload(name: string): Upload | undefined;
|
|
28
|
+
getAIProviders(): Map<string, AIProvider>;
|
|
29
|
+
getAIProvider(name: string): AIProvider | undefined;
|
|
27
30
|
getTitle(): string;
|
|
28
31
|
getCssText(): string;
|
|
29
32
|
/**
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names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G,CAAC,MAAM,EAAE,MAAM,CAAC;IAIjC,gBAAgB,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC;IAI7C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIvD,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIjC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK3C,iBAAiB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIxC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIlD,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC;IAIzC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAInD,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAI3B;;;;OAIG;IACI,YAAY,IAAI,MAAM,EAAE;IAoCxB,sBAAsB,IAAI,kBAAkB,EAAE;IAK9C,gBAAgB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIvC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAI/C,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAIlD,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAIzD;;OAEG;IACU,gBAAgB,CAC3B,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC;CA0DjB"}
|
package/dist/project.js
CHANGED
|
@@ -11,16 +11,18 @@ class Project {
|
|
|
11
11
|
outputs;
|
|
12
12
|
ffmpegOptions;
|
|
13
13
|
uploads;
|
|
14
|
+
aiProviders;
|
|
14
15
|
title;
|
|
15
16
|
cssText;
|
|
16
17
|
projectPath;
|
|
17
18
|
assetManager;
|
|
18
19
|
expressionContext;
|
|
19
|
-
constructor(sequencesDefinitions, assets, outputs, ffmpegOptions, uploads, title, cssText, projectPath) {
|
|
20
|
+
constructor(sequencesDefinitions, assets, outputs, ffmpegOptions, uploads, aiProviders, title, cssText, projectPath) {
|
|
20
21
|
this.sequencesDefinitions = sequencesDefinitions;
|
|
21
22
|
this.outputs = outputs;
|
|
22
23
|
this.ffmpegOptions = ffmpegOptions;
|
|
23
24
|
this.uploads = uploads;
|
|
25
|
+
this.aiProviders = aiProviders;
|
|
24
26
|
this.title = title;
|
|
25
27
|
this.cssText = cssText;
|
|
26
28
|
this.projectPath = projectPath;
|
|
@@ -98,6 +100,12 @@ class Project {
|
|
|
98
100
|
getYouTubeUpload(name) {
|
|
99
101
|
return this.getUpload(name);
|
|
100
102
|
}
|
|
103
|
+
getAIProviders() {
|
|
104
|
+
return this.aiProviders;
|
|
105
|
+
}
|
|
106
|
+
getAIProvider(name) {
|
|
107
|
+
return this.aiProviders.get(name);
|
|
108
|
+
}
|
|
101
109
|
getTitle() {
|
|
102
110
|
return this.title;
|
|
103
111
|
}
|
package/dist/project.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":";;;AASA,mDAA+C;AAC/C,yCAAsC;AACtC,qCAAwC;AAExC,6DAAwD;AACxD,+BAA+B;AAE/B,MAAa,OAAO;IAKR;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IAZF,YAAY,CAAe;IAC3B,iBAAiB,CAAoB;IAE7C,YACU,oBAA0C,EAClD,MAAe,EACP,OAA4B,EAC5B,aAAwC,EACxC,OAA4B,EAC5B,WAAoC,EACpC,KAAa,EACb,OAAe,EACf,WAAmB;QARnB,yBAAoB,GAApB,oBAAoB,CAAsB;QAE1C,YAAO,GAAP,OAAO,CAAqB;QAC5B,kBAAa,GAAb,aAAa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vD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAE7C,uBAAuB;YACvB,MAAM,YAAY,GAAU;gBAC1B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,MAAM,CAAC,cAAc;gBAC3B,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,CAAC;gBACX,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK;gBAC9B,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM;gBAChC,QAAQ,EAAE,CAAC;gBACX,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,KAAK;aAChB,CAAC;YAEF,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEhD,4BAA4B;YAC5B,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,CAC3C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,KAAK,MAAM,CAAC,SAAS,CAAC,EAAE,CACrD,CAAC;YACF,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,SAAS,GAAG,gBAAgB,CAAC;YACxC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAjQD,0BAiQC"}
|
package/dist/type.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export type Asset = {
|
|
|
25
25
|
rotation: number;
|
|
26
26
|
hasVideo: boolean;
|
|
27
27
|
hasAudio: boolean;
|
|
28
|
+
ai?: {
|
|
29
|
+
integrationName: string;
|
|
30
|
+
prompt: string;
|
|
31
|
+
duration?: number;
|
|
32
|
+
};
|
|
28
33
|
};
|
|
29
34
|
export type Fragment = {
|
|
30
35
|
id: string;
|
|
@@ -88,8 +93,20 @@ export type Upload = {
|
|
|
88
93
|
path: string;
|
|
89
94
|
acl?: string;
|
|
90
95
|
};
|
|
96
|
+
instagram?: {
|
|
97
|
+
caption: string;
|
|
98
|
+
shareToFeed: boolean;
|
|
99
|
+
thumbOffset?: number;
|
|
100
|
+
coverUrl?: string;
|
|
101
|
+
videoUrl?: string;
|
|
102
|
+
};
|
|
91
103
|
};
|
|
92
104
|
export type YouTubeUpload = Upload;
|
|
105
|
+
export type AIProvider = {
|
|
106
|
+
name: string;
|
|
107
|
+
tag: string;
|
|
108
|
+
model?: string;
|
|
109
|
+
};
|
|
93
110
|
export type ProjectStructure = {
|
|
94
111
|
sequences: SequenceDefinition[];
|
|
95
112
|
assets: Map<string, Asset>;
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC;AAC9B,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAElC,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAClC,QAAQ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AM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/package.json
CHANGED
package/src/asset-manager.ts
CHANGED
|
@@ -19,6 +19,10 @@ export class AssetManager {
|
|
|
19
19
|
return this.assets.find((assetItem) => assetItem.name === name);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
public getAssets(): Asset[] {
|
|
23
|
+
return this.assets;
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
public getVideoInputLabelByAssetName(name: string): Label {
|
|
23
27
|
const assetIndex = this.assetIndexMap.get(name);
|
|
24
28
|
const asset = this.getAssetByName(name);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AIGenerationStrategy } from './ai-generation-strategy';
|
|
2
|
+
import { AIMusicAPIGenerationStrategy } from './ai-music-api-ai/ai-music-api-ai-generation-strategy';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Factory for creating AI generation strategies based on provider tag
|
|
6
|
+
*/
|
|
7
|
+
export class AIGenerationStrategyFactory {
|
|
8
|
+
private strategies: Map<string, AIGenerationStrategy> = new Map();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Registers an AI generation strategy
|
|
12
|
+
*/
|
|
13
|
+
register(strategy: AIGenerationStrategy): void {
|
|
14
|
+
this.strategies.set(strategy.getTag(), strategy);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Gets a strategy for the given tag
|
|
19
|
+
* @param tag The AI provider tag (e.g., "ai-music-api-ai")
|
|
20
|
+
* @returns The strategy for this tag
|
|
21
|
+
* @throws Error if no strategy is registered for the tag
|
|
22
|
+
*/
|
|
23
|
+
getStrategy(tag: string): AIGenerationStrategy {
|
|
24
|
+
const strategy = this.strategies.get(tag);
|
|
25
|
+
if (!strategy) {
|
|
26
|
+
const availableTags = Array.from(this.strategies.keys());
|
|
27
|
+
throw new Error(
|
|
28
|
+
`No AI generation strategy registered for tag "${tag}".\n` +
|
|
29
|
+
(availableTags.length > 0
|
|
30
|
+
? `Available: ${availableTags.join(', ')}`
|
|
31
|
+
: 'No AI generation strategies registered.'),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return strategy;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a factory with all available strategies registered
|
|
39
|
+
*/
|
|
40
|
+
static createDefault(): AIGenerationStrategyFactory {
|
|
41
|
+
const factory = new AIGenerationStrategyFactory();
|
|
42
|
+
|
|
43
|
+
// Register AIMusicAPI.ai strategy
|
|
44
|
+
factory.register(new AIMusicAPIGenerationStrategy());
|
|
45
|
+
|
|
46
|
+
return factory;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for AI asset generation
|
|
3
|
+
*/
|
|
4
|
+
export interface AIAssetConfig {
|
|
5
|
+
assetName: string; // Name of the asset
|
|
6
|
+
assetPath: string; // Where to save the generated file
|
|
7
|
+
integrationName: string; // Name of AI integration (references provider in <ai> section)
|
|
8
|
+
prompt: string; // Generation prompt
|
|
9
|
+
model?: string; // Optional model name (from provider configuration)
|
|
10
|
+
duration?: number; // Optional duration in seconds (from asset configuration)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Interface for AI generation strategies
|
|
15
|
+
* Each AI provider (AIMusicAPI.ai, etc.) implements this interface
|
|
16
|
+
*/
|
|
17
|
+
export interface AIGenerationStrategy {
|
|
18
|
+
/**
|
|
19
|
+
* Returns the tag name this strategy handles (e.g., "ai-music-api-ai")
|
|
20
|
+
*/
|
|
21
|
+
getTag(): string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Validates that required credentials and configuration are present
|
|
25
|
+
* @throws Error if validation fails
|
|
26
|
+
*/
|
|
27
|
+
validate(): void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generates an AI asset
|
|
31
|
+
* @param config The AI asset configuration
|
|
32
|
+
* @param projectPath The absolute path to the project directory
|
|
33
|
+
*/
|
|
34
|
+
generate(config: AIAssetConfig, projectPath: string): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { AIGenerationStrategy, AIAssetConfig } from '../ai-generation-strategy';
|
|
2
|
+
import { resolve, dirname, basename, extname } from 'path';
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
|
+
import { makeRequest, downloadFile } from '../../lib/net';
|
|
5
|
+
import { writeFile } from '../../lib/file';
|
|
6
|
+
|
|
7
|
+
interface MusicAPICredentials {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface MusicAPICreateResponse {
|
|
12
|
+
code: number;
|
|
13
|
+
message: string;
|
|
14
|
+
task_id: string;
|
|
15
|
+
data?: {
|
|
16
|
+
state?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* AIMusicAPI.ai generation strategy
|
|
22
|
+
* Generates music using AIMusicAPI.ai's API (https://aimusicapi.ai)
|
|
23
|
+
*/
|
|
24
|
+
export class AIMusicAPIGenerationStrategy implements AIGenerationStrategy {
|
|
25
|
+
private readonly API_BASE_URL = 'https://api.aimusicapi.ai/api/v1';
|
|
26
|
+
private readonly POLL_INTERVAL_MS = 20000; // 20 seconds
|
|
27
|
+
private readonly MAX_POLL_ATTEMPTS = 60; // 20 minutes max
|
|
28
|
+
private readonly DEFAULT_MODEL = 'sonic-v4-5'; // Default model if none specified
|
|
29
|
+
private readonly DEFAULT_DURATION = 30; // Default duration in seconds if none specified
|
|
30
|
+
|
|
31
|
+
getTag(): string {
|
|
32
|
+
return 'ai-music-api-ai';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
validate(): void {
|
|
36
|
+
// Validation happens during generation when we load credentials
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async generate(config: AIAssetConfig, projectPath: string): Promise<void> {
|
|
40
|
+
const credentials = this.loadCredentials(
|
|
41
|
+
config.integrationName,
|
|
42
|
+
projectPath,
|
|
43
|
+
);
|
|
44
|
+
const model = config.model || this.DEFAULT_MODEL;
|
|
45
|
+
const duration = config.duration || this.DEFAULT_DURATION;
|
|
46
|
+
|
|
47
|
+
console.log(
|
|
48
|
+
` Submitting music generation request (model: ${model}, duration: ${duration}s)...`,
|
|
49
|
+
);
|
|
50
|
+
console.log(
|
|
51
|
+
` Using API key: ${credentials.apiKey.substring(0, 10)}... (length: ${credentials.apiKey.length})`,
|
|
52
|
+
);
|
|
53
|
+
const taskId = await this.createMusicGenerationTask(
|
|
54
|
+
credentials.apiKey,
|
|
55
|
+
config.prompt,
|
|
56
|
+
model,
|
|
57
|
+
duration,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
console.log(` Task ID: ${taskId}`);
|
|
61
|
+
console.log(` Waiting for generation to complete...`);
|
|
62
|
+
|
|
63
|
+
const audioUrls = await this.pollForCompletion(credentials.apiKey, taskId);
|
|
64
|
+
|
|
65
|
+
console.log(` Downloading ${audioUrls.length} audio file(s)...`);
|
|
66
|
+
|
|
67
|
+
// Download the first file to the main asset path
|
|
68
|
+
await this.downloadAudio(audioUrls[0], config.assetPath);
|
|
69
|
+
console.log(` Primary audio saved to: ${config.assetPath}`);
|
|
70
|
+
|
|
71
|
+
// Download remaining files to alternative paths in the same directory
|
|
72
|
+
if (audioUrls.length > 1) {
|
|
73
|
+
const assetDir = dirname(config.assetPath);
|
|
74
|
+
const assetExt = extname(config.assetPath);
|
|
75
|
+
const assetBase = basename(config.assetPath, assetExt);
|
|
76
|
+
|
|
77
|
+
for (let i = 1; i < audioUrls.length; i++) {
|
|
78
|
+
const altNumber = String(i).padStart(2, '0');
|
|
79
|
+
const altPath = resolve(
|
|
80
|
+
assetDir,
|
|
81
|
+
`${assetBase}_alt_${altNumber}${assetExt}`,
|
|
82
|
+
);
|
|
83
|
+
await this.downloadAudio(audioUrls[i], altPath);
|
|
84
|
+
console.log(` Alternative ${i} saved to: ${altPath}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Loads credentials from .auth/<integrationName>.json
|
|
91
|
+
*/
|
|
92
|
+
private loadCredentials(
|
|
93
|
+
integrationName: string,
|
|
94
|
+
projectPath: string,
|
|
95
|
+
): MusicAPICredentials {
|
|
96
|
+
const authFilePath = resolve(
|
|
97
|
+
projectPath,
|
|
98
|
+
'.auth',
|
|
99
|
+
`${integrationName}.json`,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (!existsSync(authFilePath)) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Credentials file not found: ${authFilePath}\n` +
|
|
105
|
+
`Please create the file with the following format:\n` +
|
|
106
|
+
`{\n "apiKey": "your-api-key-here"\n}`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const fileContent = readFileSync(authFilePath, 'utf-8');
|
|
112
|
+
const credentials = JSON.parse(fileContent) as MusicAPICredentials;
|
|
113
|
+
|
|
114
|
+
if (!credentials.apiKey) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Invalid credentials file: ${authFilePath}\n` +
|
|
117
|
+
`Missing "apiKey" field`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Trim whitespace from API key
|
|
122
|
+
return {
|
|
123
|
+
apiKey: credentials.apiKey.trim(),
|
|
124
|
+
};
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (error instanceof SyntaxError) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Invalid JSON in credentials file: ${authFilePath}\n` +
|
|
129
|
+
`${error.message}`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Creates a music generation task
|
|
138
|
+
* Returns the task ID
|
|
139
|
+
*/
|
|
140
|
+
private async createMusicGenerationTask(
|
|
141
|
+
apiKey: string,
|
|
142
|
+
prompt: string,
|
|
143
|
+
model: string,
|
|
144
|
+
duration: number,
|
|
145
|
+
): Promise<string> {
|
|
146
|
+
const endpoint = `${this.API_BASE_URL}/sonic/create`;
|
|
147
|
+
|
|
148
|
+
const requestBody = {
|
|
149
|
+
task_type: 'create_music',
|
|
150
|
+
custom_mode: false,
|
|
151
|
+
gpt_description_prompt: prompt,
|
|
152
|
+
mv: model,
|
|
153
|
+
duration,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const response = await makeRequest<MusicAPICreateResponse>({
|
|
157
|
+
url: endpoint,
|
|
158
|
+
method: 'POST',
|
|
159
|
+
headers: {
|
|
160
|
+
Authorization: `Bearer ${apiKey}`,
|
|
161
|
+
},
|
|
162
|
+
body: requestBody,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (!response.task_id) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`Failed to create music generation task: ${response.message || 'Unknown error'}`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return response.task_id;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Polls for task completion
|
|
176
|
+
* Returns all audio URLs when ready
|
|
177
|
+
*/
|
|
178
|
+
private async pollForCompletion(
|
|
179
|
+
apiKey: string,
|
|
180
|
+
taskId: string,
|
|
181
|
+
): Promise<string[]> {
|
|
182
|
+
const endpoint = `${this.API_BASE_URL}/sonic/task/${taskId}`;
|
|
183
|
+
|
|
184
|
+
for (let attempt = 0; attempt < this.MAX_POLL_ATTEMPTS; attempt++) {
|
|
185
|
+
const response = await makeRequest<any>({
|
|
186
|
+
url: endpoint,
|
|
187
|
+
method: 'GET',
|
|
188
|
+
headers: {
|
|
189
|
+
Authorization: `Bearer ${apiKey}`,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// API returns an array of clips in the data field
|
|
194
|
+
if (!response.data || !Array.isArray(response.data)) {
|
|
195
|
+
throw new Error(
|
|
196
|
+
`Unexpected API response format: ${JSON.stringify(response)}`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (response.data.length === 0) {
|
|
201
|
+
throw new Error('No clips returned in response');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Check the first clip to determine overall status
|
|
205
|
+
const firstClip = response.data[0];
|
|
206
|
+
const state = firstClip.state;
|
|
207
|
+
const errorMessage = firstClip.error_message;
|
|
208
|
+
|
|
209
|
+
console.log(
|
|
210
|
+
` Status: ${state}... (${response.data.length} clip(s), attempt ${attempt + 1}/${this.MAX_POLL_ATTEMPTS})`,
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
if (
|
|
214
|
+
state === 'succeeded' ||
|
|
215
|
+
state === 'completed' ||
|
|
216
|
+
state === 'success'
|
|
217
|
+
) {
|
|
218
|
+
// Collect all audio URLs from successful clips
|
|
219
|
+
const audioUrls: string[] = [];
|
|
220
|
+
for (const clip of response.data) {
|
|
221
|
+
if (clip.audio_url) {
|
|
222
|
+
audioUrls.push(clip.audio_url);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (audioUrls.length === 0) {
|
|
227
|
+
throw new Error('Task succeeded but no audio URLs returned');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
console.log(` Found ${audioUrls.length} generated clip(s)`);
|
|
231
|
+
return audioUrls;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (state === 'failed' || state === 'error') {
|
|
235
|
+
throw new Error(
|
|
236
|
+
`Music generation failed: ${errorMessage || 'Unknown error'}`,
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Still processing, wait before next poll
|
|
241
|
+
if (attempt < this.MAX_POLL_ATTEMPTS - 1) {
|
|
242
|
+
await this.sleep(this.POLL_INTERVAL_MS);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
throw new Error(
|
|
247
|
+
`Music generation timed out after ${this.MAX_POLL_ATTEMPTS} attempts`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Downloads audio from URL to file
|
|
253
|
+
*/
|
|
254
|
+
private async downloadAudio(url: string, outputPath: string): Promise<void> {
|
|
255
|
+
const buffer = await downloadFile(url);
|
|
256
|
+
|
|
257
|
+
writeFile(outputPath, buffer);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Sleep for specified milliseconds
|
|
262
|
+
*/
|
|
263
|
+
private sleep(ms: number): Promise<void> {
|
|
264
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
265
|
+
}
|
|
266
|
+
}
|