mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
✨ Add "Get Following Artists" on Spotify node (#1823)
* Add follow resource * ⚡ Improvements to #1812 * ⚡ Minor improvements Co-authored-by: Sam Roquitte <samroq@yahoo.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
6ccb42156d
commit
ccca927d70
|
@ -36,7 +36,7 @@ export class SpotifyOAuth2Api implements ICredentialType {
|
||||||
displayName: 'Scope',
|
displayName: 'Scope',
|
||||||
name: 'scope',
|
name: 'scope',
|
||||||
type: 'hidden' as NodePropertyTypes,
|
type: 'hidden' as NodePropertyTypes,
|
||||||
default: 'user-read-playback-state playlist-read-collaborative user-modify-playback-state playlist-modify-public user-read-currently-playing playlist-read-private user-read-recently-played playlist-modify-private user-library-read',
|
default: 'user-read-playback-state playlist-read-collaborative user-modify-playback-state playlist-modify-public user-read-currently-playing playlist-read-private user-read-recently-played playlist-modify-private user-library-read user-follow-read',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Auth URI Query Parameters',
|
displayName: 'Auth URI Query Parameters',
|
||||||
|
|
|
@ -40,10 +40,10 @@ export class Spotify implements INodeType {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
// Resource to Operate on
|
// Resource to Operate on
|
||||||
// Player, Album, Artisits, Playlists, Tracks
|
// Album, Artist, Library, My Data, Player, Playlist, Track
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Resource',
|
displayName: 'Resource',
|
||||||
name: 'resource',
|
name: 'resource',
|
||||||
|
@ -61,6 +61,10 @@ export class Spotify implements INodeType {
|
||||||
name: 'Library',
|
name: 'Library',
|
||||||
value: 'library',
|
value: 'library',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'My Data',
|
||||||
|
value: 'myData',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Player',
|
name: 'Player',
|
||||||
value: 'player',
|
value: 'player',
|
||||||
|
@ -77,9 +81,10 @@ export class Spotify implements INodeType {
|
||||||
default: 'player',
|
default: 'player',
|
||||||
description: 'The resource to operate on.',
|
description: 'The resource to operate on.',
|
||||||
},
|
},
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------
|
||||||
// Player Operations
|
// Player Operations
|
||||||
// Pause, Play, Get Recently Played, Get Currently Playing, Next Song, Previous Song, Add to Queue
|
// Pause, Play, Get Recently Played, Get Currently Playing, Next Song, Previous Song, Add to Queue
|
||||||
// --------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
|
@ -170,9 +175,10 @@ export class Spotify implements INodeType {
|
||||||
placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU',
|
placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU',
|
||||||
description: `Enter a track URI or ID.`,
|
description: `Enter a track URI or ID.`,
|
||||||
},
|
},
|
||||||
|
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
// Album Operations
|
// Album Operations
|
||||||
// Get an Album, Get an Album's Tracks
|
// Get an Album, Get an Album's Tracks
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
|
@ -225,9 +231,10 @@ export class Spotify implements INodeType {
|
||||||
placeholder: 'spotify:album:1YZ3k65Mqw3G8FzYlW1mmp',
|
placeholder: 'spotify:album:1YZ3k65Mqw3G8FzYlW1mmp',
|
||||||
description: `The album's Spotify URI or ID.`,
|
description: `The album's Spotify URI or ID.`,
|
||||||
},
|
},
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
// Artist Operations
|
// Artist Operations
|
||||||
// Get an Artist, Get an Artist's Related Artists, Get an Artist's Top Tracks, Get an Artist's Albums
|
// Get an Artist, Get an Artist's Related Artists, Get an Artist's Top Tracks, Get an Artist's Albums
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
|
@ -300,9 +307,10 @@ export class Spotify implements INodeType {
|
||||||
placeholder: 'US',
|
placeholder: 'US',
|
||||||
description: `Top tracks in which country? Enter the postal abbriviation.`,
|
description: `Top tracks in which country? Enter the postal abbriviation.`,
|
||||||
},
|
},
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
// Playlist Operations
|
// Playlist Operations
|
||||||
// Get a Playlist, Get a Playlist's Tracks, Add/Remove a Song from a Playlist, Get a User's Playlists
|
// Get a Playlist, Get a Playlist's Tracks, Add/Remove a Song from a Playlist, Get a User's Playlists
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
|
@ -478,7 +486,7 @@ export class Spotify implements INodeType {
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Track Operations
|
// Track Operations
|
||||||
// Get a Track, Get a Track's Audio Features
|
// Get a Track, Get a Track's Audio Features
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
|
@ -522,10 +530,11 @@ export class Spotify implements INodeType {
|
||||||
placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU',
|
placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU',
|
||||||
description: `The track's Spotify URI or ID.`,
|
description: `The track's Spotify URI or ID.`,
|
||||||
},
|
},
|
||||||
// --------------------------------------------------------------------------------------------------------
|
|
||||||
|
// -----------------------------------------------------
|
||||||
// Library Operations
|
// Library Operations
|
||||||
// Get liked tracks
|
// Get liked tracks
|
||||||
// --------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
name: 'operation',
|
name: 'operation',
|
||||||
|
@ -546,6 +555,32 @@ export class Spotify implements INodeType {
|
||||||
],
|
],
|
||||||
default: 'getLikedTracks',
|
default: 'getLikedTracks',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ---------------------------------------
|
||||||
|
// My Data Operations
|
||||||
|
// Get Followed Artists
|
||||||
|
// ---------------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'myData',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Get Following Artists',
|
||||||
|
value: 'getFollowingArtists',
|
||||||
|
description: 'Get your followed artists.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'getFollowingArtists',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Return All',
|
displayName: 'Return All',
|
||||||
name: 'returnAll',
|
name: 'returnAll',
|
||||||
|
@ -558,6 +593,7 @@ export class Spotify implements INodeType {
|
||||||
'album',
|
'album',
|
||||||
'artist',
|
'artist',
|
||||||
'library',
|
'library',
|
||||||
|
'myData',
|
||||||
'playlist',
|
'playlist',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
|
@ -566,6 +602,7 @@ export class Spotify implements INodeType {
|
||||||
'getUserPlaylists',
|
'getUserPlaylists',
|
||||||
'getNewReleases',
|
'getNewReleases',
|
||||||
'getLikedTracks',
|
'getLikedTracks',
|
||||||
|
'getFollowingArtists',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -612,9 +649,11 @@ export class Spotify implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
|
'myData',
|
||||||
'player',
|
'player',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
|
'getFollowingArtists',
|
||||||
'recentlyPlayed',
|
'recentlyPlayed',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -1046,6 +1085,25 @@ export class Spotify implements INodeType {
|
||||||
responseData = responseData.items;
|
responseData = responseData.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (resource === 'myData') {
|
||||||
|
|
||||||
|
if (operation === 'getFollowingArtists') {
|
||||||
|
requestMethod = 'GET';
|
||||||
|
|
||||||
|
endpoint = `/me/following`;
|
||||||
|
|
||||||
|
propertyName = 'artists.items';
|
||||||
|
|
||||||
|
if (!returnAll) {
|
||||||
|
const limit = this.getNodeParameter('limit', i) as number;
|
||||||
|
qs = {
|
||||||
|
type: 'artist',
|
||||||
|
limit,
|
||||||
|
};
|
||||||
|
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||||
|
responseData = responseData.artists.items;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
|
|
Loading…
Reference in a new issue