feat: apple music -> last.fm
This commit is contained in:
parent
fc59d929b4
commit
657e21e9cd
22 changed files with 88 additions and 1347 deletions
|
@ -1,3 +0,0 @@
|
|||
module.exports = {
|
||||
getKeyByValue: (object, value) => Object.keys(object).find((key) => object[key].includes(value)),
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
module.exports = {
|
||||
getReadableData: (readable) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks = []
|
||||
readable.once('error', (err) => reject(err))
|
||||
readable.on('data', (chunk) => chunks.push(chunk))
|
||||
readable.once('end', () => resolve(chunks.join('')))
|
||||
})
|
||||
},
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
const titleCaseExceptions = require('./../_data/json/title-case-exceptions.json')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Accepts a string that is then transformed to title case and returned.
|
||||
*
|
||||
* @name titleCase
|
||||
* @param {string} string
|
||||
* @returns {string}
|
||||
*/
|
||||
titleCase: (string) => {
|
||||
if (!string) return ''
|
||||
if (titleCaseExceptions.artists.includes(string)) return string
|
||||
return string
|
||||
.toLowerCase()
|
||||
.split(' ')
|
||||
.map((word, i) => {
|
||||
return titleCaseExceptions.words.includes(word) && i !== 0
|
||||
? word
|
||||
: word.charAt(0).toUpperCase().concat(word.substring(1))
|
||||
})
|
||||
.join(' ')
|
||||
},
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
const artistAliases = require('../_data/json/artist-aliases.json')
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Accepts a string representing an artist name, checks to see if said artist name
|
||||
* exists in an artist alias group of shape string[]. If so, replaces the provided
|
||||
* artist name with the canonical artist name.
|
||||
*
|
||||
* @name aliasArtist
|
||||
* @param {string} artist
|
||||
* @returns {string}
|
||||
*/
|
||||
aliasArtist: (artist) => {
|
||||
const aliased = artistAliases.aliases.find((alias) => alias.aliases.includes(artist))
|
||||
if (aliased) artist = aliased.artist
|
||||
return artist
|
||||
},
|
||||
|
||||
/**
|
||||
* Accepts a media name represented as a string (album or song name) and replaces
|
||||
* matches in the `denyList` with an empty string before returning the result.
|
||||
*
|
||||
* @name sanitizeMedia
|
||||
* @param {string} media
|
||||
* @returns {string}
|
||||
*/
|
||||
sanitizeMedia: (media) => {
|
||||
const denyList =
|
||||
/-\s*(?:single|ep)\s*|(\[|\()(Deluxe Edition|Special Edition|Remastered|Full Dynamic Range Edition|Anniversary Edition)(\]|\))/gi
|
||||
return media.replace(denyList, '').trim()
|
||||
},
|
||||
sortByPlays: (array) => Object.values(array).sort((a, b) => b.plays - a.plays),
|
||||
}
|
Reference in a new issue