-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotify.min.js
1 lines (1 loc) · 7.82 KB
/
spotify.min.js
1
"use strict";var SpotifyWebApi=function(){var t="https://api.spotify.com/v1",r=null,e=null,o=function(t,r){return t.abort=r,t},s=function(t,r){var s;if(null!==e){var n=e.defer();t(function(t){n.resolve(t)},function(t){n.reject(t)}),s=n.promise}else window.Promise&&(s=new window.Promise(t));return s?new o(s,r):null},n=function(){var t=Array.prototype.slice.call(arguments),r=t[0],e=t.slice(1);return r=r||{},e.forEach(function(t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])}),r},a=function(t,r){var e="";for(var o in r)if(r.hasOwnProperty(o)){var s=r[o];e+=encodeURIComponent(o)+"="+encodeURIComponent(s)+"&"}return e.length>0&&(e=e.substring(0,e.length-1),t=t+"?"+e),t},u=function(t,e){var o=new XMLHttpRequest,n=function(s,n){function u(t){s&&s(t),e&&e(null,t)}function p(){n&&n(o),e&&e(o,null)}var i=t.type||"GET";o.open(i,a(t.url,t.params)),r&&o.setRequestHeader("Authorization","Bearer "+r),o.onreadystatechange=function(){if(4===o.readyState){var t=null;try{t=o.responseText?JSON.parse(o.responseText):""}catch(r){console.error(r)}o.status>=200&&o.status<300?u(t):p()}},"GET"===i?o.send(null):o.send(t.postData?JSON.stringify(t.postData):null)};return e?(n(),null):s(n,function(){o.abort()})},p=function(t,r,e){var o={},s=null;"object"==typeof r?(o=r,s=e):"function"==typeof r&&(s=r);var a=t.type||"GET";return"GET"!==a&&t.postData?t.postData=n(t.postData,o):t.params=n(t.params,o),u(t,s)},i=function(){};return i.prototype={constructor:SpotifyWebApi},i.prototype.getGeneric=function(t,r){var e={url:t};return p(e,r)},i.prototype.getMe=function(r,e){var o={url:t+"/me"};return p(o,r,e)},i.prototype.getMySavedTracks=function(r,e){var o={url:t+"/me/tracks"};return p(o,r,e)},i.prototype.addToMySavedTracks=function(r,e,o){var s={url:t+"/me/tracks",type:"PUT",postData:r};return p(s,e,o)},i.prototype.removeFromMySavedTracks=function(r,e,o){var s={url:t+"/me/tracks",type:"DELETE",postData:r};return p(s,e,o)},i.prototype.containsMySavedTracks=function(r,e,o){var s={url:t+"/me/tracks/contains",params:{ids:r.join(",")}};return p(s,e,o)},i.prototype.getMySavedAlbums=function(r,e){var o={url:t+"/me/albums"};return p(o,r,e)},i.prototype.addToMySavedAlbums=function(r,e,o){var s={url:t+"/me/albums",type:"PUT",postData:r};return p(s,e,o)},i.prototype.removeFromMySavedAlbums=function(r,e,o){var s={url:t+"/me/albums",type:"DELETE",postData:r};return p(s,e,o)},i.prototype.containsMySavedAlbums=function(r,e,o){var s={url:t+"/me/albums/contains",params:{ids:r.join(",")}};return p(s,e,o)},i.prototype.followUsers=function(r,e){var o={url:t+"/me/following/",type:"PUT",params:{ids:r.join(","),type:"user"}};return p(o,e)},i.prototype.followArtists=function(r,e){var o={url:t+"/me/following/",type:"PUT",params:{ids:r.join(","),type:"artist"}};return p(o,e)},i.prototype.followPlaylist=function(r,e,o,s){var n={url:t+"/users/"+r+"/playlists/"+e+"/followers",type:"PUT",postData:{}};return p(n,o,s)},i.prototype.unfollowUsers=function(r,e){var o={url:t+"/me/following/",type:"DELETE",params:{ids:r.join(","),type:"user"}};return p(o,e)},i.prototype.unfollowArtists=function(r,e){var o={url:t+"/me/following/",type:"DELETE",params:{ids:r.join(","),type:"artist"}};return p(o,e)},i.prototype.unfollowPlaylist=function(r,e,o){var s={url:t+"/users/"+r+"/playlists/"+e+"/followers",type:"DELETE"};return p(s,o)},i.prototype.isFollowingUsers=function(r,e){var o={url:t+"/me/following/contains",type:"GET",params:{ids:r.join(","),type:"user"}};return p(o,e)},i.prototype.isFollowingArtists=function(r,e){var o={url:t+"/me/following/contains",type:"GET",params:{ids:r.join(","),type:"artist"}};return p(o,e)},i.prototype.areFollowingPlaylist=function(r,e,o,s){var n={url:t+"/users/"+r+"/playlists/"+e+"/followers/contains",type:"GET",params:{ids:o.join(",")}};return p(n,s)},i.prototype.getFollowedArtists=function(r,e){var o={url:t+"/me/following",type:"GET",params:{type:"artist"}};return p(o,r,e)},i.prototype.getUser=function(r,e,o){var s={url:t+"/users/"+r};return p(s,e,o)},i.prototype.getUserPlaylists=function(r,e,o){var s;return"string"==typeof r?s={url:t+"/users/"+r+"/playlists"}:(s={url:t+"/me/playlists"},e=r,o=e),p(s,e,o)},i.prototype.getPlaylist=function(r,e,o,s){var n={url:t+"/users/"+r+"/playlists/"+e};return p(n,o,s)},i.prototype.getPlaylistTracks=function(r,e,o,s){var n={url:t+"/users/"+r+"/playlists/"+e+"/tracks"};return p(n,o,s)},i.prototype.createPlaylist=function(r,e,o){var s={url:t+"/users/"+r+"/playlists",type:"POST",postData:e};return p(s,e,o)},i.prototype.changePlaylistDetails=function(r,e,o,s){var n={url:t+"/users/"+r+"/playlists/"+e,type:"PUT",postData:o};return p(n,o,s)},i.prototype.addTracksToPlaylist=function(r,e,o,s,n){var a={url:t+"/users/"+r+"/playlists/"+e+"/tracks",type:"POST",params:{uris:o}};return p(a,s,n)},i.prototype.replaceTracksInPlaylist=function(r,e,o,s){var n={url:t+"/users/"+r+"/playlists/"+e+"/tracks",type:"PUT",postData:{uris:o}};return p(n,{},s)},i.prototype.reorderTracksInPlaylist=function(r,e,o,s,n,a){var u={url:t+"/users/"+r+"/playlists/"+e+"/tracks",type:"PUT",postData:{range_start:o,insert_before:s}};return p(u,n,a)},i.prototype.removeTracksFromPlaylist=function(r,e,o,s){var n=o.map(function(t){return"string"==typeof t?{uri:t}:t}),a={url:t+"/users/"+r+"/playlists/"+e+"/tracks",type:"DELETE",postData:{tracks:n}};return p(a,{},s)},i.prototype.removeTracksFromPlaylistWithSnapshotId=function(r,e,o,s,n){var a=o.map(function(t){return"string"==typeof t?{uri:t}:t}),u={url:t+"/users/"+r+"/playlists/"+e+"/tracks",type:"DELETE",postData:{tracks:a,snapshot_id:s}};return p(u,{},n)},i.prototype.removeTracksFromPlaylistInPositions=function(r,e,o,s,n){var a={url:t+"/users/"+r+"/playlists/"+e+"/tracks",type:"DELETE",postData:{positions:o,snapshot_id:s}};return p(a,{},n)},i.prototype.getAlbum=function(r,e,o){var s={url:t+"/albums/"+r};return p(s,e,o)},i.prototype.getAlbumTracks=function(r,e,o){var s={url:t+"/albums/"+r+"/tracks"};return p(s,e,o)},i.prototype.getAlbums=function(r,e,o){var s={url:t+"/albums/",params:{ids:r.join(",")}};return p(s,e,o)},i.prototype.getTrack=function(r,e,o){var s={};return s.url=t+"/tracks/"+r,p(s,e,o)},i.prototype.getTracks=function(r,e,o){var s={url:t+"/tracks/",params:{ids:r.join(",")}};return p(s,e,o)},i.prototype.getArtist=function(r,e,o){var s={url:t+"/artists/"+r};return p(s,e,o)},i.prototype.getArtists=function(r,e,o){var s={url:t+"/artists/",params:{ids:r.join(",")}};return p(s,e,o)},i.prototype.getArtistAlbums=function(r,e,o){var s={url:t+"/artists/"+r+"/albums"};return p(s,e,o)},i.prototype.getArtistTopTracks=function(r,e,o,s){var n={url:t+"/artists/"+r+"/top-tracks",params:{country:e}};return p(n,o,s)},i.prototype.getArtistRelatedArtists=function(r,e,o){var s={url:t+"/artists/"+r+"/related-artists"};return p(s,e,o)},i.prototype.getFeaturedPlaylists=function(r,e){var o={url:t+"/browse/featured-playlists"};return p(o,r,e)},i.prototype.getNewReleases=function(r,e){var o={url:t+"/browse/new-releases"};return p(o,r,e)},i.prototype.getCategories=function(r,e){var o={url:t+"/browse/categories"};return p(o,r,e)},i.prototype.getCategory=function(r,e,o){var s={url:t+"/browse/categories/"+r};return p(s,e,o)},i.prototype.getCategoryPlaylists=function(r,e,o){var s={url:t+"/browse/categories/"+r+"/playlists"};return p(s,e,o)},i.prototype.searchAlbums=function(r,e,o){var s={url:t+"/search/",params:{q:r,type:"album"}};return p(s,e,o)},i.prototype.searchArtists=function(r,e,o){var s={url:t+"/search/",params:{q:r,type:"artist"}};return p(s,e,o)},i.prototype.searchTracks=function(r,e,o){var s={url:t+"/search/",params:{q:r,type:"track"}};return p(s,e,o)},i.prototype.searchPlaylists=function(r,e,o){var s={url:t+"/search/",params:{q:r,type:"playlist"}};return p(s,e,o)},i.prototype.getAccessToken=function(){return r},i.prototype.setAccessToken=function(t){r=t},i.prototype.setPromiseImplementation=function(t){if(!("defer"in t))throw new Error("Unsupported implementation of Promises/A+");e=t},i}();"object"==typeof module&&"object"==typeof module.exports&&(module.exports=SpotifyWebApi);