mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -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',
|
||||
name: 'scope',
|
||||
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',
|
||||
|
|
|
@ -40,10 +40,10 @@ export class Spotify implements INodeType {
|
|||
},
|
||||
],
|
||||
properties: [
|
||||
// ----------------------------------------------------------
|
||||
// ----------------------------------------------------------------
|
||||
// Resource to Operate on
|
||||
// Player, Album, Artisits, Playlists, Tracks
|
||||
// ----------------------------------------------------------
|
||||
// Album, Artist, Library, My Data, Player, Playlist, Track
|
||||
// ----------------------------------------------------------------
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
|
@ -61,6 +61,10 @@ export class Spotify implements INodeType {
|
|||
name: 'Library',
|
||||
value: 'library',
|
||||
},
|
||||
{
|
||||
name: 'My Data',
|
||||
value: 'myData',
|
||||
},
|
||||
{
|
||||
name: 'Player',
|
||||
value: 'player',
|
||||
|
@ -77,9 +81,10 @@ export class Spotify implements INodeType {
|
|||
default: 'player',
|
||||
description: 'The resource to operate on.',
|
||||
},
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// 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',
|
||||
|
@ -170,9 +175,10 @@ export class Spotify implements INodeType {
|
|||
placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU',
|
||||
description: `Enter a track URI or ID.`,
|
||||
},
|
||||
|
||||
// -----------------------------------------------
|
||||
// Album Operations
|
||||
// Get an Album, Get an Album's Tracks
|
||||
// Get an Album, Get an Album's Tracks
|
||||
// -----------------------------------------------
|
||||
{
|
||||
displayName: 'Operation',
|
||||
|
@ -225,9 +231,10 @@ export class Spotify implements INodeType {
|
|||
placeholder: 'spotify:album:1YZ3k65Mqw3G8FzYlW1mmp',
|
||||
description: `The album's Spotify URI or ID.`,
|
||||
},
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
// 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',
|
||||
|
@ -300,9 +307,10 @@ export class Spotify implements INodeType {
|
|||
placeholder: 'US',
|
||||
description: `Top tracks in which country? Enter the postal abbriviation.`,
|
||||
},
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
// 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',
|
||||
|
@ -478,7 +486,7 @@ export class Spotify implements INodeType {
|
|||
|
||||
// -----------------------------------------------------
|
||||
// Track Operations
|
||||
// Get a Track, Get a Track's Audio Features
|
||||
// Get a Track, Get a Track's Audio Features
|
||||
// -----------------------------------------------------
|
||||
{
|
||||
displayName: 'Operation',
|
||||
|
@ -522,10 +530,11 @@ export class Spotify implements INodeType {
|
|||
placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU',
|
||||
description: `The track's Spotify URI or ID.`,
|
||||
},
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Library Operations
|
||||
// Get liked tracks
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// Get liked tracks
|
||||
// -----------------------------------------------------
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
|
@ -546,6 +555,32 @@ export class Spotify implements INodeType {
|
|||
],
|
||||
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',
|
||||
name: 'returnAll',
|
||||
|
@ -558,6 +593,7 @@ export class Spotify implements INodeType {
|
|||
'album',
|
||||
'artist',
|
||||
'library',
|
||||
'myData',
|
||||
'playlist',
|
||||
],
|
||||
operation: [
|
||||
|
@ -566,6 +602,7 @@ export class Spotify implements INodeType {
|
|||
'getUserPlaylists',
|
||||
'getNewReleases',
|
||||
'getLikedTracks',
|
||||
'getFollowingArtists',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -612,9 +649,11 @@ export class Spotify implements INodeType {
|
|||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'myData',
|
||||
'player',
|
||||
],
|
||||
operation: [
|
||||
'getFollowingArtists',
|
||||
'recentlyPlayed',
|
||||
],
|
||||
},
|
||||
|
@ -1046,6 +1085,25 @@ export class Spotify implements INodeType {
|
|||
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) {
|
||||
|
|
Loading…
Reference in a new issue