diff --git a/components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs b/components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs index 4921527431094..c4e35ba8c03fc 100644 --- a/components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs +++ b/components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs @@ -6,7 +6,7 @@ export default { name: "Add Items to a Playlist", description: "Add one or more items to a user’s playlist. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist).", key: "spotify-add-items-to-playlist", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/create-playlist/create-playlist.mjs b/components/spotify/actions/create-playlist/create-playlist.mjs index 1492f0851ab07..d930126c8787d 100644 --- a/components/spotify/actions/create-playlist/create-playlist.mjs +++ b/components/spotify/actions/create-playlist/create-playlist.mjs @@ -5,7 +5,7 @@ export default { name: "Create a Playlist", description: "Create a playlist for a Spotify user. The playlist will be empty until you add tracks. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/create-playlist).", key: "spotify-create-playlist", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-album-tracks/get-album-tracks.mjs b/components/spotify/actions/get-album-tracks/get-album-tracks.mjs index 449596d3c8669..23f10e87d4944 100644 --- a/components/spotify/actions/get-album-tracks/get-album-tracks.mjs +++ b/components/spotify/actions/get-album-tracks/get-album-tracks.mjs @@ -7,7 +7,7 @@ export default { name: "Get Album Tracks", description: "Get all tracks in an album. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/get-an-albums-tracks)", key: "spotify-get-album-tracks", - version: "0.0.3", + version: "0.0.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-all-tracks-by-artist/get-all-tracks-by-artist.mjs b/components/spotify/actions/get-all-tracks-by-artist/get-all-tracks-by-artist.mjs index 93eedefe324dd..de9f86f4ca784 100644 --- a/components/spotify/actions/get-all-tracks-by-artist/get-all-tracks-by-artist.mjs +++ b/components/spotify/actions/get-all-tracks-by-artist/get-all-tracks-by-artist.mjs @@ -5,7 +5,7 @@ export default { name: "Get All Tracks by Artist", description: "Get Spotify tracks information related with an artist's. [see docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-albums).", key: "spotify-get-all-tracks-by-artist", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-artist-top-tracks/get-artist-top-tracks.mjs b/components/spotify/actions/get-artist-top-tracks/get-artist-top-tracks.mjs index 3bdd3d87f1a8c..6b4e01c2434b2 100644 --- a/components/spotify/actions/get-artist-top-tracks/get-artist-top-tracks.mjs +++ b/components/spotify/actions/get-artist-top-tracks/get-artist-top-tracks.mjs @@ -6,7 +6,7 @@ export default { name: "Get an Artist's Top Tracks", description: "Get Spotify catalog information about an artist’s top tracks by country. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-top-tracks).", key: "spotify-get-artist-top-tracks", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-audio-features-for-a-track/get-audio-features-for-a-track.mjs b/components/spotify/actions/get-audio-features-for-a-track/get-audio-features-for-a-track.mjs index c61d05a68ab0a..ecbfaee7d46c0 100644 --- a/components/spotify/actions/get-audio-features-for-a-track/get-audio-features-for-a-track.mjs +++ b/components/spotify/actions/get-audio-features-for-a-track/get-audio-features-for-a-track.mjs @@ -6,7 +6,7 @@ export default { name: "Get Audio Features for a Track", description: "Get audio feature information for a single track identified by its unique Spotify ID. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-audio-features).", key: "spotify-get-audio-features-for-a-track", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-categorys-playlist/get-categorys-playlist.mjs b/components/spotify/actions/get-categorys-playlist/get-categorys-playlist.mjs index d1009c0a7cadc..b7a14fffc87ce 100644 --- a/components/spotify/actions/get-categorys-playlist/get-categorys-playlist.mjs +++ b/components/spotify/actions/get-categorys-playlist/get-categorys-playlist.mjs @@ -6,7 +6,7 @@ export default { name: "Get a Category's Playlists", description: "Get a list of Spotify playlists tagged with a particular category. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-categories-playlists).", key: "spotify-get-categorys-playlist", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs b/components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs index d54b4f4599964..ef729ef9918a9 100644 --- a/components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs +++ b/components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs @@ -7,7 +7,7 @@ export default { description: "Get the object currently being played on the user's Spotify account. [See the documentation](https://developer.spotify.com/documentation/web-api/reference/get-the-users-currently-playing-track)", key: "spotify-get-currently-playing-track", - version: "0.0.3", + version: "0.0.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-playlist-items/get-playlist-items.mjs b/components/spotify/actions/get-playlist-items/get-playlist-items.mjs index 3e24cb5b5f2d0..8b60e1c394464 100644 --- a/components/spotify/actions/get-playlist-items/get-playlist-items.mjs +++ b/components/spotify/actions/get-playlist-items/get-playlist-items.mjs @@ -6,7 +6,7 @@ export default { name: "Get a Playlist's Items", description: "Get full details of the items of a playlist owned by a Spotify user. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-playlists-tracks).", key: "spotify-get-playlist-items", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-playlist/get-playlist.mjs b/components/spotify/actions/get-playlist/get-playlist.mjs index 879eea960bd4c..0339fe37f48c5 100644 --- a/components/spotify/actions/get-playlist/get-playlist.mjs +++ b/components/spotify/actions/get-playlist/get-playlist.mjs @@ -4,7 +4,7 @@ export default { name: "Get a Playlist", description: "Get a playlist owned by a Spotify user. [See the documentation](https://developer.spotify.com/documentation/web-api/reference/get-playlist).", key: "spotify-get-playlist", - version: "0.0.4", + version: "0.0.5", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-recommendations/get-recommendations.mjs b/components/spotify/actions/get-recommendations/get-recommendations.mjs index 3cc71f2a8f89e..dcdf965f87b2c 100644 --- a/components/spotify/actions/get-recommendations/get-recommendations.mjs +++ b/components/spotify/actions/get-recommendations/get-recommendations.mjs @@ -5,7 +5,7 @@ export default { name: "Get Recommendations", description: "Create a list of recommendations based on the available information for a given seed entity and matched against similar artists and tracks. If there is sufficient information about the provided seeds, a list of tracks will be returned together with pool size details. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-recommendations).", key: "spotify-get-recommendations", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/get-track/get-track.mjs b/components/spotify/actions/get-track/get-track.mjs index 465d42d2b9b2f..93b83f702f6d2 100644 --- a/components/spotify/actions/get-track/get-track.mjs +++ b/components/spotify/actions/get-track/get-track.mjs @@ -6,7 +6,7 @@ export default { name: "Get a Track", description: "Get a track by its name or ID. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/search)", key: "spotify-get-track", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/remove-items-from-playlist/remove-items-from-playlist.mjs b/components/spotify/actions/remove-items-from-playlist/remove-items-from-playlist.mjs index af11d9388f061..b859d55933537 100644 --- a/components/spotify/actions/remove-items-from-playlist/remove-items-from-playlist.mjs +++ b/components/spotify/actions/remove-items-from-playlist/remove-items-from-playlist.mjs @@ -6,7 +6,7 @@ export default { name: "Remove Items from a Playlist", description: "Remove one or more items from a user’s playlist. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-tracks-playlist)", key: "spotify-remove-items-from-playlist", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/spotify/actions/remove-user-saved-tracks/remove-user-saved-tracks.mjs b/components/spotify/actions/remove-user-saved-tracks/remove-user-saved-tracks.mjs index 059efa6f4b988..0ca9f0e067413 100644 --- a/components/spotify/actions/remove-user-saved-tracks/remove-user-saved-tracks.mjs +++ b/components/spotify/actions/remove-user-saved-tracks/remove-user-saved-tracks.mjs @@ -5,7 +5,7 @@ export default { name: "Remove User's Saved Tracks", description: "Remove one or more tracks from the current user’s ‘Your Music’ library. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-tracks-user)", key: "spotify-remove-user-saved-tracks", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/spotify/actions/save-track/save-track.mjs b/components/spotify/actions/save-track/save-track.mjs index 3a8d608580981..3b542078d9319 100644 --- a/components/spotify/actions/save-track/save-track.mjs +++ b/components/spotify/actions/save-track/save-track.mjs @@ -6,7 +6,7 @@ export default { name: "Save Tracks for User", description: "Save one or more tracks to the current user’s \"Your Music\" library. [See the docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/save-tracks-user).", key: "spotify-save-track", - version: "0.1.3", + version: "0.1.4", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/spotify/actions/search/search.mjs b/components/spotify/actions/search/search.mjs new file mode 100644 index 0000000000000..86343d57c7090 --- /dev/null +++ b/components/spotify/actions/search/search.mjs @@ -0,0 +1,88 @@ +import { ConfigurationError } from "@pipedream/platform"; +import spotify from "../../spotify.app.mjs"; +import { + ITEM_TYPES_LIST, ITEM_TYPES, +} from "../../consts.mjs"; + +export default { + key: "spotify-search", + name: "Search", + description: "Search for items on Spotify (tracks, albums, artists, playlists, shows, or episodes). [See the docs here](https://developer.spotify.com/documentation/web-api/reference/search)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + spotify, + query: { + type: "string", + label: "Search Query", + description: "Search query keywords and optional field filters. [See the Spotify docs for query syntax](https://developer.spotify.com/documentation/web-api/reference/search)", + }, + type: { + type: "string[]", + label: "Search Type", + description: "Type(s) of items to search for", + options: ITEM_TYPES_LIST, + default: [ + ITEM_TYPES.TRACK, + ], + }, + market: { + propDefinition: [ + spotify, + "market", + ], + optional: true, + }, + limit: { + propDefinition: [ + spotify, + "limit", + ], + description: "The maximum number of results to return per type.", + default: 20, + max: 50, + }, + offset: { + propDefinition: [ + spotify, + "offset", + ], + }, + includeExternal: { + type: "string", + label: "Include External", + description: "If `audio` is specified, the response will include any relevant audio content that is hosted externally.", + optional: true, + options: [ + "audio", + ], + }, + }, + async run({ $ }) { + if (!this.query || this.query.trim().length === 0) { + throw new ConfigurationError("Search `query` cannot be empty"); + } + + if (!this.type) { + throw new ConfigurationError("Select at least one search type"); + } + + const res = await this.spotify.search({ + q: this.query, + type: this.type.join(","), + market: this.market, + limit: this.limit, + offset: this.offset, + include_external: this.includeExternal, + }); + + $.export("$summary", `Successfully retrieved results matching query: "${this.query}"`); + + return res; + }, +}; diff --git a/components/spotify/consts.mjs b/components/spotify/consts.mjs index 45fb86c8d513e..ccd3994fd1cad 100644 --- a/components/spotify/consts.mjs +++ b/components/spotify/consts.mjs @@ -7,6 +7,33 @@ export const ITEM_TYPES = { EPISODE: "episode", }; +export const ITEM_TYPES_LIST = [ + { + label: "Album", + value: ITEM_TYPES.ALBUM, + }, + { + label: "Artist", + value: ITEM_TYPES.ARTIST, + }, + { + label: "Playlist", + value: ITEM_TYPES.PLAYLIST, + }, + { + label: "Track", + value: ITEM_TYPES.TRACK, + }, + { + label: "Show", + value: ITEM_TYPES.SHOW, + }, + { + label: "Episode", + value: ITEM_TYPES.EPISODE, + }, +]; + export const ITEM_TYPES_RESULT_NAME = { [ITEM_TYPES.ALBUM]: "albums", [ITEM_TYPES.ARTIST]: "artists", diff --git a/components/spotify/package.json b/components/spotify/package.json index 1b280f16f643d..6adb41a09ade8 100644 --- a/components/spotify/package.json +++ b/components/spotify/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/spotify", - "version": "0.7.3", + "version": "0.7.4", "description": "Pipedream Spotify Components", "main": "spotify.app.mjs", "keywords": [ diff --git a/components/spotify/sources/new-playlist/new-playlist.mjs b/components/spotify/sources/new-playlist/new-playlist.mjs index d82665b37fdaf..93aea65f57390 100644 --- a/components/spotify/sources/new-playlist/new-playlist.mjs +++ b/components/spotify/sources/new-playlist/new-playlist.mjs @@ -6,7 +6,7 @@ export default { key: "spotify-new-playlist", name: "New Playlist", description: "Emit new event when a new playlist is created or followed by the current Spotify user.", - version: "0.1.2", + version: "0.1.3", props: { ...common.props, }, diff --git a/components/spotify/sources/new-saved-track/new-saved-track.mjs b/components/spotify/sources/new-saved-track/new-saved-track.mjs index d97a5ca235bc1..4831c5ff14604 100644 --- a/components/spotify/sources/new-saved-track/new-saved-track.mjs +++ b/components/spotify/sources/new-saved-track/new-saved-track.mjs @@ -6,7 +6,7 @@ export default { key: "spotify-new-saved-track", name: "New Saved Track", description: "Emit new event for each new track saved to the current Spotify user's Music Library.", - version: "0.1.2", + version: "0.1.3", props: { ...common.props, db: "$.service.db", diff --git a/components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs b/components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs index a9e7d4a69abd5..7029529f3b701 100644 --- a/components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs +++ b/components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs @@ -7,7 +7,7 @@ export default { key: "spotify-new-track-by-artist", name: "New Track by Artist", description: "Emit new event for each new Spotify track related with an artist. [see docs here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-albums)", - version: "0.1.2", + version: "0.1.3", props: { ...common.props, db: "$.service.db", diff --git a/components/spotify/sources/new-track-in-playlist/new-track-in-playlist.mjs b/components/spotify/sources/new-track-in-playlist/new-track-in-playlist.mjs index 68d1d98bb0d14..7377eb086e230 100644 --- a/components/spotify/sources/new-track-in-playlist/new-track-in-playlist.mjs +++ b/components/spotify/sources/new-track-in-playlist/new-track-in-playlist.mjs @@ -7,7 +7,7 @@ export default { key: "spotify-new-track-in-playlist", name: "New Track in Playlist", description: "Emit new event for each new Spotify track added to a playlist", - version: "0.1.2", + version: "0.1.3", props: { ...common.props, db: "$.service.db", diff --git a/components/spotify/spotify.app.mjs b/components/spotify/spotify.app.mjs index 3636b3b1a4b06..c99554c3b57af 100644 --- a/components/spotify/spotify.app.mjs +++ b/components/spotify/spotify.app.mjs @@ -386,6 +386,10 @@ export default { const { data } = await this._makeRequest("GET", "/recommendations", params); return data; }, + async search(params) { + const { data } = await this._makeRequest("GET", "/search", params); + return data; + }, async fetchChunksOfAlbumsIds({ artistId, market,