LastFM for supporting imagery; Album wiki from LastFM; fixes #369

This commit is contained in:
James Barnsley
2019-02-20 21:08:48 +13:00
parent 602c9d1fa1
commit 4d62e33109
13 changed files with 4182 additions and 3406 deletions

View File

@ -272,20 +272,24 @@ export function getAlbum(uri, artist, album, mbid = false){
.then(
response => {
if (response.album){
var existing_album = getState().core.albums[uri];
var album = {
uri: uri,
images: response.album.image,
listeners: response.album.listeners,
play_count: response.album.playcount,
mbid: response.album.mbid
mbid: response.album.mbid,
wiki: (response.album.wiki ? response.album.wiki.content : null),
wiki_publish_date: (response.album.wiki ? response.album.wiki.published : null),
};
if (response.album.wiki){
album.wiki = response.album.wiki.content;
if (response.album.wiki.published){
album.wiki_publish_date = response.album.wiki.published;
}
// If we've already got some of this album and it has images aready, don't use our ones.
// In *most* cases this existing image will be perfectly suffice. This prevents an ugly
// flicker when the existing image is replaced by the LastFM one
if (existing_album && existing_album.images){
delete album.images;
}
dispatch(coreActions.albumLoaded(album));

View File

@ -1906,9 +1906,6 @@ const MopidyMiddleware = (function(){
var album = Object.assign(
{},
{
images: []
},
response[0].album,
{
source: 'local',
@ -1921,13 +1918,13 @@ const MopidyMiddleware = (function(){
store.dispatch(coreActions.albumLoaded(album));
store.dispatch(coreActions.artistsLoaded(artists));
// load artwork from LastFM
if (album.images.length <= 0){
// load artwork from LastFM
if (!response[0].album.images){
var mbid = helpers.getFromUri('mbid',album.uri);
if (mbid){
store.dispatch(lastfmActions.getAlbum(false, false, mbid));
} else {
store.dispatch(lastfmActions.getAlbum(album.artists[0].name, album.name));
store.dispatch(lastfmActions.getAlbum(album.uri, false, false, mbid));
} else if (artists && artists.length > 0){
store.dispatch(lastfmActions.getAlbum(album.uri, artists[0].name, album.name));
}
}