More robust fetching of artist / label info

This commit is contained in:
patrickkfkan 2021-01-21 21:31:40 +08:00
parent aeed0098c0
commit e3260ece1c
2 changed files with 18 additions and 11 deletions

View File

@ -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) );
}

View File

@ -328,8 +328,9 @@ function parseArtistOrLabelInfo(html, opts) {
const $ = cheerio.load(html);
let bioText = $('#bio-text');
let bioTextMore = bioText.find('.peekaboo-text');
let description;
if (bioText.length) {
let bioTextMore = bioText.find('.peekaboo-text');
if (bioTextMore.length) {
bioTextMore.find('.lightweightBreak').remove();
bioText.find('.peekaboo-text, .peekaboo-link').remove();
@ -342,6 +343,10 @@ function parseArtistOrLabelInfo(html, opts) {
description = utils.brToNewLine(description);
description = utils.stripTags(description);
description = decode(description);
}
else {
description = '';
}
let isLabel = $('a[href="/artists"]').length;
let label = null;