playlist utils added
This commit is contained in:
parent
7d9424e244
commit
17e24d4e4f
2 changed files with 28 additions and 4 deletions
|
@ -396,9 +396,7 @@ const app = new Vue({
|
||||||
ipcRenderer.invoke('setStoreValue', 'volume', this.mk.volume)
|
ipcRenderer.invoke('setStoreValue', 'volume', this.mk.volume)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.apiCall('https://api.music.apple.com/v1/me/library/playlist-folders/p.playlistsroot/children/', res => {
|
this.refreshPlaylists()
|
||||||
self.playlists.listing = res.data
|
|
||||||
})
|
|
||||||
document.body.removeAttribute("loading")
|
document.body.removeAttribute("loading")
|
||||||
if (window.location.hash != "") {
|
if (window.location.hash != "") {
|
||||||
this.appRoute(window.location.hash)
|
this.appRoute(window.location.hash)
|
||||||
|
@ -449,6 +447,32 @@ const app = new Vue({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async refreshPlaylists() {
|
||||||
|
let self = this
|
||||||
|
this.apiCall('https://api.music.apple.com/v1/me/library/playlist-folders/p.playlistsroot/children/', res => {
|
||||||
|
self.playlists.listing = res.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async editPlaylist(id, name = "New Playlist") {
|
||||||
|
await app.mk.api.library.editPlaylist(id, {name: name}).then(res => {
|
||||||
|
self.refreshPlaylists()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async newPlaylist(name = "New Playlist", tracks = []) {
|
||||||
|
let self = this
|
||||||
|
await app.mk.api.library.createPlaylist({name: name, tracks: tracks}).then(res => {
|
||||||
|
self.refreshPlaylists()
|
||||||
|
appRoute(`playlist_` + res.id);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async deletePlaylist(id) {
|
||||||
|
let self = this
|
||||||
|
if(confirm(`Are you sure you want to delete "${this.playlists.listing[id].attributes.name}"?`)) {
|
||||||
|
await app.mk.api.library.deletePlaylist(id).then(res=>{
|
||||||
|
self.refreshPlaylists()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
async showCollection(response, title, type) {
|
async showCollection(response, title, type) {
|
||||||
let self = this
|
let self = this
|
||||||
this.collectionList.response = response
|
this.collectionList.response = response
|
||||||
|
@ -1928,7 +1952,7 @@ const app = new Vue({
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
apiCall(url, callback) {
|
async apiCall(url, callback) {
|
||||||
const xmlHttp = new XMLHttpRequest();
|
const xmlHttp = new XMLHttpRequest();
|
||||||
|
|
||||||
xmlHttp.onreadystatechange = (e) => {
|
xmlHttp.onreadystatechange = (e) => {
|
||||||
|
|
0
src/renderer/views/components/playlists.ejs
Normal file
0
src/renderer/views/components/playlists.ejs
Normal file
Loading…
Add table
Add a link
Reference in a new issue