Using Mopidy as gateway for non-spotify image requests, fixes #496
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user