From 325f642d72f3bc22900dec094edef93c0cfedee1 Mon Sep 17 00:00:00 2001 From: Thomas Amland Date: Sun, 14 Mar 2021 13:47:42 +0100 Subject: [PATCH] add download button. fixes #23 --- src/library/TrackContextMenu.vue | 6 ++++++ src/shared/api.ts | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/library/TrackContextMenu.vue b/src/library/TrackContextMenu.vue index b5ee790..4e2b8a4 100644 --- a/src/library/TrackContextMenu.vue +++ b/src/library/TrackContextMenu.vue @@ -12,6 +12,9 @@ {{ starred ? 'Unstar' : 'Star' }} + + Download + @@ -35,6 +38,9 @@ } return this.$api.star('track', this.track.id) }, + download() { + window.location.href = this.$api.getDownloadUrl(this.track.id) + }, setNextInQueue() { return this.$store.dispatch('player/setNextInQueue', [this.track]) }, diff --git a/src/shared/api.ts b/src/shared/api.ts index aca7a1b..5c308cd 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -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) { if (!item.coverArt) { return undefined