Using Mopidy as gateway for non-spotify image requests, fixes #496

This commit is contained in:
James Barnsley
2020-03-06 11:01:33 +13:00
parent 9f378288c0
commit 242b29e216
7 changed files with 27174 additions and 19166 deletions

View File

@ -1,5 +1,5 @@
import { formatImages } from '../../util/format';
import { formatImages, collate } from '../../util/format';
import { generateGuid } from '../../util/helpers';
const coreActions = require('../core/actions');
@ -302,10 +302,13 @@ export function getImages(context, uri) {
if (record.mbid) {
var params = `method=album.getInfo&mbid=${record.mbid}`;
} else if (record.artists && record.artists.length > 0 && record.album) {
var artist = encodeURIComponent(record.artists[0].name);
var album = encodeURIComponent(record.album.name);
var params = `method=album.getInfo&album=${album}&artist=${artist}`;
} else {
record = collate(record, { artists: getState().core.artists });
if (record.artists && record.artists.length > 0 && record.album) {
var artist = encodeURIComponent(record.artists[0].name);
var album = encodeURIComponent(record.album.name);
var params = `method=album.getInfo&album=${album}&artist=${artist}`;
}
}
if (params) {
@ -325,10 +328,13 @@ export function getImages(context, uri) {
if (record.mbid) {
var params = `method=album.getInfo&mbid=${record.mbid}`;
} else if (record.artists && record.artists.length > 0) {
var artist = encodeURIComponent(record.artists[0].name);
var album = encodeURIComponent(record.name);
var params = `method=album.getInfo&album=${album}&artist=${artist}`;
} else {
record = collate(record, { artists: getState().core.artists });
if (record.artists && record.artists.length > 0) {
var artist = encodeURIComponent(record.artists[0].name);
var album = encodeURIComponent(record.name);
var params = `method=album.getInfo&album=${album}&artist=${artist}`;
}
}
if (params) {
@ -343,6 +349,9 @@ export function getImages(context, uri) {
);
}
break;
default:
break;
}
}
};

View File

@ -2327,9 +2327,8 @@ const MopidyMiddleware = (function () {
for (const uri in response) {
if (response.hasOwnProperty(uri)) {
let images = response[uri];
images = formatImages(digestMopidyImages(store.getState().mopidy, images));
if (images) {
if (images.length) {
images = formatImages(digestMopidyImages(store.getState().mopidy, images));
records.push({
uri,
images,