[web] Use OwnTone information when opening a Spotify album or artist from the music page

This commit is contained in:
Alain Nussbaumer 2025-02-25 13:21:51 +01:00
parent 51b76d0b73
commit 069c00ce30

View File

@ -9,8 +9,6 @@
<script> <script>
import ModalDialogPlayable from '@/components/ModalDialogPlayable.vue' import ModalDialogPlayable from '@/components/ModalDialogPlayable.vue'
import SpotifyWebApi from 'spotify-web-api-js'
import { useServicesStore } from '@/stores/services'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
@ -18,14 +16,6 @@ export default {
components: { ModalDialogPlayable }, components: { ModalDialogPlayable },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close', 'play-count-changed'], emits: ['close', 'play-count-changed'],
setup() {
return { servicesStore: useServicesStore() }
},
data() {
return {
spotify_track: {}
}
},
computed: { computed: {
buttons() { buttons() {
if (this.item.media_kind !== 'podcast') { if (this.item.media_kind !== 'podcast') {
@ -71,7 +61,7 @@ export default {
}, },
{ {
label: 'property.quality', label: 'property.quality',
value: this.$t('dialog.track.quality-value', { value: this.item.data_kind !== 'spotify' && this.$t('dialog.track.quality-value', {
format: this.item.type, format: this.item.type,
bitrate: this.item.bitrate, bitrate: this.item.bitrate,
channels: this.$t('count.channels', this.item.channels), channels: this.$t('count.channels', this.item.channels),
@ -94,25 +84,6 @@ export default {
} }
} }
}, },
watch: {
item() {
if (
this.item &&
this.item.data_kind === 'spotify' &&
this.item.media_kind !== 'podcast'
) {
const spotifyApi = new SpotifyWebApi()
spotifyApi.setAccessToken(this.servicesStore.spotify.webapi_token)
spotifyApi
.getTrack(this.item.path.slice(this.item.path.lastIndexOf(':') + 1))
.then((response) => {
this.spotify_track = response
})
} else {
this.spotify_track = {}
}
}
},
methods: { methods: {
mark_new() { mark_new() {
webapi webapi
@ -132,15 +103,7 @@ export default {
}, },
open_album() { open_album() {
this.$emit('close') this.$emit('close')
if ( if (this.item.media_kind === 'podcast') {
this.item.data_kind === 'spotify' &&
this.item.media_kind !== 'podcast'
) {
this.$router.push({
name: 'music-spotify-album',
params: { id: this.spotify_track.album.id }
})
} else if (this.item.media_kind === 'podcast') {
this.$router.push({ this.$router.push({
name: 'podcast', name: 'podcast',
params: { id: this.item.album_id } params: { id: this.item.album_id }
@ -159,12 +122,7 @@ export default {
}, },
open_artist() { open_artist() {
this.$emit('close') this.$emit('close')
if (this.item.data_kind === 'spotify') { if (
this.$router.push({
name: 'music-spotify-artist',
params: { id: this.spotify_track.artists[0].id }
})
} else if (
this.item.media_kind === 'music' || this.item.media_kind === 'music' ||
this.item.media_kind === 'podcast' this.item.media_kind === 'podcast'
) { ) {