mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 15:45:56 -05:00
2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
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.areFollowingPlaylist=function(t,e,r){var a={url:o+"/playlists/"+t+"/followers/contains",type:"GET",params:{ids:e.join(",")}};return n(a,r)},s.prototype.getFollowedArtists=function(t,e){var r={url:o+"/me/following",type:"GET",params:{type:"artist"}};return n(r,t,e)},s.prototype.getUser=function(t,e,r){var a={url:o+"/users/"+encodeURIComponent(t)};return n(a,e,r)},s.prototype.getUserPlaylists=function(t,e,r){var a;return typeof t=="string"?a={url:o+"/users/"+encodeURIComponent(t)+"/playlists"}:(a={url:o+"/me/playlists"},r=e,e=t),n(a,e,r)},s.prototype.getPlaylist=function(t,e,r){var a={url:o+"/playlists/"+t};return n(a,e,r)},s.prototype.getPlaylistTracks=function(t,e,r){var a={url:o+"/playlists/"+t+"/tracks"};return n(a,e,r)},s.prototype.getPlaylistCoverImage=function(t,e){var r={url:o+"/playlists/"+t+"/images"};return n(r,e)},s.prototype.createPlaylist=function(t,e,r){var a={url:o+"/users/"+encodeURIComponent(t)+"/playlists",type:"POST",postData:e};return n(a,e,r)},s.prototype.changePlaylistDetails=function(t,e,r){var a={url:o+"/playlists/"+t,type:"PUT",postData:e};return n(a,e,r)},s.prototype.addTracksToPlaylist=function(t,e,r,a){var u={url:o+"/playlists/"+t+"/tracks",type:"POST",postData:{uris:e}};return n(u,r,a,!0)},s.prototype.replaceTracksInPlaylist=function(t,e,r){var a={url:o+"/playlists/"+t+"/tracks",type:"PUT",postData:{uris:e}};return n(a,{},r)},s.prototype.reorderTracksInPlaylist=function(t,e,r,a,u){var i={url:o+"/playlists/"+t+"/tracks",type:"PUT",postData:{range_start:e,insert_before:r}};return n(i,a,u)},s.prototype.removeTracksFromPlaylist=function(t,e,r){var a=e.map(function(i){return typeof i=="string"?{uri:i}:i}),u={url:o+"/playlists/"+t+"/tracks",type:"DELETE",postData:{tracks:a}};return n(u,{},r)},s.prototype.removeTracksFromPlaylistWithSnapshotId=function(t,e,r,a){var u=e.map(function(p){return typeof p=="string"?{uri:p}:p}),i={url:o+"/playlists/"+t+"/tracks",type:"DELETE",postData:{tracks:u,snapshot_id:r}};return n(i,{},a)},s.prototype.removeTracksFromPlaylistInPositions=function(t,e,r,a){var u={url:o+"/playlists/"+t+"/tracks",type:"DELETE",postData:{positions:e,snapshot_id:r}};return n(u,{},a)},s.prototype.uploadCustomPlaylistCoverImage=function(t,e,r){var a={url:o+"/playlists/"+t+"/images",type:"PUT",postData:e.replace(/^data:image\/jpeg;base64,/,""),contentType:"image/jpeg"};return n(a,{},r)},s.prototype.getAlbum=function(t,e,r){var a={url:o+"/albums/"+t};return n(a,e,r)},s.prototype.getAlbumTracks=function(t,e,r){var a={url:o+"/albums/"+t+"/tracks"};return n(a,e,r)},s.prototype.getAlbums=function(t,e,r){var a={url:o+"/albums/",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getTrack=function(t,e,r){var a={};return a.url=o+"/tracks/"+t,n(a,e,r)},s.prototype.getTracks=function(t,e,r){var a={url:o+"/tracks/",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getArtist=function(t,e,r){var a={url:o+"/artists/"+t};return n(a,e,r)},s.prototype.getArtists=function(t,e,r){var a={url:o+"/artists/",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getArtistAlbums=function(t,e,r){var a={url:o+"/artists/"+t+"/albums"};return n(a,e,r)},s.prototype.getArtistTopTracks=function(t,e,r,a){var u={url:o+"/artists/"+t+"/top-tracks",params:{country:e}};return n(u,r,a)},s.prototype.getArtistRelatedArtists=function(t,e,r){var a={url:o+"/artists/"+t+"/related-artists"};return n(a,e,r)},s.prototype.getFeaturedPlaylists=function(t,e){var r={url:o+"/browse/featured-playlists"};return n(r,t,e)},s.prototype.getNewReleases=function(t,e){var r={url:o+"/browse/new-releases"};return n(r,t,e)},s.prototype.getCategories=function(t,e){var r={url:o+"/browse/categories"};return n(r,t,e)},s.prototype.getCategory=function(t,e,r){var a={url:o+"/browse/categories/"+t};return n(a,e,r)},s.prototype.getCategoryPlaylists=function(t,e,r){var a={url:o+"/browse/categories/"+t+"/playlists"};return n(a,e,r)},s.prototype.search=function(t,e,r,a){var u={url:o+"/search/",params:{q:t,type:e.join(",")}};return n(u,r,a)},s.prototype.searchAlbums=function(t,e,r){return this.search(t,["album"],e,r)},s.prototype.searchArtists=function(t,e,r){return this.search(t,["artist"],e,r)},s.prototype.searchTracks=function(t,e,r){return this.search(t,["track"],e,r)},s.prototype.searchPlaylists=function(t,e,r){return this.search(t,["playlist"],e,r)},s.prototype.searchShows=function(t,e,r){return this.search(t,["show"],e,r)},s.prototype.searchEpisodes=function(t,e,r){return this.search(t,["episode"],e,r)},s.prototype.getAudioFeaturesForTrack=function(t,e){var r={};return r.url=o+"/audio-features/"+t,n(r,{},e)},s.prototype.getAudioFeaturesForTracks=function(t,e){var r={url:o+"/audio-features",params:{ids:t}};return n(r,{},e)},s.prototype.getAudioAnalysisForTrack=function(t,e){var r={};return r.url=o+"/audio-analysis/"+t,n(r,{},e)},s.prototype.getRecommendations=function(t,e){var r={url:o+"/recommendations"};return n(r,t,e)},s.prototype.getAvailableGenreSeeds=function(t){var e={url:o+"/recommendations/available-genre-seeds"};return n(e,{},t)},s.prototype.getMyDevices=function(t){var e={url:o+"/me/player/devices"};return n(e,{},t)},s.prototype.getMyCurrentPlaybackState=function(t,e){var r={url:o+"/me/player"};return n(r,t,e)},s.prototype.getMyCurrentPlayingTrack=function(t,e){var r={url:o+"/me/player/currently-playing"};return n(r,t,e)},s.prototype.transferMyPlayback=function(t,e,r){var a=e||{};a.device_ids=t;var u={type:"PUT",url:o+"/me/player",postData:a};return n(u,e,r)},s.prototype.play=function(t,e){t=t||{};var r="device_id"in t?{device_id:t.device_id}:null,a={};["context_uri","uris","offset","position_ms"].forEach(function(p){p in t&&(a[p]=t[p])});var u={type:"PUT",url:o+"/me/player/play",params:r,postData:a},i=typeof t=="function"?t:{};return n(u,i,e)},s.prototype.queue=function(t,e,r){e=e||{};var a="device_id"in e?{uri:t,device_id:e.device_id}:{uri:t},u={type:"POST",url:o+"/me/player/queue",params:a};return n(u,e,r)},s.prototype.pause=function(t,e){t=t||{};var r="device_id"in t?{device_id:t.device_id}:null,a={type:"PUT",url:o+"/me/player/pause",params:r};return n(a,t,e)},s.prototype.skipToNext=function(t,e){t=t||{};var r="device_id"in t?{device_id:t.device_id}:null,a={type:"POST",url:o+"/me/player/next",params:r};return n(a,t,e)},s.prototype.skipToPrevious=function(t,e){t=t||{};var r="device_id"in t?{device_id:t.device_id}:null,a={type:"POST",url:o+"/me/player/previous",params:r};return n(a,t,e)},s.prototype.seek=function(t,e,r){e=e||{};var a={position_ms:t};"device_id"in e&&(a.device_id=e.device_id);var u={type:"PUT",url:o+"/me/player/seek",params:a};return n(u,e,r)},s.prototype.setRepeat=function(t,e,r){e=e||{};var a={state:t};"device_id"in e&&(a.device_id=e.device_id);var u={type:"PUT",url:o+"/me/player/repeat",params:a};return n(u,e,r)},s.prototype.setVolume=function(t,e,r){e=e||{};var a={volume_percent:t};"device_id"in e&&(a.device_id=e.device_id);var u={type:"PUT",url:o+"/me/player/volume",params:a};return n(u,e,r)},s.prototype.setShuffle=function(t,e,r){e=e||{};var a={state:t};"device_id"in e&&(a.device_id=e.device_id);var u={type:"PUT",url:o+"/me/player/shuffle",params:a};return n(u,e,r)},s.prototype.getShow=function(t,e,r){var a={};return a.url=o+"/shows/"+t,n(a,e,r)},s.prototype.getShows=function(t,e,r){var a={url:o+"/shows/",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getMySavedShows=function(t,e){var r={url:o+"/me/shows"};return n(r,t,e)},s.prototype.addToMySavedShows=function(t,e,r){var a={url:o+"/me/shows",type:"PUT",postData:t};return n(a,e,r)},s.prototype.removeFromMySavedShows=function(t,e,r){var a={url:o+"/me/shows",type:"DELETE",postData:t};return n(a,e,r)},s.prototype.containsMySavedShows=function(t,e,r){var a={url:o+"/me/shows/contains",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getShowEpisodes=function(t,e,r){var a={url:o+"/shows/"+t+"/episodes"};return n(a,e,r)},s.prototype.getEpisode=function(t,e,r){var a={};return a.url=o+"/episodes/"+t,n(a,e,r)},s.prototype.getEpisodes=function(t,e,r){var a={url:o+"/episodes/",params:{ids:t.join(",")}};return n(a,e,r)},s.prototype.getAccessToken=function(){return c},s.prototype.setAccessToken=function(t){c=t},s.prototype.setPromiseImplementation=function(t){var e=!1;try{var r=new t(function(a){a()});typeof r.then=="function"&&typeof r.catch=="function"&&(e=!0)}catch(a){console.error(a)}if(e)y=t;else throw new Error("Unsupported implementation of Promises/A+")},s}();g.exports=v})(D);var _=D.exports;const S=E(_);export{S};
|