Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions components/listen_notes/.gitignore

This file was deleted.

58 changes: 58 additions & 0 deletions components/listen_notes/actions/full-search/full-search.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import app from "../../listen_notes.app.mjs";

export default {
key: "listen_notes-full-search",
name: "Full Search",
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)",
version: "0.0.1",
type: "action",
props: {
app,
q: {
propDefinition: [
app,
"q",
],
},
sortByDate: {
propDefinition: [
app,
"sortByDate",
],
},
type: {
propDefinition: [
app,
"type",
],
},
language: {
propDefinition: [
app,
"language",
],
},
offset: {
propDefinition: [
app,
"offset",
],
},
},

async run({ $ }) {
const response = await this.app.fullSearch({
$,
params: {
q: this.q,
sort_by_date: this.sortByDate,
type: this.type,
language: this.language,
},
});

$.export("$summary", `Successfully retrieved ${response.results.length} results`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import app from "../../listen_notes.app.mjs";

export default {
key: "listen_notes-get-episode-details",
name: "Get Episode Details",
description: "Get the details of the selected episode. [See the documentation](https://www.listennotes.com/api/docs/#get-api-v2-episodes-id)",
version: "0.0.1",
type: "action",
props: {
app,
q: {
propDefinition: [
app,
"q",
],
},
language: {
propDefinition: [
app,
"language",
],
},
offset: {
propDefinition: [
app,
"offset",
],
},
id: {
propDefinition: [
app,
"id",
(c) => ({
q: c.q,
language: c.language,
offset: c.offset,
}),
],
},
},

async run({ $ }) {
const response = await this.app.getEpisodeDetails({
$,
id: this.id,
});

$.export("$summary", `Successfully retrieved details for the episode '${response.title}'`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import app from "../../listen_notes.app.mjs";

export default {
key: "listen_notes-get-podcast-details",
name: "Get Podcast Details",
description: "Get the details of the selected podcast. [See the documentation](https://www.listennotes.com/api/docs/#get-api-v2-podcasts-id)",
version: "0.0.1",
type: "action",
props: {
app,
q: {
propDefinition: [
app,
"q",
],
},
language: {
propDefinition: [
app,
"language",
],
},
offset: {
propDefinition: [
app,
"offset",
],
},
id: {
propDefinition: [
app,
"id",
(c) => ({
q: c.q,
type: "podcast",
language: c.language,
offset: c.offset,
}),
],
},
},

async run({ $ }) {
const response = await this.app.getPodcastDetails({
$,
id: this.id,
});

$.export("$summary", `Successfully retrieved details for the podcast '${response.title}'`);

return response;
},
};
13 changes: 0 additions & 13 deletions components/listen_notes/app/listen_notes.app.ts

This file was deleted.

11 changes: 11 additions & 0 deletions components/listen_notes/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
BOOLEAN_OPTIONS: [
"0",
"1",
],
TYPE_OPTIONS: [
"episode",
"podcast",
"curated",
],
};
139 changes: 139 additions & 0 deletions components/listen_notes/listen_notes.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "listen_notes",
propDefinitions: {
id: {
type: "string",
label: "Podcast or Episode ID",
description: "The ID of the podcast or episode",
async options({
q, type, language, offset,
}) {
const response = await this.listPodcasts({
q,
type,
language,
offset,
});
const ids = response.results;
return ids.map(({
title_original, id,
}) => ({
value: id,
label: title_original,
}));
},
},
q: {
type: "string",
label: "Query",
description: "Search term, e.g., person, place, topic... You can use double quotes to do verbatim match",
},
offset: {
type: "string",
label: "Offset",
description: "The offset parameter is used to paginate through search results",
optional: true,
},
sortByDate: {
type: "string",
label: "Sort By Date",
description: "Sort by date. If 0, then sort by relevance. If 1, then sort by date",
options: constants.BOOLEAN_OPTIONS,
optional: true,
},
type: {
type: "string",
label: "Type",
description: "What type of contents do you want to search for?",
options: constants.TYPE_OPTIONS,
optional: true,
},
language: {
type: "string",
label: "Language",
description: "Limit search results to a specific language. If not specified, it'll be any language",
async options() {
const response = await this.getLanguages();
const languages = response.languages;
return languages.map((language) => ({
value: language,
label: language,
}));
},
optional: true,
},
},
methods: {
_baseUrl() {
return "https://listen-api.listennotes.com/api/v2";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"X-ListenAPI-Key": `${this.$auth.api_key}`,
},
});
},
async fullSearch(args = {}) {
return this._makeRequest({
path: "/search",
...args,
});
},
async getPodcastDetails({
id,
...args
}) {
return this._makeRequest({
path: `/podcasts/${id}`,
...args,
});
},
async getEpisodeDetails({
id,
...args
}) {
return this._makeRequest({
path: `/episodes/${id}`,
...args,
});
},
async listPodcasts({
q,
language,
type,
offset,
...args
}) {
return this._makeRequest({
path: "/search",
params: {
q: q,
type: type,
language: language,
offset: offset,
},
...args,
});
},
async getLanguages(args = {}) {
return this._makeRequest({
path: "/languages",
...args,
});
},
},
};
5 changes: 2 additions & 3 deletions components/listen_notes/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "@pipedream/listen_notes",
"version": "0.0.2",
"version": "0.1.0",
"description": "Pipedream Listen Notes Components",
"main": "dist/app/listen_notes.app.mjs",
"main": "listen_notes.app.mjs",
"keywords": [
"pipedream",
"listen_notes"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/listen_notes",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
Expand Down
Loading