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,
|
||||
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( html => parser.parseArtistOrLabelInfo(html, opts) );
|
||||
}
|
||||
|
|
|
@ -328,20 +328,25 @@ function parseArtistOrLabelInfo(html, opts) {
|
|||
const $ = cheerio.load(html);
|
||||
|
||||
let bioText = $('#bio-text');
|
||||
let bioTextMore = bioText.find('.peekaboo-text');
|
||||
let description;
|
||||
if (bioTextMore.length) {
|
||||
bioTextMore.find('.lightweightBreak').remove();
|
||||
bioText.find('.peekaboo-text, .peekaboo-link').remove();
|
||||
description = (bioText.html().trim() + ' ' + bioTextMore.html()).trim();
|
||||
if (bioText.length) {
|
||||
let bioTextMore = bioText.find('.peekaboo-text');
|
||||
if (bioTextMore.length) {
|
||||
bioTextMore.find('.lightweightBreak').remove();
|
||||
bioText.find('.peekaboo-text, .peekaboo-link').remove();
|
||||
description = (bioText.html().trim() + ' ' + bioTextMore.html()).trim();
|
||||
}
|
||||
else {
|
||||
description = bioText.html().trim();
|
||||
}
|
||||
description = utils.stripLineBreaks(description);
|
||||
description = utils.brToNewLine(description);
|
||||
description = utils.stripTags(description);
|
||||
description = decode(description);
|
||||
}
|
||||
else {
|
||||
description = bioText.html().trim();
|
||||
description = '';
|
||||
}
|
||||
description = utils.stripLineBreaks(description);
|
||||
description = utils.brToNewLine(description);
|
||||
description = utils.stripTags(description);
|
||||
description = decode(description);
|
||||
|
||||
let isLabel = $('a[href="/artists"]').length;
|
||||
let label = null;
|
||||
|
|
Loading…
Reference in New Issue
Block a user