Skip to content

Commit 10ad254

Browse files
lcaresiaGTFalcaocoderabbitai[bot]
authored
[Components] Robopost #17638 (#19218)
* Added actions * Update components/robopost/robopost.app.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * pnpm --------- Co-authored-by: Guilherme Falcão <48412907+GTFalcao@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 90c201d commit 10ad254

File tree

7 files changed

+320
-10
lines changed

7 files changed

+320
-10
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import app from "../../robopost.app.mjs";
2+
3+
export default {
4+
key: "robopost-create-video-configuration",
5+
name: "Create Video Configuration",
6+
description: "Create a new faceless video series configuration for generating multiple videos with consistent settings. [See the documentation](https://robopost.app/docs/robopost-api/#videogenerationendpoints)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
name: {
17+
propDefinition: [
18+
app,
19+
"name",
20+
],
21+
},
22+
contentType: {
23+
propDefinition: [
24+
app,
25+
"contentType",
26+
],
27+
},
28+
style: {
29+
propDefinition: [
30+
app,
31+
"style",
32+
],
33+
},
34+
voice: {
35+
propDefinition: [
36+
app,
37+
"voice",
38+
],
39+
},
40+
lang: {
41+
propDefinition: [
42+
app,
43+
"lang",
44+
],
45+
},
46+
maxDuration: {
47+
propDefinition: [
48+
app,
49+
"maxDuration",
50+
],
51+
},
52+
},
53+
async run({ $ }) {
54+
const response = await this.app.createVideoConfiguration({
55+
$,
56+
data: {
57+
name: this.name,
58+
content_type: this.contentType,
59+
style: this.style,
60+
voice: this.voice,
61+
lang: this.lang,
62+
max_duration: this.maxDuration,
63+
},
64+
});
65+
$.export("$summary", `Successfully created video series configuration with ID: ${response.id}`);
66+
return response;
67+
},
68+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../robopost.app.mjs";
2+
3+
export default {
4+
key: "robopost-generate-video",
5+
name: "Generate Video",
6+
description: "Create a new video generation task from a video series. [See the documentation](https://robopost.app/docs/robopost-api/#videogenerationtasks)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
configurationId: {
17+
propDefinition: [
18+
app,
19+
"configurationId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.generateVideo({
25+
$,
26+
configurationId: this.configurationId,
27+
});
28+
$.export("$summary", `Successfully started the task to generate the video. Task ID: ${response.task_id}`);
29+
return response;
30+
},
31+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../robopost.app.mjs";
2+
3+
export default {
4+
key: "robopost-get-video-status",
5+
name: "Get Video Status",
6+
description: "Check the status of a video generation task. [See the documentation](https://robopost.app/docs/robopost-api/#videogenerationtasks)",
7+
version: "0.0.2",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
taskId: {
17+
propDefinition: [
18+
app,
19+
"taskId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.getVideoStatus({
25+
$,
26+
taskId: this.taskId,
27+
});
28+
$.export("$summary", `The task status is: ${response.status}`);
29+
return response;
30+
},
31+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
export default {
2+
CONTENT_TYPES: [
3+
"RANDOM_AI_STORY",
4+
"SCARY_STORIES",
5+
"BEDTIME_STORIES",
6+
"INTERESTING_HISTORY",
7+
"URBAN_LEGENDS",
8+
"MOTIVATIONAL",
9+
"FUN_FACTS",
10+
"LONG_FORM_JOKES",
11+
"LIFE_PRO_TIPS",
12+
"ELI5",
13+
"DID_YOU_KNOW",
14+
"PHILOSOPHY",
15+
"RECIPES",
16+
"FITNESS",
17+
"BEAUTY",
18+
"GROWTH_ADVICE",
19+
"PRODUCT_MARKETING",
20+
"CUSTOM",
21+
"BLOG_ARTICLE",
22+
],
23+
STYLE_OPTIONS: [
24+
"DEFAULT",
25+
"REALISM",
26+
"IMPRESSIONISM",
27+
"SURREALISM",
28+
"ABSTRACT",
29+
"ART_NOUVEAU",
30+
"CUBISM",
31+
"POP_ART",
32+
"FUTURISM",
33+
"FANTASY_CONCEPT_ART",
34+
"MINIMALISM",
35+
"WATERCOLOR",
36+
"GOTHIC_MEDIEVAL_ART",
37+
"ANIME",
38+
"COMIC",
39+
],
40+
VOICE_OPTIONS: [
41+
"ALICE",
42+
"BILL",
43+
"SARAH",
44+
"BRIAN",
45+
"LAURA",
46+
"ARIA",
47+
"CALLUM",
48+
"CHARLIE",
49+
],
50+
};

components/robopost/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/robopost",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Robopost Components",
55
"main": "robopost.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.1"
1417
}
15-
}
18+
}
Lines changed: 127 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,134 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "robopost",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
name: {
9+
type: "string",
10+
label: "Name",
11+
description: "Name of the video series configuration",
12+
},
13+
contentType: {
14+
type: "string",
15+
label: "Content Type",
16+
description: "The type of the content of the video",
17+
options: constants.CONTENT_TYPES,
18+
optional: true,
19+
},
20+
style: {
21+
type: "string",
22+
label: "Style",
23+
description: "The style of the video",
24+
options: constants.STYLE_OPTIONS,
25+
optional: true,
26+
},
27+
voice: {
28+
type: "string",
29+
label: "Voice",
30+
description: "The voice used for the video",
31+
options: constants.VOICE_OPTIONS,
32+
optional: true,
33+
},
34+
lang: {
35+
type: "string",
36+
label: "Language Code",
37+
description: "Language of the video, i.e.: `en`",
38+
optional: true,
39+
},
40+
maxDuration: {
41+
type: "integer",
42+
label: "Max Duration",
43+
description: "Maximum video duration in seconds (5-600)",
44+
optional: true,
45+
min: 5,
46+
max: 600,
47+
},
48+
configurationId: {
49+
type: "string",
50+
label: "Configuration ID",
51+
description: "ID of the configuration for the video generation",
52+
async options() {
53+
const response = await this.getVideoSeries();
54+
return response.map(({
55+
name, id,
56+
}) => ({
57+
label: name,
58+
value: id,
59+
}));
60+
},
61+
},
62+
taskId: {
63+
type: "string",
64+
label: "Task ID",
65+
description: "ID of the task to be checked",
66+
async options() {
67+
const response = await this.getTaskStatus();
68+
return response.map(({
69+
created_at, task_id,
70+
}) => ({
71+
label: created_at,
72+
value: task_id,
73+
}));
74+
},
75+
},
76+
},
577
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
78+
_baseUrl() {
79+
return "https://public-api.robopost.app/v1";
80+
},
81+
async _makeRequest(opts = {}) {
82+
const {
83+
$ = this,
84+
path,
85+
params,
86+
...otherOpts
87+
} = opts;
88+
return axios($, {
89+
...otherOpts,
90+
url: this._baseUrl() + path,
91+
params: {
92+
apikey: `${this.$auth.api_key}`,
93+
...params,
94+
},
95+
});
96+
},
97+
async createVideoConfiguration(args = {}) {
98+
return this._makeRequest({
99+
path: "/video-series",
100+
method: "post",
101+
...args,
102+
});
103+
},
104+
async generateVideo({
105+
configurationId, ...args
106+
}) {
107+
return this._makeRequest({
108+
path: `/video-tasks/${configurationId}/generate`,
109+
method: "post",
110+
...args,
111+
});
112+
},
113+
async getVideoStatus({
114+
taskId, ...args
115+
}) {
116+
return this._makeRequest({
117+
path: `/video-tasks/${taskId}`,
118+
...args,
119+
});
120+
},
121+
async getVideoSeries(args = {}) {
122+
return this._makeRequest({
123+
path: "/video-series",
124+
...args,
125+
});
126+
},
127+
async getTaskStatus(args = {}) {
128+
return this._makeRequest({
129+
path: "/video-tasks",
130+
...args,
131+
});
9132
},
10133
},
11134
};

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)