javascript-ampache 0.0.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.m.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from"querystringify";import t from"isomorphic-unfetch";import r from"jssha/dist/sha256";function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}var i,o=function(){function e(e){this.sessionKey=void 0,this.url=void 0,this.version="6.0.0",this.debug=void 0,this.sessionKey=e.sessionKey||null,this.url=e.url,this.debug=e.debug||!1}var r=e.prototype;return r.request=function(e,r){void 0===r&&(r=!0);var n=this.url+"/server/json.server.php?action="+e;return r&&(n+="&auth="+this.sessionKey+"&version="+this.version),this.debug&&console.debug("javascript-ampache query URL %c"+n,"color: black; font-style: italic; background-color: orange;padding: 2px"),t(n).then(function(e){if(e.ok)return e.json();throw new Error(e.statusText)})},r.setSessionKey=function(e){this.sessionKey=e},e}(),u=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.albums=function(t){try{var r="albums";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},s.album=function(t){var r="album";return r+=e.stringify(t,"&"),this.request(r)},s.artistAlbums=function(t){try{var r="artist_albums";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},s.genreAlbums=function(t){try{var r="genre_albums";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},r}(o),c=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.artists=function(t){try{var r="artists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},s.artist=function(t){var r="artist";return r+=e.stringify(t,"&"),this.request(r)},s.genreArtists=function(t){try{var r="genre_artists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},s.labelArtists=function(t){try{var r="label_artists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},r}(o),a=function(s){function i(){return s.apply(this,arguments)||this}n(i,s);var o=i.prototype;return o.handshake=function(r){var n=this;r.timestamp||(r.timestamp=Math.floor((new Date).getTime()/1e3)),r.version&&(this.version=r.version),r.user||delete r.timestamp;var s=this.url+"/server/json.server.php?action=handshake";return s+=e.stringify(r,"&"),t(s).then(function(e){return e.json()}).then(function(e){return e.auth&&(n.sessionKey=e.auth),e})},o.ping=function(t){var r="ping";return r+=e.stringify(t,"&"),this.request(r,!1)},o.goodbye=function(t){var r="goodbye";return r+=e.stringify(t,"&"),this.request(r,!1)},o.encryptPassword=function(e){var t=n(e.password);return n(e.time+t);function n(e){var t=new r("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("HEX")}},i}(o),f=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.bookmarks=function(){try{return Promise.resolve(this.request("bookmarks")).then(function(e){return e.bookmark?e.bookmark:e})}catch(e){return Promise.reject(e)}},s.getBookmark=function(t){var r="get_bookmark";return r+=e.stringify(t,"&"),this.request(r)},s.bookmarkCreate=function(t){var r="bookmark_create";return r+=e.stringify(t,"&"),this.request(r)},s.bookmarkEdit=function(t){var r="bookmark_edit";return r+=e.stringify(t,"&"),this.request(r)},s.bookmarkDelete=function(t){var r="bookmark_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),l=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.catalogs=function(t){try{var r="catalogs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.catalog?e.catalog:e})}catch(e){return Promise.reject(e)}},s.catalog=function(t){var r="catalog";return r+=e.stringify(t,"&"),this.request(r)},s.catalogAction=function(t){var r="catalog_action";return r+=e.stringify(t,"&"),this.request(r)},s.catalogFile=function(t){var r="catalog_file";return r+=e.stringify(t,"&"),this.request(r)},r}(o),h=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.genres=function(t){try{var r="genres";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.genre?e.genre:e})}catch(e){return Promise.reject(e)}},s.genre=function(t){try{var r="genre";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.genre?e.genre:e})}catch(e){return Promise.reject(e)}},r}(o),y=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.labels=function(t){try{var r="labels";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.label?e.label:e})}catch(e){return Promise.reject(e)}},s.label=function(t){var r="label";return r+=e.stringify(t,"&"),this.request(r)},r}(o),p=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.licenses=function(t){try{var r="licenses";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.license?e.license:e})}catch(e){return Promise.reject(e)}},s.license=function(t){var r="license";return r+=e.stringify(t,"&"),this.request(r)},r}(o),v=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.liveStreams=function(t){try{var r="live_streams";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.live_stream?e.live_stream:e})}catch(e){return Promise.reject(e)}},s.liveStream=function(t){var r="live_stream";return r+=e.stringify(t,"&"),this.request(r)},r}(o),g=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.playlists=function(t){try{var r="playlists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.playlist?e.playlist:e})}catch(e){return Promise.reject(e)}},s.smartlists=function(t){try{var r="playlists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){var t=e.playlist?e.playlist:e;return Array.isArray(t)&&(t=t.filter(function(e){return e.id.toString().match(/^smart_/)})),t})}catch(e){return Promise.reject(e)}},s.playlist=function(t){var r="playlist";return r+=e.stringify(t,"&"),this.request(r)},s.playlistCreate=function(t){var r="playlist_create";return r+=e.stringify(t,"&"),this.request(r)},s.playlistEdit=function(t){var r="playlist_edit";return r+=e.stringify(t,"&"),this.request(r)},s.playlistDelete=function(t){var r="playlist_delete";return r+=e.stringify(t,"&"),this.request(r)},s.playlistAddSong=function(t){var r="playlist_add_song";return r+=e.stringify(t,"&"),this.request(r)},s.playlistRemoveSong=function(t){var r="playlist_remove_song";return r+=e.stringify(t,"&"),this.request(r)},s.playlistGenerate=function(t){try{var r="playlist_generate";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r}(o),m=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.podcasts=function(t){try{var r="podcasts";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.podcast?e.podcast:e})}catch(e){return Promise.reject(e)}},s.podcast=function(t){try{var r="podcast";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.podcast?e.podcast:e})}catch(e){return Promise.reject(e)}},s.podcastCreate=function(t){var r="podcast_create";return r+=e.stringify(t,"&"),this.request(r)},s.podcastEdit=function(t){var r="podcast_edit";return r+=e.stringify(t,"&"),this.request(r)},s.podcastDelete=function(t){var r="podcast_delete";return r+=e.stringify(t,"&"),this.request(r)},s.podcastEpisodes=function(t){try{var r="podcast_episodes";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.podcast_episode?e.podcast_episode:e})}catch(e){return Promise.reject(e)}},s.podcastEpisode=function(t){var r="podcast_episode";return r+=e.stringify(t,"&"),this.request(r)},s.podcastEpisodeDelete=function(t){var r="podcast_episode_delete";return r+=e.stringify(t,"&"),this.request(r)},s.updatePodcast=function(t){var r="update_podcast";return r+=e.stringify(t,"&"),this.request(r)},s.deletedPodcastEpisodes=function(t){try{var r="deleted_podcast_episodes";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.deleted_podcast_episode?e.deleted_podcast_episode:e})}catch(e){return Promise.reject(e)}},r}(o),d=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.systemPreferences=function(){try{return Promise.resolve(this.request("system_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},s.systemPreference=function(t){try{var r="system_preference";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}},s.userPreferences=function(){try{return Promise.resolve(this.request("user_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},s.userPreference=function(t){try{var r="user_preference";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}},s.preferenceCreate=function(t){var r="preference_create";return r+=e.stringify(t,"&"),this.request(r)},s.preferenceEdit=function(t){var r="preference_edit";return r+=e.stringify(t,"&"),this.request(r)},s.preferenceDelete=function(t){var r="preference_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),P=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.shares=function(t){try{var r="shares";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.share?e.share:e})}catch(e){return Promise.reject(e)}},s.share=function(t){var r="share";return r+=e.stringify(t,"&"),this.request(r)},s.shareCreate=function(t){var r="share_create";return r+=e.stringify(t,"&"),this.request(r)},s.shareEdit=function(t){var r="share_edit";return r+=e.stringify(t,"&"),this.request(r)},s.shareDelete=function(t){var r="share_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),q=function(t){function r(){return t.apply(this,arguments)||this}return n(r,t),r.prototype.last_shouts=function(t){try{var r="last_shouts";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.shout?e.shout:e})}catch(e){return Promise.reject(e)}},r}(o),_=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.songs=function(t){try{var r="songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.song=function(t){var r="song";return r+=e.stringify(t,"&"),this.request(r)},s.artistSongs=function(t){try{var r="artist_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.albumSongs=function(t){try{var r="album_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.genreSongs=function(t){try{var r="genre_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.playlistSongs=function(t){try{var r="playlist_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.licenseSongs=function(t){try{var r="license_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.songDelete=function(t){var r="song_delete";return r+=e.stringify(t,"&"),this.request(r)},s.urlToSong=function(t){var r="url_to_song";return t.url=encodeURIComponent(t.url),r+=e.stringify(t,"&"),this.request(r)},s.searchSongs=function(t){try{var r="search_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.deletedSongs=function(t){try{var r="deleted_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.deleted_song?e.deleted_song:e})}catch(e){return Promise.reject(e)}},r}(o),b=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.systemUpdate=function(){return this.request("system_update")},s.getIndexes=function(t){try{var r,n=this,s="get_indexes";switch(s+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(n.request(s)).then(function(e){return(r=e).song?r.song:r});case"album":return Promise.resolve(n.request(s)).then(function(e){return(r=e).album?r.album:r});case"artist":case"album_artist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).artist?r.artist:r});case"playlist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).playlist?r.playlist:r});case"podcast":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast?r.podcast:r});case"podcast_episode":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast_episode?r.podcast_episode:r});case"live_stream":return Promise.resolve(n.request(s)).then(function(e){return(r=e).live_stream?r.live_stream:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},s.getSimilar=function(t){try{var r,n="get_similar";switch(n+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(this.request(n)).then(function(e){return(r=e).song?r.song:r});case"artist":return Promise.resolve(this.request(n)).then(function(e){return(r=e).artist?r.artist:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},s.stats=function(t){try{var r,n=this,s="stats";switch(s+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(n.request(s)).then(function(e){return(r=e).song?r.song:r});case"album":return Promise.resolve(n.request(s)).then(function(e){return(r=e).album?r.album:r});case"artist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).artist?r.artist:r});case"video":return Promise.resolve(n.request(s)).then(function(e){return(r=e).video?r.video:r});case"playlist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).playlist?r.playlist:r});case"podcast":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast?r.podcast:r});case"podcast_episode":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast_episode?r.podcast_episode:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},s.rate=function(t){var r="rate";return r+=e.stringify(t,"&"),this.request(r)},s.flag=function(t){var r="flag";return r+=e.stringify(t,"&"),this.request(r)},s.recordPlay=function(t){var r="record_play";return r+=e.stringify(t,"&"),this.request(r)},s.scrobble=function(t){var r="scrobble";return r+=e.stringify(t,"&"),this.request(r)},s.updateFromTags=function(t){var r="update_from_tags";return r+=e.stringify(t,"&"),this.request(r)},s.updateArtistInfo=function(t){var r="update_artist_info";return r+=e.stringify(t,"&"),this.request(r)},s.updateArt=function(t){var r="update_art";return r+=e.stringify(t,"&"),this.request(r)},s.stream=function(t){var r="stream";return r+=e.stringify(t,"&"),this.request(r)},s.download=function(t){var r="download";return r+=e.stringify(t,"&"),this.request(r)},s.getArt=function(t){var r="get_art";return r+=e.stringify(t,"&"),this.request(r)},s.localplay=function(t){var r="localplay";return r+=e.stringify(t,"&"),this.request(r)},s.localplaySongs=function(){return this.request("localplay_songs")},s.democratic=function(t){var r="democratic";return r+=e.stringify(t,"&"),this.request(r)},s.advancedSearch=function(t){try{for(var r,n=this,s="advanced_search",i=0;i<t.rules.length;i++){var o=t.rules[i],u=i+1;t["rule_"+u]=o[0],t["rule_"+u+"_operator"]=o[1],t["rule_"+u+"_input"]=o[2],"metadata"===o[0]&&(t["rule_"+u+"_subtype"]=o[3])}switch(delete t.rules,s+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(n.request(s)).then(function(e){return(r=e).song?r.song:r});case"album":return Promise.resolve(n.request(s)).then(function(e){return(r=e).album?r.album:r});case"artist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).artist?r.artist:r});case"label":return Promise.resolve(n.request(s)).then(function(e){return(r=e).label?r.label:r});case"playlist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).playlist?r.playlist:r});case"podcast":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast?r.podcast:r});case"podcast_episode":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast_episode?r.podcast_episode:r});case"genre":return Promise.resolve(n.request(s)).then(function(e){return(r=e).genre?r.genre:r});case"user":return Promise.resolve(n.request(s)).then(function(e){return(r=e).user?r.user:r});case"video":return Promise.resolve(n.request(s)).then(function(e){return(r=e).video?r.video:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},r}(o),j=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.users=function(){try{return Promise.resolve(this.request("users")).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},s.user=function(t){try{var r="user";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r))}catch(e){return Promise.reject(e)}},s.userCreate=function(t){var r="user_create";return r+=e.stringify(t,"&"),this.request(r)},s.userUpdate=function(t){var r="user_update";return r+=e.stringify(t,"&"),this.request(r)},s.userDelete=function(t){var r="user_delete";return r+=e.stringify(t,"&"),this.request(r)},s.followers=function(t){try{var r="followers";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},s.following=function(t){try{var r="following";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},s.toggleFollow=function(t){var r="toggle_follow";return r+=e.stringify(t,"&"),this.request(r)},s.timeline=function(t){try{var r="timeline";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},s.friendsTimeline=function(t){try{var r="friends_timeline";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},r}(o),k=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.videos=function(t){try{var r="videos";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.video?e.video:e})}catch(e){return Promise.reject(e)}},s.video=function(t){var r="video";return r+=e.stringify(t,"&"),this.request(r)},s.deletedVideos=function(t){try{var r="deleted_videos";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.deleted_video?e.deleted_video:e})}catch(e){return Promise.reject(e)}},r}(o),w=function(e){function t(){return e.apply(this,arguments)||this}return n(t,e),t}(o);i=w,[u,c,a,f,l,h,y,p,v,g,m,d,P,q,_,b,j,k].forEach(function(e){Object.getOwnPropertyNames(e.prototype).forEach(function(t){Object.defineProperty(i.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t))})});export{w as default};
1
+ import e from"querystringify";import t from"isomorphic-unfetch";import r from"jssha/dist/sha256";function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}var i,o=function(){function e(e){this.sessionKey=void 0,this.url=void 0,this.version="6.0.0",this.debug=void 0,this.sessionKey=e.sessionKey||null,this.url=e.url,this.debug=e.debug||!1}var r=e.prototype;return r.request=function(e,r){void 0===r&&(r=!0);var n=this.url+"/server/json.server.php?action="+e;return r&&(n+="&auth="+this.sessionKey+"&version="+this.version),this.debug&&console.debug("javascript-ampache query URL %c"+n,"color: black; font-style: italic; background-color: orange;padding: 2px"),t(n).then(function(e){if(e.ok)return e.json();throw new Error(e.statusText)})},r.binary=function(e,r){void 0===r&&(r=!0);var n=this.url+"/server/json.server.php?action="+e;return r&&(n+="&auth="+this.sessionKey+"&version="+this.version),this.debug&&console.debug("javascript-ampache query URL %c"+n,"color: black; font-style: italic; background-color: orange;padding: 2px"),t(n).then(function(e){return e.blob()}).then(function(e){return e})},r.setSessionKey=function(e){this.sessionKey=e},e}(),u=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.albums=function(t){try{var r="albums";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},s.album=function(t){var r="album";return r+=e.stringify(t,"&"),this.request(r)},s.artistAlbums=function(t){try{var r="artist_albums";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},s.genreAlbums=function(t){try{var r="genre_albums";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},r}(o),a=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.artists=function(t){try{var r="artists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},s.artist=function(t){var r="artist";return r+=e.stringify(t,"&"),this.request(r)},s.genreArtists=function(t){try{var r="genre_artists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},s.labelArtists=function(t){try{var r="label_artists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},r}(o),c=function(s){function i(){return s.apply(this,arguments)||this}n(i,s);var o=i.prototype;return o.handshake=function(r){var n=this;r.timestamp||(r.timestamp=Math.floor((new Date).getTime()/1e3)),r.version&&(this.version=r.version),r.user||delete r.timestamp;var s=this.url+"/server/json.server.php?action=handshake";return s+=e.stringify(r,"&"),t(s).then(function(e){return e.json()}).then(function(e){return e.auth&&(n.sessionKey=e.auth),e})},o.ping=function(t){var r="ping";return r+=e.stringify(t,"&"),this.request(r,!1)},o.goodbye=function(t){var r="goodbye";return r+=e.stringify(t,"&"),this.request(r,!1)},o.encryptPassword=function(e){var t=n(e.password);return n(e.time+t);function n(e){var t=new r("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("HEX")}},i}(o),f=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.bookmarks=function(){try{return Promise.resolve(this.request("bookmarks")).then(function(e){return e.bookmark?e.bookmark:e})}catch(e){return Promise.reject(e)}},s.getBookmark=function(t){var r="get_bookmark";return r+=e.stringify(t,"&"),this.request(r)},s.bookmarkCreate=function(t){var r="bookmark_create";return r+=e.stringify(t,"&"),this.request(r)},s.bookmarkEdit=function(t){var r="bookmark_edit";return r+=e.stringify(t,"&"),this.request(r)},s.bookmarkDelete=function(t){var r="bookmark_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),l=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.catalogs=function(t){try{var r="catalogs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.catalog?e.catalog:e})}catch(e){return Promise.reject(e)}},s.catalog=function(t){var r="catalog";return r+=e.stringify(t,"&"),this.request(r)},s.catalogAction=function(t){var r="catalog_action";return r+=e.stringify(t,"&"),this.request(r)},s.catalogFile=function(t){var r="catalog_file";return r+=e.stringify(t,"&"),this.request(r)},s.catalogAdd=function(t){var r="catalog_add";return r+=e.stringify(t,"&"),this.request(r)},s.catalogDelete=function(t){var r="catalog_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),h=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.genres=function(t){try{var r="genres";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.genre?e.genre:e})}catch(e){return Promise.reject(e)}},s.genre=function(t){try{var r="genre";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.genre?e.genre:e})}catch(e){return Promise.reject(e)}},r}(o),y=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.labels=function(t){try{var r="labels";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.label?e.label:e})}catch(e){return Promise.reject(e)}},s.label=function(t){var r="label";return r+=e.stringify(t,"&"),this.request(r)},r}(o),v=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.licenses=function(t){try{var r="licenses";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.license?e.license:e})}catch(e){return Promise.reject(e)}},s.license=function(t){var r="license";return r+=e.stringify(t,"&"),this.request(r)},r}(o),p=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.liveStreams=function(t){try{var r="live_streams";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.live_stream?e.live_stream:e})}catch(e){return Promise.reject(e)}},s.liveStream=function(t){var r="live_stream";return r+=e.stringify(t,"&"),this.request(r)},s.liveStreamCreate=function(t){var r="live_stream_create";return r+=e.stringify(t,"&"),this.request(r)},s.liveStreamEdit=function(t){var r="live_stream_edit";return r+=e.stringify(t,"&"),this.request(r)},s.liveStreamDelete=function(t){var r="live_stream_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),g=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.playlists=function(t){try{var r="playlists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.playlist?e.playlist:e})}catch(e){return Promise.reject(e)}},s.smartlists=function(t){try{var r="playlists";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){var t=e.playlist?e.playlist:e;return Array.isArray(t)&&(t=t.filter(function(e){return e.id.toString().match(/^smart_/)})),t})}catch(e){return Promise.reject(e)}},s.playlist=function(t){var r="playlist";return r+=e.stringify(t,"&"),this.request(r)},s.playlistCreate=function(t){var r="playlist_create";return r+=e.stringify(t,"&"),this.request(r)},s.playlistEdit=function(t){var r="playlist_edit";return r+=e.stringify(t,"&"),this.request(r)},s.playlistDelete=function(t){var r="playlist_delete";return r+=e.stringify(t,"&"),this.request(r)},s.playlistAddSong=function(t){var r="playlist_add_song";return r+=e.stringify(t,"&"),this.request(r)},s.playlistRemoveSong=function(t){var r="playlist_remove_song";return r+=e.stringify(t,"&"),this.request(r)},s.playlistGenerate=function(t){try{var r="playlist_generate";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r}(o),m=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.podcasts=function(t){try{var r="podcasts";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.podcast?e.podcast:e})}catch(e){return Promise.reject(e)}},s.podcast=function(t){try{var r="podcast";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.podcast?e.podcast:e})}catch(e){return Promise.reject(e)}},s.podcastCreate=function(t){var r="podcast_create";return r+=e.stringify(t,"&"),this.request(r)},s.podcastEdit=function(t){var r="podcast_edit";return r+=e.stringify(t,"&"),this.request(r)},s.podcastDelete=function(t){var r="podcast_delete";return r+=e.stringify(t,"&"),this.request(r)},s.podcastEpisodes=function(t){try{var r="podcast_episodes";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.podcast_episode?e.podcast_episode:e})}catch(e){return Promise.reject(e)}},s.podcastEpisode=function(t){var r="podcast_episode";return r+=e.stringify(t,"&"),this.request(r)},s.podcastEpisodeDelete=function(t){var r="podcast_episode_delete";return r+=e.stringify(t,"&"),this.request(r)},s.updatePodcast=function(t){var r="update_podcast";return r+=e.stringify(t,"&"),this.request(r)},s.deletedPodcastEpisodes=function(t){try{var r="deleted_podcast_episodes";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.deleted_podcast_episode?e.deleted_podcast_episode:e})}catch(e){return Promise.reject(e)}},r}(o),d=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.systemPreferences=function(){try{return Promise.resolve(this.request("system_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},s.systemPreference=function(t){try{var r="system_preference";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}},s.userPreferences=function(){try{return Promise.resolve(this.request("user_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},s.userPreference=function(t){try{var r="user_preference";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}},s.preferenceCreate=function(t){var r="preference_create";return r+=e.stringify(t,"&"),this.request(r)},s.preferenceEdit=function(t){var r="preference_edit";return r+=e.stringify(t,"&"),this.request(r)},s.preferenceDelete=function(t){var r="preference_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),q=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.shares=function(t){try{var r="shares";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.share?e.share:e})}catch(e){return Promise.reject(e)}},s.share=function(t){var r="share";return r+=e.stringify(t,"&"),this.request(r)},s.shareCreate=function(t){var r="share_create";return r+=e.stringify(t,"&"),this.request(r)},s.shareEdit=function(t){var r="share_edit";return r+=e.stringify(t,"&"),this.request(r)},s.shareDelete=function(t){var r="share_delete";return r+=e.stringify(t,"&"),this.request(r)},r}(o),P=function(t){function r(){return t.apply(this,arguments)||this}return n(r,t),r.prototype.last_shouts=function(t){try{var r="last_shouts";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.shout?e.shout:e})}catch(e){return Promise.reject(e)}},r}(o),_=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.songs=function(t){try{var r="songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.song=function(t){var r="song";return r+=e.stringify(t,"&"),this.request(r)},s.artistSongs=function(t){try{var r="artist_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.albumSongs=function(t){try{var r="album_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.genreSongs=function(t){try{var r="genre_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.playlistSongs=function(t){try{var r="playlist_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.licenseSongs=function(t){try{var r="license_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.songDelete=function(t){var r="song_delete";return r+=e.stringify(t,"&"),this.request(r)},s.urlToSong=function(t){var r="url_to_song";return t.url=encodeURIComponent(t.url),r+=e.stringify(t,"&"),this.request(r)},s.searchSongs=function(t){try{var r="search_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},s.deletedSongs=function(t){try{var r="deleted_songs";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.deleted_song?e.deleted_song:e})}catch(e){return Promise.reject(e)}},r}(o),b=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.systemUpdate=function(){return this.request("system_update")},s.getIndexes=function(t){try{var r,n=this,s="get_indexes";switch(s+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(n.request(s)).then(function(e){return(r=e).song?r.song:r});case"album":return Promise.resolve(n.request(s)).then(function(e){return(r=e).album?r.album:r});case"artist":case"album_artist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).artist?r.artist:r});case"playlist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).playlist?r.playlist:r});case"podcast":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast?r.podcast:r});case"podcast_episode":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast_episode?r.podcast_episode:r});case"live_stream":return Promise.resolve(n.request(s)).then(function(e){return(r=e).live_stream?r.live_stream:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},s.list=function(t){try{var r="list";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r))}catch(e){return Promise.reject(e)}},s.browse=function(t){try{var r="browse";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r))}catch(e){return Promise.reject(e)}},s.getSimilar=function(t){try{var r,n="get_similar";switch(n+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(this.request(n)).then(function(e){return(r=e).song?r.song:r});case"artist":return Promise.resolve(this.request(n)).then(function(e){return(r=e).artist?r.artist:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},s.stats=function(t){try{var r,n=this,s="stats";switch(s+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(n.request(s)).then(function(e){return(r=e).song?r.song:r});case"album":return Promise.resolve(n.request(s)).then(function(e){return(r=e).album?r.album:r});case"artist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).artist?r.artist:r});case"video":return Promise.resolve(n.request(s)).then(function(e){return(r=e).video?r.video:r});case"playlist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).playlist?r.playlist:r});case"podcast":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast?r.podcast:r});case"podcast_episode":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast_episode?r.podcast_episode:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},s.rate=function(t){var r="rate";return r+=e.stringify(t,"&"),this.request(r)},s.flag=function(t){var r="flag";return r+=e.stringify(t,"&"),this.request(r)},s.recordPlay=function(t){var r="record_play";return r+=e.stringify(t,"&"),this.request(r)},s.scrobble=function(t){var r="scrobble";return r+=e.stringify(t,"&"),this.request(r)},s.updateFromTags=function(t){var r="update_from_tags";return r+=e.stringify(t,"&"),this.request(r)},s.updateArtistInfo=function(t){var r="update_artist_info";return r+=e.stringify(t,"&"),this.request(r)},s.updateArt=function(t){var r="update_art";return r+=e.stringify(t,"&"),this.request(r)},s.stream=function(t){var r="stream";return r+=e.stringify(t,"&"),this.request(r)},s.download=function(t){var r="download";return r+=e.stringify(t,"&"),this.binary(r)},s.getArt=function(t){var r="get_art";return r+=e.stringify(t,"&"),this.request(r)},s.localplay=function(t){var r="localplay";return r+=e.stringify(t,"&"),this.request(r)},s.localplaySongs=function(){return this.request("localplay_songs")},s.democratic=function(t){var r="democratic";return r+=e.stringify(t,"&"),this.request(r)},s.advancedSearch=function(t){try{for(var r,n=this,s="advanced_search",i=0;i<t.rules.length;i++){var o=t.rules[i],u=i+1;t["rule_"+u]=o[0],t["rule_"+u+"_operator"]=o[1],t["rule_"+u+"_input"]=o[2],"metadata"===o[0]&&(t["rule_"+u+"_subtype"]=o[3])}switch(delete t.rules,s+=e.stringify(t,"&"),t.type){case"song":return Promise.resolve(n.request(s)).then(function(e){return(r=e).song?r.song:r});case"album":return Promise.resolve(n.request(s)).then(function(e){return(r=e).album?r.album:r});case"artist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).artist?r.artist:r});case"label":return Promise.resolve(n.request(s)).then(function(e){return(r=e).label?r.label:r});case"playlist":return Promise.resolve(n.request(s)).then(function(e){return(r=e).playlist?r.playlist:r});case"podcast":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast?r.podcast:r});case"podcast_episode":return Promise.resolve(n.request(s)).then(function(e){return(r=e).podcast_episode?r.podcast_episode:r});case"genre":return Promise.resolve(n.request(s)).then(function(e){return(r=e).genre?r.genre:r});case"user":return Promise.resolve(n.request(s)).then(function(e){return(r=e).user?r.user:r});case"video":return Promise.resolve(n.request(s)).then(function(e){return(r=e).video?r.video:r});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},r}(o),j=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.users=function(){try{return Promise.resolve(this.request("users")).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},s.user=function(t){try{var r="user";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r))}catch(e){return Promise.reject(e)}},s.userCreate=function(t){var r="user_create";return r+=e.stringify(t,"&"),this.request(r)},s.register=function(t){var r="register";return r+=e.stringify(t,"&"),this.request(r)},s.userUpdate=function(t){var r="user_update";return r+=e.stringify(t,"&"),this.request(r)},s.userEdit=function(t){var r="user_edit";return r+=e.stringify(t,"&"),this.request(r)},s.userDelete=function(t){var r="user_delete";return r+=e.stringify(t,"&"),this.request(r)},s.followers=function(t){try{var r="followers";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},s.following=function(t){try{var r="following";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},s.toggleFollow=function(t){var r="toggle_follow";return r+=e.stringify(t,"&"),this.request(r)},s.timeline=function(t){try{var r="timeline";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},s.friendsTimeline=function(t){try{var r="friends_timeline";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},r}(o),k=function(t){function r(){return t.apply(this,arguments)||this}n(r,t);var s=r.prototype;return s.videos=function(t){try{var r="videos";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.video?e.video:e})}catch(e){return Promise.reject(e)}},s.video=function(t){var r="video";return r+=e.stringify(t,"&"),this.request(r)},s.deletedVideos=function(t){try{var r="deleted_videos";return r+=e.stringify(t,"&"),Promise.resolve(this.request(r)).then(function(e){return e.deleted_video?e.deleted_video:e})}catch(e){return Promise.reject(e)}},r}(o),w=function(e){function t(){return e.apply(this,arguments)||this}return n(t,e),t}(o);i=w,[u,a,c,f,l,h,y,v,p,g,m,d,q,P,_,b,j,k].forEach(function(e){Object.getOwnPropertyNames(e.prototype).forEach(function(t){Object.defineProperty(i.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t))})});export{w as default};
2
2
  //# sourceMappingURL=index.m.js.map