2020-01-04 18:53:27 +01:00
|
|
|
<template>
|
2022-02-19 06:18:01 +01:00
|
|
|
<div class="fd-page-with-tabs">
|
2022-02-19 06:39:14 +01:00
|
|
|
<tabs-settings />
|
2020-01-04 18:53:27 +01:00
|
|
|
|
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="title is-4">Spotify</div>
|
|
|
|
</template>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #content>
|
|
|
|
<div v-if="!spotify.spotify_installed" class="notification is-size-7">
|
|
|
|
<p>
|
|
|
|
OwnTone was either built without support for Spotify or libspotify
|
|
|
|
is not installed.
|
|
|
|
</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
2021-07-04 14:43:54 +02:00
|
|
|
<div v-if="spotify.spotify_installed">
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="notification is-size-7">
|
2022-02-19 06:39:14 +01:00
|
|
|
<b>You must have a Spotify premium account</b>.
|
|
|
|
<span v-if="use_libspotity"
|
|
|
|
>If you normally log into Spotify with your Facebook account you
|
|
|
|
must first go to Spotify's web site where you can get the Spotify
|
|
|
|
username and password that matches your account.</span
|
|
|
|
>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
|
2021-07-04 14:43:54 +02:00
|
|
|
<div v-if="use_libspotity">
|
2020-01-04 18:53:27 +01:00
|
|
|
<p class="content">
|
|
|
|
<b>libspotify</b> - Login with your Spotify username and password
|
|
|
|
</p>
|
|
|
|
<p v-if="spotify.libspotify_logged_in" class="fd-has-margin-bottom">
|
2022-02-19 06:39:14 +01:00
|
|
|
Logged in as
|
|
|
|
<b
|
|
|
|
><code>{{ spotify.libspotify_user }}</code></b
|
|
|
|
>
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<form
|
|
|
|
v-if="spotify.spotify_installed && !spotify.libspotify_logged_in"
|
|
|
|
@submit.prevent="login_libspotify"
|
|
|
|
>
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control is-expanded">
|
2022-02-19 06:39:14 +01:00
|
|
|
<input
|
|
|
|
v-model="libspotify.user"
|
|
|
|
class="input"
|
|
|
|
type="text"
|
|
|
|
placeholder="Username"
|
|
|
|
/>
|
|
|
|
<p class="help is-danger">
|
|
|
|
{{ libspotify.errors.user }}
|
|
|
|
</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control is-expanded">
|
2022-02-19 06:39:14 +01:00
|
|
|
<input
|
|
|
|
v-model="libspotify.password"
|
|
|
|
class="input"
|
|
|
|
type="password"
|
|
|
|
placeholder="Password"
|
|
|
|
/>
|
|
|
|
<p class="help is-danger">
|
|
|
|
{{ libspotify.errors.password }}
|
|
|
|
</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<button class="button is-info">Login</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2022-02-19 06:39:14 +01:00
|
|
|
<p class="help is-danger">
|
|
|
|
{{ libspotify.errors.error }}
|
|
|
|
</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
<p class="help">
|
2021-05-13 16:03:10 +02:00
|
|
|
libspotify enables OwnTone to play Spotify tracks.
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
|
|
|
<p class="help">
|
2022-02-19 06:39:14 +01:00
|
|
|
OwnTone will not store your password, but will still be able to
|
|
|
|
log you in automatically afterwards, because libspotify saves a
|
|
|
|
login token.
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="fd-has-margin-top">
|
|
|
|
<p class="content">
|
|
|
|
<b>Spotify Web API</b> - Grant access to the Spotify Web API
|
|
|
|
</p>
|
|
|
|
<p v-if="spotify.webapi_token_valid">
|
2022-02-19 06:39:14 +01:00
|
|
|
Access granted for
|
|
|
|
<b
|
|
|
|
><code>{{ spotify.webapi_user }}</code></b
|
|
|
|
>
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<p v-if="spotify_missing_scope.length > 0" class="help is-danger">
|
|
|
|
Please reauthorize Web API access to grant OwnTone the following
|
|
|
|
additional access rights:
|
|
|
|
<b
|
|
|
|
><code>{{ spotify_missing_scope.join() }}</code></b
|
|
|
|
>
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<div class="field fd-has-margin-top">
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="control">
|
2022-02-19 06:39:14 +01:00
|
|
|
<a
|
|
|
|
class="button"
|
|
|
|
:class="{
|
|
|
|
'is-info':
|
|
|
|
!spotify.webapi_token_valid ||
|
|
|
|
spotify_missing_scope.length > 0
|
|
|
|
}"
|
|
|
|
:href="spotify.oauth_uri"
|
|
|
|
>Authorize Web API access</a
|
|
|
|
>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<p class="help">
|
2022-02-19 06:39:14 +01:00
|
|
|
Access to the Spotify Web API enables scanning of your Spotify
|
|
|
|
library. Required scopes are
|
|
|
|
<code>{{ spotify_required_scope.join() }}</code
|
|
|
|
>.
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<div
|
|
|
|
v-if="spotify.webapi_token_valid"
|
|
|
|
class="field fd-has-margin-top"
|
|
|
|
>
|
2021-12-26 20:19:51 +01:00
|
|
|
<div class="control">
|
|
|
|
<a class="button is-danger" @click="logout_spotify">Logout</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
|
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="title is-4">Last.fm</div>
|
|
|
|
</template>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #content>
|
|
|
|
<div v-if="!lastfm.enabled" class="notification is-size-7">
|
2021-05-13 16:03:10 +02:00
|
|
|
<p>OwnTone was built without support for Last.fm.</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div v-if="lastfm.enabled">
|
|
|
|
<p class="content">
|
2022-02-19 06:39:14 +01:00
|
|
|
<b>Last.fm</b> - Login with your Last.fm username and password to
|
|
|
|
enable scrobbling
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
|
|
|
<div v-if="lastfm.scrobbling_enabled">
|
|
|
|
<a class="button" @click="logoutLastfm">Stop scrobbling</a>
|
|
|
|
</div>
|
|
|
|
<div v-if="!lastfm.scrobbling_enabled">
|
|
|
|
<form @submit.prevent="login_lastfm">
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control is-expanded">
|
2022-02-19 06:39:14 +01:00
|
|
|
<input
|
|
|
|
v-model="lastfm_login.user"
|
|
|
|
class="input"
|
|
|
|
type="text"
|
|
|
|
placeholder="Username"
|
|
|
|
/>
|
|
|
|
<p class="help is-danger">
|
|
|
|
{{ lastfm_login.errors.user }}
|
|
|
|
</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control is-expanded">
|
2022-02-19 06:39:14 +01:00
|
|
|
<input
|
|
|
|
v-model="lastfm_login.password"
|
|
|
|
class="input"
|
|
|
|
type="password"
|
|
|
|
placeholder="Password"
|
|
|
|
/>
|
|
|
|
<p class="help is-danger">
|
|
|
|
{{ lastfm_login.errors.password }}
|
|
|
|
</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<button class="button is-info" type="submit">Login</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-02-19 06:39:14 +01:00
|
|
|
<p class="help is-danger">
|
|
|
|
{{ lastfm_login.errors.error }}
|
|
|
|
</p>
|
2020-01-04 18:53:27 +01:00
|
|
|
<p class="help">
|
2022-02-19 06:39:14 +01:00
|
|
|
OwnTone will not store your Last.fm username/password, only the
|
|
|
|
session key. The session key does not expire.
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 06:18:01 +01:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
|
|
|
import TabsSettings from '@/components/TabsSettings.vue'
|
2020-01-04 18:53:27 +01:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'SettingsPageOnlineServices',
|
|
|
|
components: { ContentWithHeading, TabsSettings },
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
filters: {
|
|
|
|
join(array) {
|
|
|
|
return array.join(', ')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
2020-01-04 18:53:27 +01:00
|
|
|
return {
|
2022-02-19 06:39:14 +01:00
|
|
|
libspotify: {
|
|
|
|
user: '',
|
|
|
|
password: '',
|
|
|
|
errors: { user: '', password: '', error: '' }
|
|
|
|
},
|
|
|
|
lastfm_login: {
|
|
|
|
user: '',
|
|
|
|
password: '',
|
|
|
|
errors: { user: '', password: '', error: '' }
|
|
|
|
}
|
2020-01-04 18:53:27 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2022-02-19 06:39:14 +01:00
|
|
|
lastfm() {
|
2020-01-04 18:53:27 +01:00
|
|
|
return this.$store.state.lastfm
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify() {
|
2020-01-04 18:53:27 +01:00
|
|
|
return this.$store.state.spotify
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify_required_scope() {
|
2021-12-26 20:19:51 +01:00
|
|
|
if (this.spotify.webapi_required_scope) {
|
2020-01-04 18:53:27 +01:00
|
|
|
return this.spotify.webapi_required_scope.split(' ')
|
|
|
|
}
|
|
|
|
return []
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify_missing_scope() {
|
|
|
|
if (
|
|
|
|
this.spotify.webapi_token_valid &&
|
|
|
|
this.spotify.webapi_granted_scope &&
|
|
|
|
this.spotify.webapi_required_scope
|
|
|
|
) {
|
|
|
|
return this.spotify.webapi_required_scope
|
|
|
|
.split(' ')
|
|
|
|
.filter(
|
|
|
|
(scope) => this.spotify.webapi_granted_scope.indexOf(scope) < 0
|
|
|
|
)
|
2020-01-04 18:53:27 +01:00
|
|
|
}
|
|
|
|
return []
|
2021-07-04 14:43:54 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
use_libspotify() {
|
2021-07-04 14:43:54 +02:00
|
|
|
return this.$store.state.config.use_libspotify
|
2020-01-04 18:53:27 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2022-02-19 06:39:14 +01:00
|
|
|
login_libspotify() {
|
|
|
|
webapi.spotify_login(this.libspotify).then((response) => {
|
2020-01-04 18:53:27 +01:00
|
|
|
this.libspotify.user = ''
|
|
|
|
this.libspotify.password = ''
|
|
|
|
this.libspotify.errors.user = ''
|
|
|
|
this.libspotify.errors.password = ''
|
|
|
|
this.libspotify.errors.error = ''
|
|
|
|
|
|
|
|
if (!response.data.success) {
|
|
|
|
this.libspotify.errors.user = response.data.errors.user
|
|
|
|
this.libspotify.errors.password = response.data.errors.password
|
|
|
|
this.libspotify.errors.error = response.data.errors.error
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
logout_spotify() {
|
2021-12-26 20:19:51 +01:00
|
|
|
webapi.spotify_logout()
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
login_lastfm() {
|
|
|
|
webapi.lastfm_login(this.lastfm_login).then((response) => {
|
2020-01-04 18:53:27 +01:00
|
|
|
this.lastfm_login.user = ''
|
|
|
|
this.lastfm_login.password = ''
|
|
|
|
this.lastfm_login.errors.user = ''
|
|
|
|
this.lastfm_login.errors.password = ''
|
|
|
|
this.lastfm_login.errors.error = ''
|
|
|
|
|
|
|
|
if (!response.data.success) {
|
|
|
|
this.lastfm_login.errors.user = response.data.errors.user
|
|
|
|
this.lastfm_login.errors.password = response.data.errors.password
|
|
|
|
this.lastfm_login.errors.error = response.data.errors.error
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
logoutLastfm() {
|
2020-01-04 18:53:27 +01:00
|
|
|
webapi.lastfm_logout()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<style></style>
|