diff --git a/lib/htmlParser.js b/lib/htmlParser.js index accc711..872b477 100644 --- a/lib/htmlParser.js +++ b/lib/htmlParser.js @@ -385,6 +385,10 @@ exports.parseArtistInfo = function (html, artistUrl) { selector: '.bio-pic a', attr: 'href' }, + bannerImage: { + selector: ".desktop-header a img", + attr: 'src' + }, description: 'p#bio-text', albums: { listItem: '.music-grid-item', @@ -453,14 +457,34 @@ exports.parseArtistInfo = function (html, artistUrl) { const albums = data.albums.map(mapAlbums) const mergedAlbums = [...new Set([...albums, ...data.discographyAlbums])] + // Parse raw. + const scriptWithRaw = $('script[data-tralbum]') + if (scriptWithRaw.length > 0) { + data.raw = scriptWithRaw.data('band') + } else { + let raw = this.extractJavascriptObjectVariable(html, 'BandData') + // The only javascript in the variable is the concatenation of the base url + // with the current album path. We nned to do it yourself. + // Ex: + // url: "http://musique.coeurdepirate.com" + "/album/blonde", + raw = raw ? raw.replace('" + "', '') : '' + try { + data.raw = JSON5.parse(raw) + } catch (error) { + console.error(error) + } + } + return { name: data.name, location: data.location, description: data.description, coverImage: data.coverImage, + bannerImage: data.bannerImage, albums: mergedAlbums, shows: data.shows, - bandLinks: data.bandLinks + bandLinks: data.bandLinks, + raw: data.raw } } diff --git a/schemas/artist-info.json b/schemas/artist-info.json index 7d365f6..8889a4a 100644 --- a/schemas/artist-info.json +++ b/schemas/artist-info.json @@ -66,6 +66,10 @@ "type": "string", "format": "uri" }, + "bannerImage": { + "type": "string", + "format": "uri" + }, "description": { "type": "string" }, @@ -86,6 +90,9 @@ "items": { "$ref": "#/definitions/bandLink" } + }, + "raw": { + "type": "object" } } -} \ No newline at end of file +}