add "add/remove to library" in playlist view
This commit is contained in:
parent
f9e19fa6b2
commit
2e05c0ef9f
2 changed files with 37 additions and 10 deletions
|
@ -155,13 +155,13 @@ const CiderBase = {
|
|||
|
||||
win.webContents.session.webRequest.onBeforeSendHeaders(async (details, callback) => {
|
||||
if(details.url == "https://buy.itunes.apple.com/account/web/info"){
|
||||
details.requestHeaders['sec-fetch-site'] = 'same-site';
|
||||
details.requestHeaders['DNT'] = '1';
|
||||
let itspod = await win.webContents.executeJavaScript(`window.localStorage.getItem("music.ampwebplay.itspod")`)
|
||||
if (itspod != null)
|
||||
details.requestHeaders['Cookie'] = `itspod=${itspod}`
|
||||
}
|
||||
callback({ requestHeaders: details.requestHeaders })
|
||||
details.requestHeaders['sec-fetch-site'] = 'same-site';
|
||||
details.requestHeaders['DNT'] = '1';
|
||||
let itspod = await win.webContents.executeJavaScript(`window.localStorage.getItem("music.ampwebplay.itspod")`)
|
||||
if (itspod != null)
|
||||
details.requestHeaders['Cookie'] = `itspod=${itspod}`
|
||||
}
|
||||
callback({ requestHeaders: details.requestHeaders })
|
||||
})
|
||||
|
||||
let location = "http://localhost:9000/"
|
||||
|
|
|
@ -55,6 +55,10 @@
|
|||
@click="app.mk.shuffleMode = 1;app.playMediaItemById(data.attributes.playParams.id ?? data.id, data.attributes.playParams.kind ?? data.type, data.attributes.playParams.isLibrary ?? false, data.attributes.url)">
|
||||
Shuffle
|
||||
</button>
|
||||
<button class="wr-btn" style="min-width: 120px;"
|
||||
@click="(!inLibrary) ? addToLibrary(data.attributes.playParams.id.toString()) : removeFromLibrary(data.attributes.playParams.id.toString())">
|
||||
{{ (!inLibrary) ? "Add to Library" : "Remove from Library" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -89,17 +93,40 @@
|
|||
return {
|
||||
editorialNotesExpanded: false,
|
||||
drag: false,
|
||||
nameEditing: false
|
||||
nameEditing: false,
|
||||
inLibrary: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
mounted: function () {
|
||||
this.isInLibrary()
|
||||
},
|
||||
watch:{
|
||||
data : function() {
|
||||
this.isInLibrary()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async isInLibrary () {
|
||||
if (this.data.type && !this.data.type.includes('library')){
|
||||
// please keep using vars here
|
||||
var params = {"fields[albums]": "inLibrary","relate" : "library"}
|
||||
var res = await app.mkapi(this.data.attributes.playParams.kind ?? this.data.type, false , this.data.attributes.playParams.id ?? this.data.id, params);
|
||||
this.inLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false} else {this.inLibrary = true}
|
||||
},
|
||||
editPlaylist() {
|
||||
app.editPlaylist(this.data.id, this.data.attributes.name);
|
||||
this.nameEditing = false
|
||||
},
|
||||
addToLibrary(id) {
|
||||
app.mk.addToLibrary(id)
|
||||
this.inLibrary = true
|
||||
},
|
||||
removeFromLibrary(id) {
|
||||
let kind = this.data.attributes.playParams.kind ?? this.data.type ?? '';
|
||||
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
app.mk.api.library.remove({[truekind]: this.data.id ?? this.data.attributes.playParams.id })
|
||||
this.inLibrary = false
|
||||
},
|
||||
editPlaylistName() {
|
||||
if(this.data.attributes.canEdit && this.data.type == "library-playlists") {
|
||||
this.nameEditing = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue