More robust fetching of artist / label info
This commit is contained in:
parent
aeed0098c0
commit
e3260ece1c
|
@ -122,7 +122,9 @@ async function getArtistOrLabelInfo(artistOrLabelUrl, options = {}) {
|
||||||
artistOrLabelUrl,
|
artistOrLabelUrl,
|
||||||
imageFormat: await _parseImageFormatArg(options.imageFormat)
|
imageFormat: await _parseImageFormatArg(options.imageFormat)
|
||||||
};
|
};
|
||||||
return fetch(artistOrLabelUrl)
|
// Some pages don't actually show the 'bio' column.
|
||||||
|
// The /music page does seem to always show it though, so parse from that.
|
||||||
|
return fetch(utils.getUrl('music', artistOrLabelUrl))
|
||||||
.then( res => res.text() )
|
.then( res => res.text() )
|
||||||
.then( html => parser.parseArtistOrLabelInfo(html, opts) );
|
.then( html => parser.parseArtistOrLabelInfo(html, opts) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,8 +328,9 @@ function parseArtistOrLabelInfo(html, opts) {
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
let bioText = $('#bio-text');
|
let bioText = $('#bio-text');
|
||||||
let bioTextMore = bioText.find('.peekaboo-text');
|
|
||||||
let description;
|
let description;
|
||||||
|
if (bioText.length) {
|
||||||
|
let bioTextMore = bioText.find('.peekaboo-text');
|
||||||
if (bioTextMore.length) {
|
if (bioTextMore.length) {
|
||||||
bioTextMore.find('.lightweightBreak').remove();
|
bioTextMore.find('.lightweightBreak').remove();
|
||||||
bioText.find('.peekaboo-text, .peekaboo-link').remove();
|
bioText.find('.peekaboo-text, .peekaboo-link').remove();
|
||||||
|
@ -342,6 +343,10 @@ function parseArtistOrLabelInfo(html, opts) {
|
||||||
description = utils.brToNewLine(description);
|
description = utils.brToNewLine(description);
|
||||||
description = utils.stripTags(description);
|
description = utils.stripTags(description);
|
||||||
description = decode(description);
|
description = decode(description);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
description = '';
|
||||||
|
}
|
||||||
|
|
||||||
let isLabel = $('a[href="/artists"]').length;
|
let isLabel = $('a[href="/artists"]').length;
|
||||||
let label = null;
|
let label = null;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user