owntone-server/htdocs/assets/spotify-web-api.js

2 lines
12 KiB
JavaScript
Raw Normal View History

2023-12-14 15:00:28 -05:00
import{K as E}from"./index.js";var D={exports:{}};(function(g){var v=function(){var o="https://api.spotify.com/v1",c=null,y=null,T=function(t,e){return t.abort=e,t},q=function(t,e){var r;if(y!==null){var a=y.defer();t(function(u){a.resolve(u)},function(u){a.reject(u)}),r=a.promise}else window.Promise&&(r=new window.Promise(t));return r?new T(r,e):null},m=function(){var t=Array.prototype.slice.call(arguments),e=t[0],r=t.slice(1);return e=e||{},r.forEach(function(a){for(var u in a)a.hasOwnProperty(u)&&(e[u]=a[u])}),e},h=function(t,e){var r="";for(var a in e)if(e.hasOwnProperty(a)){var u=e[a];r+=encodeURIComponent(a)+"="+encodeURIComponent(u)+"&"}return r.length>0&&(r=r.substring(0,r.length-1),t=t+"?"+r),t},P=function(t,e){var r=new XMLHttpRequest,a=function(u,i){function p(l){u&&u(l),e&&e(null,l)}function w(){i&&i(r),e&&e(r,null)}var d=t.type||"GET";if(r.open(d,h(t.url,t.params)),c&&r.setRequestHeader("Authorization","Bearer "+c),r.onreadystatechange=function(){if(r.readyState===4){var l=null;try{l=r.responseText?JSON.parse(r.responseText):""}catch(k){console.error(k)}r.status>=200&&r.status<300?p(l):w()}},d==="GET")r.send(null);else{var f=null;t.postData&&(t.contentType==="image/jpeg"?(f=t.postData,r.setRequestHeader("Content-Type",t.contentType)):(f=JSON.stringify(t.postData),r.setRequestHeader("Content-Type","application/json"))),r.send(f)}};return e?(a(),null):q(a,function(){r.abort()})},n=function(t,e,r,a){var u={},i=null;typeof e=="object"?(u=e,i=r):typeof e=="function"&&(i=e);var p=t.type||"GET";return p!=="GET"&&t.postData&&!a?t.postData=m(t.postData,u):t.params=m(t.params,u),P(t,i)},s=function(){};return s.prototype={constructor:v},s.prototype.getGeneric=function(t,e){var r={url:t};return n(r,e)},s.prototype.getMe=function(t,e){var r={url:o+"/me"};return n(r,t,e)},s.prototype.getMySavedTracks=function(t,e){var r={url:o+"/me/tracks"};return n(r,t,e)},s.prototype.addToMySavedTracks=function(t,e,r){var a={url:o+"/me/tracks",type:"PUT",postData:t};return n(a,e,r)},s.prototype.removeFromMySavedTracks=function(t,e,r){var a={url:o+"/me/tracks",type:"DELETE",postData:t};return n(a,e,r)},s.prototype.containsMySavedTracks=function(t,e,r){var a={url:o+"/me/tracks/contains",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getMySavedAlbums=function(t,e){var r={url:o+"/me/albums"};return n(r,t,e)},s.prototype.addToMySavedAlbums=function(t,e,r){var a={url:o+"/me/albums",type:"PUT",postData:t};return n(a,e,r)},s.prototype.removeFromMySavedAlbums=function(t,e,r){var a={url:o+"/me/albums",type:"DELETE",postData:t};return n(a,e,r)},s.prototype.containsMySavedAlbums=function(t,e,r){var a={url:o+"/me/albums/contains",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getMyTopArtists=function(t,e){var r={url:o+"/me/top/artists"};return n(r,t,e)},s.prototype.getMyTopTracks=function(t,e){var r={url:o+"/me/top/tracks"};return n(r,t,e)},s.prototype.getMyRecentlyPlayedTracks=function(t,e){var r={url:o+"/me/player/recently-played"};return n(r,t,e)},s.prototype.followUsers=function(t,e){var r={url:o+"/me/following/",type:"PUT",params:{ids:t.join(","),type:"user"}};return n(r,e)},s.prototype.followArtists=function(t,e){var r={url:o+"/me/following/",type:"PUT",params:{ids:t.join(","),type:"artist"}};return n(r,e)},s.prototype.followPlaylist=function(t,e,r){var a={url:o+"/playlists/"+t+"/followers",type:"PUT",postData:{}};return n(a,e,r)},s.prototype.unfollowUsers=function(t,e){var r={url:o+"/me/following/",type:"DELETE",params:{ids:t.join(","),type:"user"}};return n(r,e)},s.prototype.unfollowArtists=function(t,e){var r={url:o+"/me/following/",type:"DELETE",params:{ids:t.join(","),type:"artist"}};return n(r,e)},s.prototype.unfollowPlaylist=function(t,e){var r={url:o+"/playlists/"+t+"/followers",type:"DELETE"};return n(r,e)},s.prototype.isFollowingUsers=function(t,e){var r={url:o+"/me/following/contains",type:"GET",params:{ids:t.join(","),type:"user"}};return n(r,e)},s.prototype.isFollowingArtists=function(t,e){var r={url:o+"/me/following/contains",type:"GET",params:{ids:t.join(","),type:"artist"}};return n(r,e)},s.prototype.areFollowi