Skip to content

Commit df02c5c

Browse files
jmfortunatojrJMPerez
authored andcommitted
Sept 11 Playlist API Updates - Fixes #103 (#105)
Sept 11 Playlist API Updates
1 parent 54efc17 commit df02c5c

File tree

3 files changed

+54
-92
lines changed

3 files changed

+54
-92
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ spotifyApi.getUserPlaylists('jmperezperez')
290290
console.error(err);
291291
});
292292

293-
spotifyApi.getPlaylist('jmperezperez', '4vHIKV7j4QcZwgzGQcZg1x')
293+
spotifyApi.getPlaylist('4vHIKV7j4QcZwgzGQcZg1x')
294294
.then(function(data) {
295295
console.log('User playlist', data);
296296
}, function(err) {

__test__/spotify-web-api.spec.js

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -442,25 +442,25 @@ describe('Basic tests', function() {
442442
var callback = sinon.spy();
443443
var api = new SpotifyWebApi();
444444
api.setAccessToken('<example_access_token>');
445-
api.getPlaylist('jmperezperez', '7Kud0O2IdWLbEGgvBkW9di', callback);
445+
api.getPlaylist('7Kud0O2IdWLbEGgvBkW9di', callback);
446446
that.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(fixtures.playlist));
447447
expect(callback.calledWith(null, fixtures.playlist)).toBeTruthy();
448448
expect(that.requests.length).toBe(1);
449449
expect(that.requests[0].url).toBe(
450-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di'
450+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di'
451451
);
452452
});
453453

454454
it('should get the tracks of a playlist', function() {
455455
var callback = sinon.spy();
456456
var api = new SpotifyWebApi();
457457
api.setAccessToken('<example_access_token>');
458-
api.getPlaylistTracks('wizzler', '0EIVqzEcrY2a8vO0AUJar2', callback);
458+
api.getPlaylistTracks('0EIVqzEcrY2a8vO0AUJar2', callback);
459459
that.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(fixtures.playlist_tracks));
460460
expect(callback.calledWith(null, fixtures.playlist_tracks)).toBeTruthy();
461461
expect(that.requests.length).toBe(1);
462462
expect(that.requests[0].url).toBe(
463-
'https://api.spotify.com/v1/users/wizzler/playlists/0EIVqzEcrY2a8vO0AUJar2/tracks'
463+
'https://api.spotify.com/v1/playlists/0EIVqzEcrY2a8vO0AUJar2/tracks'
464464
);
465465
});
466466

@@ -480,7 +480,6 @@ describe('Basic tests', function() {
480480
var api = new SpotifyWebApi();
481481
api.setAccessToken('<example_access_token>');
482482
api.changePlaylistDetails(
483-
'jmperezperez',
484483
'7Kud0O2IdWLbEGgvBkW9di',
485484
{
486485
name: 'A NEW name for the playlist',
@@ -492,7 +491,7 @@ describe('Basic tests', function() {
492491
expect(callback.calledWith(null, '')).toBeTruthy();
493492
expect(that.requests.length).toBe(1);
494493
expect(that.requests[0].url).toBe(
495-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di'
494+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di'
496495
);
497496
});
498497

@@ -501,7 +500,6 @@ describe('Basic tests', function() {
501500
var api = new SpotifyWebApi();
502501
api.setAccessToken('<example_access_token>');
503502
api.addTracksToPlaylist(
504-
'jmperezperez',
505503
'7Kud0O2IdWLbEGgvBkW9di',
506504
['spotify:track:2Oehrcv4Kov0SuIgWyQY9e'],
507505
callback
@@ -510,7 +508,7 @@ describe('Basic tests', function() {
510508
expect(callback.calledWith(null, '')).toBeTruthy();
511509
expect(that.requests.length).toBe(1);
512510
expect(that.requests[0].url).toBe(
513-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
511+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
514512
);
515513
expect(that.requests[0].requestBody).toBe(
516514
JSON.stringify({
@@ -524,7 +522,6 @@ describe('Basic tests', function() {
524522
var api = new SpotifyWebApi();
525523
api.setAccessToken('<example_access_token>');
526524
api.addTracksToPlaylist(
527-
'jmperezperez',
528525
'7Kud0O2IdWLbEGgvBkW9di',
529526
['spotify:track:2Oehrcv4Kov0SuIgWyQY9e'],
530527
{ position: 0 },
@@ -534,7 +531,7 @@ describe('Basic tests', function() {
534531
expect(callback.calledWith(null, '')).toBeTruthy();
535532
expect(that.requests.length).toBe(1);
536533
expect(that.requests[0].url).toBe(
537-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks?position=0'
534+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks?position=0'
538535
);
539536
expect(that.requests[0].requestBody).toBe(
540537
JSON.stringify({
@@ -548,7 +545,6 @@ describe('Basic tests', function() {
548545
var api = new SpotifyWebApi();
549546
api.setAccessToken('<example_access_token>');
550547
api.removeTracksFromPlaylist(
551-
'jmperezperez',
552548
'7Kud0O2IdWLbEGgvBkW9di',
553549
['spotify:track:2Oehrcv4Kov0SuIgWyQY9e'],
554550
callback
@@ -557,7 +553,7 @@ describe('Basic tests', function() {
557553
expect(callback.calledWith(null, '')).toBeTruthy();
558554
expect(that.requests.length).toBe(1);
559555
expect(that.requests[0].url).toBe(
560-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
556+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
561557
);
562558
expect(that.requests[0].method).toBe('DELETE');
563559
expect(that.requests[0].status).toBe(200);
@@ -573,7 +569,6 @@ describe('Basic tests', function() {
573569
var api = new SpotifyWebApi();
574570
api.setAccessToken('<example_access_token>');
575571
api.removeTracksFromPlaylist(
576-
'jmperezperez',
577572
'7Kud0O2IdWLbEGgvBkW9di',
578573
[{ uri: 'spotify:track:2Oehrcv4Kov0SuIgWyQY9e', positions: [6] }],
579574
callback
@@ -582,7 +577,7 @@ describe('Basic tests', function() {
582577
expect(callback.calledWith(null, '')).toBeTruthy();
583578
expect(that.requests.length).toBe(1);
584579
expect(that.requests[0].url).toBe(
585-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
580+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
586581
);
587582
expect(that.requests[0].method).toBe('DELETE');
588583
expect(that.requests[0].status).toBe(200);
@@ -603,7 +598,6 @@ describe('Basic tests', function() {
603598
var api = new SpotifyWebApi();
604599
api.setAccessToken('<example_access_token>');
605600
api.removeTracksFromPlaylistWithSnapshotId(
606-
'jmperezperez',
607601
'7Kud0O2IdWLbEGgvBkW9di',
608602
['spotify:track:2Oehrcv4Kov0SuIgWyQY9e'],
609603
'AsNaPsHoTiD',
@@ -613,7 +607,7 @@ describe('Basic tests', function() {
613607
expect(callback.calledWith(null, '')).toBeTruthy();
614608
expect(that.requests.length).toBe(1);
615609
expect(that.requests[0].url).toBe(
616-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
610+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
617611
);
618612
expect(that.requests[0].method).toBe('DELETE');
619613
expect(that.requests[0].status).toBe(200);
@@ -630,7 +624,6 @@ describe('Basic tests', function() {
630624
var api = new SpotifyWebApi();
631625
api.setAccessToken('<example_access_token>');
632626
api.removeTracksFromPlaylistWithSnapshotId(
633-
'jmperezperez',
634627
'7Kud0O2IdWLbEGgvBkW9di',
635628
[{ uri: 'spotify:track:2Oehrcv4Kov0SuIgWyQY9e', positions: [6] }],
636629
'AsNaPsHoTiD',
@@ -640,7 +633,7 @@ describe('Basic tests', function() {
640633
expect(callback.calledWith(null, '')).toBeTruthy();
641634
expect(that.requests.length).toBe(1);
642635
expect(that.requests[0].url).toBe(
643-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
636+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
644637
);
645638
expect(that.requests[0].method).toBe('DELETE');
646639
expect(that.requests[0].status).toBe(200);
@@ -662,7 +655,6 @@ describe('Basic tests', function() {
662655
var api = new SpotifyWebApi();
663656
api.setAccessToken('<example_access_token>');
664657
api.removeTracksFromPlaylistInPositions(
665-
'jmperezperez',
666658
'7Kud0O2IdWLbEGgvBkW9di',
667659
[0, 1, 3, 9],
668660
'AsNaPsHoTiD',
@@ -672,7 +664,7 @@ describe('Basic tests', function() {
672664
expect(callback.calledWith(null, '')).toBeTruthy();
673665
expect(that.requests.length).toBe(1);
674666
expect(that.requests[0].url).toBe(
675-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
667+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
676668
);
677669
expect(that.requests[0].method).toBe('DELETE');
678670
expect(that.requests[0].status).toBe(200);
@@ -689,7 +681,6 @@ describe('Basic tests', function() {
689681
var api = new SpotifyWebApi();
690682
api.setAccessToken('<example_access_token>');
691683
api.replaceTracksInPlaylist(
692-
'jmperezperez',
693684
'7Kud0O2IdWLbEGgvBkW9di',
694685
['spotify:track:2Oehrcv4Kov0SuIgWyQY9e'],
695686
callback
@@ -698,7 +689,7 @@ describe('Basic tests', function() {
698689
expect(callback.calledWith(null, '')).toBeTruthy();
699690
expect(that.requests.length).toBe(1);
700691
expect(that.requests[0].url).toBe(
701-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
692+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
702693
);
703694
expect(that.requests[0].method).toBe('PUT');
704695
expect(that.requests[0].status).toBe(200);
@@ -713,7 +704,7 @@ describe('Basic tests', function() {
713704
var callback = sinon.spy();
714705
var api = new SpotifyWebApi();
715706
api.setAccessToken('<example_access_token>');
716-
api.reorderTracksInPlaylist('jmperezperez', '7Kud0O2IdWLbEGgvBkW9di', 1, 3, callback);
707+
api.reorderTracksInPlaylist('7Kud0O2IdWLbEGgvBkW9di', 1, 3, callback);
717708
that.requests[0].respond(
718709
200,
719710
{ 'Content-Type': 'application/json' },
@@ -722,7 +713,7 @@ describe('Basic tests', function() {
722713
expect(callback.calledWith(null, { snapshot_id: 'AsNaPsHoTiD' })).toBeTruthy();
723714
expect(that.requests.length).toBe(1);
724715
expect(that.requests[0].url).toBe(
725-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
716+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
726717
);
727718
expect(that.requests[0].method).toBe('PUT');
728719
expect(that.requests[0].status).toBe(200);
@@ -738,7 +729,7 @@ describe('Basic tests', function() {
738729
var callback = sinon.spy();
739730
var api = new SpotifyWebApi();
740731
api.setAccessToken('<example_access_token>');
741-
api.reorderTracksInPlaylist('jmperezperez', '7Kud0O2IdWLbEGgvBkW9di', 1, 3, { range_length: 2 }, callback);
732+
api.reorderTracksInPlaylist('7Kud0O2IdWLbEGgvBkW9di', 1, 3, { range_length: 2 }, callback);
742733
that.requests[0].respond(
743734
200,
744735
{ 'Content-Type': 'application/json' },
@@ -747,7 +738,7 @@ describe('Basic tests', function() {
747738
expect(callback.calledWith(null, { snapshot_id: 'AsNaPsHoTiD' })).toBeTruthy();
748739
expect(that.requests.length).toBe(1);
749740
expect(that.requests[0].url).toBe(
750-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
741+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'
751742
);
752743
expect(that.requests[0].method).toBe('PUT');
753744
expect(that.requests[0].status).toBe(200);
@@ -766,11 +757,11 @@ describe('Basic tests', function() {
766757
var imageDataWithEncoding = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2';
767758
var imageDataWithoutEncoding = '/9j/4AAQSkZJRgABAQAAAQABAAD/2';
768759
api.setAccessToken('<example_access_token>');
769-
api.uploadCustomPlaylistCoverImage('jmperezperez', '7Kud0O2IdWLbEGgvBkW9di', imageDataWithEncoding, callback);
760+
api.uploadCustomPlaylistCoverImage('7Kud0O2IdWLbEGgvBkW9di', imageDataWithEncoding, callback);
770761
that.requests[0].respond(202);
771762
expect(that.requests.length).toBe(1);
772763
expect(that.requests[0].url).toBe(
773-
'https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/images'
764+
'https://api.spotify.com/v1/playlists/7Kud0O2IdWLbEGgvBkW9di/images'
774765
);
775766
expect(that.requests[0].method).toBe('PUT');
776767
expect(that.requests[0].status).toBe(202);
@@ -945,33 +936,33 @@ describe('Basic tests', function() {
945936
it('should follow a playlist publicly', function() {
946937
var callback = sinon.spy();
947938
var api = new SpotifyWebApi();
948-
api.followPlaylist('spotify', '2ujjMpFriZ2nayLmrD1Jgl', callback);
939+
api.followPlaylist('2ujjMpFriZ2nayLmrD1Jgl', callback);
949940
that.requests[0].respond(200);
950941
expect(that.requests[0].method).toBe('PUT');
951942
expect(callback.calledWith(null, '')).toBeTruthy();
952943
expect(that.requests.length).toBe(1);
953944
expect(that.requests[0].url).toBe(
954-
'https://api.spotify.com/v1/users/spotify/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers'
945+
'https://api.spotify.com/v1/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers'
955946
);
956947
});
957948

958949
it('should follow a playlist privately', function() {
959950
var callback = sinon.spy();
960951
var api = new SpotifyWebApi();
961-
api.followPlaylist('spotify', '2ujjMpFriZ2nayLmrD1Jgl', { public: false }, callback);
952+
api.followPlaylist('2ujjMpFriZ2nayLmrD1Jgl', { public: false }, callback);
962953
that.requests[0].respond(200);
963954
expect(that.requests[0].method).toBe('PUT');
964955
expect(callback.calledWith(null, '')).toBeTruthy();
965956
expect(that.requests.length).toBe(1);
966957
expect(that.requests[0].url).toBe(
967-
'https://api.spotify.com/v1/users/spotify/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers'
958+
'https://api.spotify.com/v1/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers'
968959
);
969960
});
970961

971962
it('should check whether users are following a playlist', function() {
972963
var callback = sinon.spy();
973964
var api = new SpotifyWebApi();
974-
api.areFollowingPlaylist('spotify', '2ujjMpFriZ2nayLmrD1Jgl', ['userid01', 'userid02'], callback);
965+
api.areFollowingPlaylist('2ujjMpFriZ2nayLmrD1Jgl', ['userid01', 'userid02'], callback);
975966
that.requests[0].respond(
976967
200,
977968
{ 'Content-Type': 'application/json' },
@@ -981,20 +972,20 @@ describe('Basic tests', function() {
981972
expect(callback.calledWith(null, fixtures.follow_are_following_playlist)).toBeTruthy();
982973
expect(that.requests.length).toBe(1);
983974
expect(that.requests[0].url).toBe(
984-
'https://api.spotify.com/v1/users/spotify/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers/contains?ids=userid01%2Cuserid02'
975+
'https://api.spotify.com/v1/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers/contains?ids=userid01%2Cuserid02'
985976
);
986977
});
987978

988979
it('should unfollow a playlist', function() {
989980
var callback = sinon.spy();
990981
var api = new SpotifyWebApi();
991-
api.unfollowPlaylist('spotify', '2ujjMpFriZ2nayLmrD1Jgl', callback);
982+
api.unfollowPlaylist('2ujjMpFriZ2nayLmrD1Jgl', callback);
992983
that.requests[0].respond(200);
993984
expect(that.requests[0].method).toBe('DELETE');
994985
expect(callback.calledWith(null, '')).toBeTruthy();
995986
expect(that.requests.length).toBe(1);
996987
expect(that.requests[0].url).toBe(
997-
'https://api.spotify.com/v1/users/spotify/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers'
988+
'https://api.spotify.com/v1/playlists/2ujjMpFriZ2nayLmrD1Jgl/followers'
998989
);
999990
});
1000991

0 commit comments

Comments
 (0)