chore: sanitize album titles

This commit is contained in:
Cory Dransfeldt 2023-07-07 14:15:59 -07:00
parent 489d674fb5
commit c9c1ebf958
No known key found for this signature in database

View file

@ -9,6 +9,14 @@ const aliasArtists = (array) => {
return array
}
const sanitizeAlbums = (array) => {
const denyList = /(\[|\()(Deluxe Edition|Special Edition|Remastered)(\]|\))/i;
array.forEach((a) => {
a.name = a.name.replace(denyList, '')
})
return array
}
const sort = (array) => Object.values(array).sort((a, b) => b.plays - a.plays)
module.exports = async function () {
@ -90,7 +98,7 @@ module.exports = async function () {
}
})
response.artists = aliasArtists(sort(response.artists)).splice(0, 8)
response.albums = aliasArtists(sort(response.albums)).splice(0, 8)
response.albums = sanitizeAlbums(aliasArtists(sort(response.albums)).splice(0, 8))
response.tracks = aliasArtists(sort(response.tracks)).splice(0, 5)
await asset.save(response, 'json')
return response