Skip to content

Commit d481cdd

Browse files
committed
Added actions
1 parent 2e729e5 commit d481cdd

File tree

8 files changed

+315
-19
lines changed

8 files changed

+315
-19
lines changed

components/listen_notes/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import app from "../../listen_notes.app.mjs";
2+
3+
export default {
4+
key: "listen_notes-full-search",
5+
name: "Full Search",
6+
description: "Full-text search on episodes, podcasts, or curated lists of podcasts. [See the documentation](https://www.listennotes.com/api/docs/#get-api-v2-search)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
q: {
12+
propDefinition: [
13+
app,
14+
"q",
15+
],
16+
},
17+
sortByDate: {
18+
propDefinition: [
19+
app,
20+
"sortByDate",
21+
],
22+
},
23+
type: {
24+
propDefinition: [
25+
app,
26+
"type",
27+
],
28+
},
29+
language: {
30+
propDefinition: [
31+
app,
32+
"language",
33+
],
34+
},
35+
offset: {
36+
propDefinition: [
37+
app,
38+
"offset",
39+
],
40+
},
41+
},
42+
43+
async run({ $ }) {
44+
const response = await this.app.fullSearch({
45+
$,
46+
params: {
47+
q: this.q,
48+
sort_by_date: this.sortByDate,
49+
type: this.type,
50+
language: this.language,
51+
},
52+
});
53+
54+
$.export("$summary", `Successfully retrieved ${response.results.length} results`);
55+
56+
return response;
57+
},
58+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import app from "../../listen_notes.app.mjs";
2+
3+
export default {
4+
key: "listen_notes-get-episode-details",
5+
name: "Get Episode Details",
6+
description: "Get the details of the selected episode. [See the documentation](https://www.listennotes.com/api/docs/#get-api-v2-episodes-id)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
q: {
12+
propDefinition: [
13+
app,
14+
"q",
15+
],
16+
},
17+
language: {
18+
propDefinition: [
19+
app,
20+
"language",
21+
],
22+
},
23+
offset: {
24+
propDefinition: [
25+
app,
26+
"offset",
27+
],
28+
},
29+
id: {
30+
propDefinition: [
31+
app,
32+
"id",
33+
(c) => ({
34+
q: c.q,
35+
language: c.language,
36+
offset: c.offset,
37+
}),
38+
],
39+
},
40+
},
41+
42+
async run({ $ }) {
43+
const response = await this.app.getEpisodeDetails({
44+
$,
45+
id: this.id,
46+
});
47+
48+
$.export("$summary", `Successfully retrieved details for the episode '${response.title}'`);
49+
50+
return response;
51+
},
52+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import app from "../../listen_notes.app.mjs";
2+
3+
export default {
4+
key: "listen_notes-get-podcast-details",
5+
name: "Get Podcast Details",
6+
description: "Get the details of the selected podcast. [See the documentation](https://www.listennotes.com/api/docs/#get-api-v2-podcasts-id)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
q: {
12+
propDefinition: [
13+
app,
14+
"q",
15+
],
16+
},
17+
language: {
18+
propDefinition: [
19+
app,
20+
"language",
21+
],
22+
},
23+
offset: {
24+
propDefinition: [
25+
app,
26+
"offset",
27+
],
28+
},
29+
id: {
30+
propDefinition: [
31+
app,
32+
"id",
33+
(c) => ({
34+
q: c.q,
35+
type: "podcast",
36+
language: c.language,
37+
offset: c.offset,
38+
}),
39+
],
40+
},
41+
},
42+
43+
async run({ $ }) {
44+
const response = await this.app.getPodcastDetails({
45+
$,
46+
id: this.id,
47+
});
48+
49+
$.export("$summary", `Successfully retrieved details for the podcast '${response.title}'`);
50+
51+
return response;
52+
},
53+
};

components/listen_notes/app/listen_notes.app.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
BOOLEAN_OPTIONS: [
3+
"0",
4+
"1",
5+
],
6+
TYPE_OPTIONS: [
7+
"episode",
8+
"podcast",
9+
"curated",
10+
],
11+
};
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
4+
export default {
5+
type: "app",
6+
app: "listen_notes",
7+
propDefinitions: {
8+
id: {
9+
type: "string",
10+
label: "Podcast or Episode ID",
11+
description: "The ID of the podcast or episode",
12+
async options({
13+
q, type, language, offset,
14+
}) {
15+
const response = await this.listPodcasts({
16+
q,
17+
type,
18+
language,
19+
offset,
20+
});
21+
const ids = response.results;
22+
return ids.map(({
23+
title_original, id,
24+
}) => ({
25+
value: id,
26+
label: title_original,
27+
}));
28+
},
29+
},
30+
q: {
31+
type: "string",
32+
label: "Query",
33+
description: "Search term, e.g., person, place, topic... You can use double quotes to do verbatim match",
34+
},
35+
offset: {
36+
type: "string",
37+
label: "Offset",
38+
description: "The offset parameter is used to paginate through search results",
39+
optional: true,
40+
},
41+
sortByDate: {
42+
type: "string",
43+
label: "Sort By Date",
44+
description: "Sort by date. If 0, then sort by relevance. If 1, then sort by date",
45+
options: constants.BOOLEAN_OPTIONS,
46+
optional: true,
47+
},
48+
type: {
49+
type: "string",
50+
label: "Type",
51+
description: "What type of contents do you want to search for?",
52+
options: constants.TYPE_OPTIONS,
53+
optional: true,
54+
},
55+
language: {
56+
type: "string",
57+
label: "Language",
58+
description: "Limit search results to a specific language. If not specified, it'll be any language",
59+
async options() {
60+
const response = await this.getLanguages();
61+
const languages = response.languages;
62+
return languages.map((language) => ({
63+
value: language,
64+
label: language,
65+
}));
66+
},
67+
optional: true,
68+
},
69+
},
70+
methods: {
71+
_baseUrl() {
72+
return "https://listen-api.listennotes.com/api/v2";
73+
},
74+
async _makeRequest(opts = {}) {
75+
const {
76+
$ = this,
77+
path,
78+
headers,
79+
...otherOpts
80+
} = opts;
81+
return axios($, {
82+
...otherOpts,
83+
url: this._baseUrl() + path,
84+
headers: {
85+
...headers,
86+
"X-ListenAPI-Key": `${this.$auth.api_key}`,
87+
},
88+
});
89+
},
90+
async fullSearch(args = {}) {
91+
return this._makeRequest({
92+
path: "/search",
93+
...args,
94+
});
95+
},
96+
async getPodcastDetails({
97+
id,
98+
...args
99+
}) {
100+
return this._makeRequest({
101+
path: `/podcasts/${id}`,
102+
...args,
103+
});
104+
},
105+
async getEpisodeDetails({
106+
id,
107+
...args
108+
}) {
109+
return this._makeRequest({
110+
path: `/episodes/${id}`,
111+
...args,
112+
});
113+
},
114+
async listPodcasts({
115+
q,
116+
language,
117+
type,
118+
offset,
119+
...args
120+
}) {
121+
return this._makeRequest({
122+
path: "/search",
123+
params: {
124+
q: q,
125+
type: type,
126+
language: language,
127+
offset: offset,
128+
},
129+
...args,
130+
});
131+
},
132+
async getLanguages(args = {}) {
133+
return this._makeRequest({
134+
path: "/languages",
135+
...args,
136+
});
137+
},
138+
},
139+
};

components/listen_notes/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "@pipedream/listen_notes",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"description": "Pipedream Listen Notes Components",
5-
"main": "dist/app/listen_notes.app.mjs",
5+
"main": "listen_notes.app.mjs",
66
"keywords": [
77
"pipedream",
88
"listen_notes"
99
],
10-
"files": ["dist"],
1110
"homepage": "https://pipedream.com/apps/listen_notes",
1211
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1312
"publishConfig": {

0 commit comments

Comments
 (0)