add download button. fixes #23

This commit is contained in:
Thomas Amland 2021-03-14 13:47:42 +01:00
parent 4e71857e2a
commit 325f642d72
2 changed files with 17 additions and 0 deletions

View File

@ -12,6 +12,9 @@
<b-dropdown-item-button @click="toggleStarred()"> <b-dropdown-item-button @click="toggleStarred()">
{{ starred ? 'Unstar' : 'Star' }} {{ starred ? 'Unstar' : 'Star' }}
</b-dropdown-item-button> </b-dropdown-item-button>
<b-dropdown-item-button @click="download()">
Download
</b-dropdown-item-button>
<slot :item="track" /> <slot :item="track" />
</b-dropdown> </b-dropdown>
</template> </template>
@ -35,6 +38,9 @@
} }
return this.$api.star('track', this.track.id) return this.$api.star('track', this.track.id)
}, },
download() {
window.location.href = this.$api.getDownloadUrl(this.track.id)
},
setNextInQueue() { setNextInQueue() {
return this.$store.dispatch('player/setNextInQueue', [this.track]) return this.$store.dispatch('player/setNextInQueue', [this.track])
}, },

View File

@ -428,6 +428,17 @@ export class API {
} }
} }
getDownloadUrl(id: any) {
const { server, username, salt, hash } = this.auth
return `${server}/rest/download` +
`?id=${id}` +
'&v=1.15.0' +
`&u=${username}` +
`&s=${salt}` +
`&t=${hash}` +
`&c=${this.clientName}`
}
private getCoverArtUrl(item: any) { private getCoverArtUrl(item: any) {
if (!item.coverArt) { if (!item.coverArt) {
return undefined return undefined