Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion lib/htmlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
}
}

Expand Down
9 changes: 8 additions & 1 deletion schemas/artist-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"type": "string",
"format": "uri"
},
"bannerImage": {
"type": "string",
"format": "uri"
},
"description": {
"type": "string"
},
Expand All @@ -86,6 +90,9 @@
"items": {
"$ref": "#/definitions/bandLink"
}
},
"raw": {
"type": "object"
}
}
}
}