mirror of
https://github.com/koel/koel
synced 2024-12-24 19:43:06 +00:00
cf27ed713d
Koel can now integrate and use the rich information from Last.fm. Now whenever a song is played, its album and artist information will be queried from Last.fm and cached for later use. What's better, if an album has no cover, Koel will try to update its cover if one is found on Last.fm. In order to use this feature, users only need to provide valid Last.fm API credentials (namely LASTFM_API_KEY and LASTFM_API_SECRET) in .env. A npm and gulp rebuild is also required - just like with every update.
124 lines
3.3 KiB
Vue
124 lines
3.3 KiB
Vue
<template>
|
|
<article v-if="song" id="albumInfo">
|
|
<h1>
|
|
<span>{{ song.album.name }}</span>
|
|
|
|
<a class="shuffle" @click.prevent="shuffleAll"><i class="fa fa-random"></i></a>
|
|
</h1>
|
|
|
|
<div v-if="song.album.info">
|
|
<img v-if="song.album.info.image" :src="song.album.info.image"
|
|
title=""
|
|
class="cover">
|
|
|
|
<div class="wiki" v-if="song.album.info.wiki && song.album.info.wiki.summary">
|
|
<div class="summary" v-show="!showingFullWiki">{{{ song.album.info.wiki.summary }}}</div>
|
|
<div class="full" v-show="showingFullWiki">{{{ song.album.info.wiki.full }}}</div>
|
|
|
|
<button class="more" v-show="!showingFullWiki" @click.prevent="showingFullWiki = !showingFullWiki">
|
|
Full Wiki
|
|
</button>
|
|
</div>
|
|
|
|
<section class="track-listing" v-if="song.album.info.tracks.length">
|
|
<h1>Track Listing</h1>
|
|
<ul class="tracks">
|
|
<li v-for="track in song.album.info.tracks">
|
|
<span class="no">{{ $index + 1 }}</span>
|
|
<span class="title">{{ track.title }}</span>
|
|
<span class="length">{{ track.fmtLength }}</span>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<footer>Data © <a target="_blank" href="{{{ song.album.info.url }}}">Last.fm</a></footer>
|
|
</div>
|
|
|
|
<p class="none" v-else>
|
|
No album information found. At all.
|
|
</p>
|
|
</article>
|
|
</template>
|
|
|
|
<script>
|
|
import playback from '../../../services/playback';
|
|
|
|
export default {
|
|
replace: false,
|
|
|
|
data() {
|
|
return {
|
|
song: null,
|
|
showingFullWiki: false,
|
|
};
|
|
},
|
|
|
|
methods: {
|
|
resetState() {
|
|
this.song = null;
|
|
this.showingFullWiki = false;
|
|
},
|
|
|
|
shuffleAll() {
|
|
playback.playAllInAlbum(this.song.album);
|
|
}
|
|
},
|
|
|
|
events: {
|
|
'song:info-loaded': function (song) {
|
|
this.song = song;
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="sass">
|
|
@import "resources/assets/sass/partials/_vars.scss";
|
|
@import "resources/assets/sass/partials/_mixins.scss";
|
|
|
|
#albumInfo {
|
|
img.cover {
|
|
width: 100%;
|
|
height: auto;
|
|
}
|
|
|
|
.wiki {
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.track-listing {
|
|
margin-top: 16px;
|
|
|
|
h1 {
|
|
font-size: 20px;
|
|
margin-bottom: 0;
|
|
display: block;
|
|
}
|
|
|
|
li {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 8px;
|
|
|
|
&:nth-child(even) {
|
|
background: rgba(255, 255, 255, 0.05);
|
|
}
|
|
|
|
.no {
|
|
flex: 0 0 24px;
|
|
opacity: .5;
|
|
}
|
|
|
|
.title {
|
|
flex: 1;
|
|
}
|
|
|
|
.length {
|
|
flex: 0 0 48px;
|
|
text-align: right;
|
|
opacity: .5;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|