chore: tweak music + deps
This commit is contained in:
parent
348aefc71b
commit
83c309c940
2 changed files with 104 additions and 57 deletions
|
@ -7,9 +7,10 @@ const aliasArtist = (artist) => {
|
|||
return artist
|
||||
}
|
||||
|
||||
const sanitizeAlbum = (album) => {
|
||||
const denyList = /(\[|\()(Deluxe Edition|Special Edition|Remastered)(\]|\))/i
|
||||
return album.replace(denyList, '')
|
||||
const sanitizeMedia = (media) => {
|
||||
const denyList =
|
||||
/(\[|\()(Deluxe Edition|Special Edition|Remastered|Full Dynamic Range Edition)(\]|\))/i
|
||||
return media.replace(denyList, '').trim()
|
||||
}
|
||||
|
||||
const titleCase = (string) => {
|
||||
|
@ -62,7 +63,7 @@ module.exports = async function () {
|
|||
const asset = new AssetCache('recent_tracks_data')
|
||||
const PAGE_SIZE = 30
|
||||
const PAGES = 10
|
||||
const response = {
|
||||
const charts = {
|
||||
artists: {},
|
||||
albums: {},
|
||||
tracks: {},
|
||||
|
@ -91,44 +92,45 @@ module.exports = async function () {
|
|||
CURRENT_PAGE++
|
||||
}
|
||||
res.forEach((track) => {
|
||||
const artist = titleCase(aliasArtist(track.attributes['artistName']))
|
||||
const album = titleCase(sanitizeAlbum(track.attributes['albumName']))
|
||||
if (!response.artists[artist]) {
|
||||
response.artists[artist] = {
|
||||
artist,
|
||||
const formattedArtist = titleCase(aliasArtist(track.attributes['artistName']))
|
||||
const formattedAlbum = titleCase(sanitizeMedia(track.attributes['albumName']))
|
||||
const formattedTrack = sanitizeMedia(track.attributes['name'])
|
||||
if (!charts.artists[formattedArtist]) {
|
||||
charts.artists[formattedArtist] = {
|
||||
artist: formattedArtist,
|
||||
plays: 1,
|
||||
}
|
||||
} else {
|
||||
response.artists[artist].plays++
|
||||
charts.artists[formattedArtist].plays++
|
||||
}
|
||||
|
||||
if (!response.albums[album]) {
|
||||
response.albums[album] = {
|
||||
name: album,
|
||||
artist,
|
||||
if (!charts.albums[formattedAlbum]) {
|
||||
charts.albums[formattedAlbum] = {
|
||||
name: formattedAlbum,
|
||||
artist: formattedArtist,
|
||||
art: track.attributes.artwork.url.replace('{w}', '300').replace('{h}', '300'),
|
||||
url: track['relationships']
|
||||
? `https://song.link/${track['relationships'].albums.data.pop().attributes.url}`
|
||||
: `https://rateyourmusic.com/search?searchtype=l&searchterm=${album}%20${artist}`,
|
||||
: `https://rateyourmusic.com/search?searchtype=l&searchterm=${formattedAlbum}%20${formattedArtist}`,
|
||||
plays: 1,
|
||||
}
|
||||
} else {
|
||||
response.albums[album].plays++
|
||||
charts.albums[formattedAlbum].plays++
|
||||
}
|
||||
|
||||
if (!response.tracks[track.attributes.name]) {
|
||||
response.tracks[track.attributes.name] = {
|
||||
name: track.attributes.name,
|
||||
artist,
|
||||
if (!charts.tracks[formattedTrack]) {
|
||||
charts.tracks[formattedTrack] = {
|
||||
name: formattedTrack,
|
||||
artist: formattedArtist,
|
||||
plays: 1,
|
||||
}
|
||||
} else {
|
||||
response.tracks[track.attributes.name].plays++
|
||||
charts.tracks[formattedTrack].plays++
|
||||
}
|
||||
})
|
||||
response.artists = sort(response.artists).splice(0, 8)
|
||||
response.albums = sort(response.albums).splice(0, 8)
|
||||
response.tracks = sort(response.tracks).splice(0, 5)
|
||||
await asset.save(response, 'json')
|
||||
return response
|
||||
charts.artists = sort(charts.artists).splice(0, 8)
|
||||
charts.albums = sort(charts.albums).splice(0, 8)
|
||||
charts.tracks = sort(charts.tracks).splice(0, 5)
|
||||
await asset.save(charts, 'json')
|
||||
return charts
|
||||
}
|
||||
|
|
107
yarn.lock
107
yarn.lock
|
@ -1118,6 +1118,18 @@ array.prototype.flatmap@^1.3.1:
|
|||
es-abstract "^1.20.4"
|
||||
es-shim-unscopables "^1.0.0"
|
||||
|
||||
arraybuffer.prototype.slice@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.1.tgz#9b5ea3868a6eebc30273da577eb888381c0044bb"
|
||||
integrity sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw==
|
||||
dependencies:
|
||||
array-buffer-byte-length "^1.0.0"
|
||||
call-bind "^1.0.2"
|
||||
define-properties "^1.2.0"
|
||||
get-intrinsic "^1.2.1"
|
||||
is-array-buffer "^3.0.2"
|
||||
is-shared-array-buffer "^1.0.2"
|
||||
|
||||
arrify@^1.0.0, arrify@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
|
||||
|
@ -1484,9 +1496,9 @@ camelcase@^5.3.1:
|
|||
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
|
||||
|
||||
caniuse-lite@^1.0.30001464, caniuse-lite@^1.0.30001503:
|
||||
version "1.0.30001515"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001515.tgz#418aefeed9d024cd3129bfae0ccc782d4cb8f12b"
|
||||
integrity sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==
|
||||
version "1.0.30001516"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001516.tgz#621b1be7d85a8843ee7d210fd9d87b52e3daab3a"
|
||||
integrity sha512-Wmec9pCBY8CWbmI4HsjBeQLqDTqV91nFVR83DnZpYyRnPI1wePDsTg0bGLPC5VU/3OIZV1fmxEea1b+tFKe86g==
|
||||
|
||||
chalk@4.1.2, chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0:
|
||||
version "4.1.2"
|
||||
|
@ -2110,9 +2122,9 @@ destroy@~1.0.4:
|
|||
integrity sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==
|
||||
|
||||
detect-libc@^2.0.0, detect-libc@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd"
|
||||
integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.2.tgz#8ccf2ba9315350e1241b88d0ac3b0e1fbd99605d"
|
||||
integrity sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==
|
||||
|
||||
dev-ip@^1.0.1:
|
||||
version "1.0.1"
|
||||
|
@ -2328,9 +2340,9 @@ ejs@^3.1.8, ejs@^3.1.9:
|
|||
jake "^10.8.5"
|
||||
|
||||
electron-to-chromium@^1.4.431:
|
||||
version "1.4.461"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.461.tgz#6b14af66042732bf883ab63a4d82cac8f35eb252"
|
||||
integrity sha512-1JkvV2sgEGTDXjdsaQCeSwYYuhLRphRpc+g6EHTFELJXEiznLt3/0pZ9JuAOQ5p2rI3YxKTbivtvajirIfhrEQ==
|
||||
version "1.4.464"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.464.tgz#2f94bad78dff34e527aacbfc5d0b1a33cf046507"
|
||||
integrity sha512-guZ84yoou4+ILNdj0XEbmGs6DEWj6zpVOWYpY09GU66yEb0DSYvP/biBPzHn0GuW/3RC/pnaYNUWlQE1fJYtgA==
|
||||
|
||||
eleventy-plugin-tabler-icons@^1.0.8:
|
||||
version "1.0.8"
|
||||
|
@ -2459,11 +2471,12 @@ error-ex@^1.3.1:
|
|||
is-arrayish "^0.2.1"
|
||||
|
||||
es-abstract@^1.19.0, es-abstract@^1.20.4:
|
||||
version "1.21.3"
|
||||
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.3.tgz#8aaa0ffc080e8a6fef6ace72631dc1ec5d47bf94"
|
||||
integrity sha512-ZU4miiY1j3sGPFLJ34VJXEqhpmL+HGByCinGHv4HC+Fxl2fI2Z4yR6tl0mORnDr6PA8eihWo4LmSWDbvhALckg==
|
||||
version "1.22.1"
|
||||
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.22.1.tgz#8b4e5fc5cefd7f1660f0f8e1a52900dfbc9d9ccc"
|
||||
integrity sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw==
|
||||
dependencies:
|
||||
array-buffer-byte-length "^1.0.0"
|
||||
arraybuffer.prototype.slice "^1.0.1"
|
||||
available-typed-arrays "^1.0.5"
|
||||
call-bind "^1.0.2"
|
||||
es-set-tostringtag "^2.0.1"
|
||||
|
@ -2490,10 +2503,13 @@ es-abstract@^1.19.0, es-abstract@^1.20.4:
|
|||
object-keys "^1.1.1"
|
||||
object.assign "^4.1.4"
|
||||
regexp.prototype.flags "^1.5.0"
|
||||
safe-array-concat "^1.0.0"
|
||||
safe-regex-test "^1.0.0"
|
||||
string.prototype.trim "^1.2.7"
|
||||
string.prototype.trimend "^1.0.6"
|
||||
string.prototype.trimstart "^1.0.6"
|
||||
typed-array-buffer "^1.0.0"
|
||||
typed-array-byte-length "^1.0.0"
|
||||
typed-array-byte-offset "^1.0.0"
|
||||
typed-array-length "^1.0.4"
|
||||
unbox-primitive "^1.0.2"
|
||||
|
@ -2896,9 +2912,9 @@ fast-levenshtein@^2.0.6:
|
|||
integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==
|
||||
|
||||
fast-xml-parser@^4.0.14, fast-xml-parser@^4.2.5:
|
||||
version "4.2.5"
|
||||
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.5.tgz#a6747a09296a6cb34f2ae634019bf1738f3b421f"
|
||||
integrity sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g==
|
||||
version "4.2.6"
|
||||
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.6.tgz#30ad37b014c16e31eec0e01fbf90a85cedb4eacf"
|
||||
integrity sha512-Xo1qV++h/Y3Ng8dphjahnYe+rGHaaNdsYOBWL9Y9GCPKpNKilJtilvWkLcI9f9X2DoKTLsZsGYAls5+JL5jfLA==
|
||||
dependencies:
|
||||
strnum "^1.0.5"
|
||||
|
||||
|
@ -3803,15 +3819,11 @@ is-text-path@^1.0.1:
|
|||
text-extensions "^1.0.0"
|
||||
|
||||
is-typed-array@^1.1.10, is-typed-array@^1.1.9:
|
||||
version "1.1.10"
|
||||
resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.10.tgz#36a5b5cb4189b575d1a3e4b08536bfb485801e3f"
|
||||
integrity sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==
|
||||
version "1.1.12"
|
||||
resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.12.tgz#d0bab5686ef4a76f7a73097b95470ab199c57d4a"
|
||||
integrity sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==
|
||||
dependencies:
|
||||
available-typed-arrays "^1.0.5"
|
||||
call-bind "^1.0.2"
|
||||
for-each "^0.3.3"
|
||||
gopd "^1.0.1"
|
||||
has-tostringtag "^1.0.0"
|
||||
which-typed-array "^1.1.11"
|
||||
|
||||
is-typedarray@^1.0.0:
|
||||
version "1.0.0"
|
||||
|
@ -3842,6 +3854,11 @@ is-wsl@^2.2.0:
|
|||
dependencies:
|
||||
is-docker "^2.0.0"
|
||||
|
||||
isarray@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723"
|
||||
integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==
|
||||
|
||||
isexe@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||
|
@ -5886,6 +5903,16 @@ rxjs@^7.8.0:
|
|||
dependencies:
|
||||
tslib "^2.1.0"
|
||||
|
||||
safe-array-concat@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/safe-array-concat/-/safe-array-concat-1.0.0.tgz#2064223cba3c08d2ee05148eedbc563cd6d84060"
|
||||
integrity sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ==
|
||||
dependencies:
|
||||
call-bind "^1.0.2"
|
||||
get-intrinsic "^1.2.0"
|
||||
has-symbols "^1.0.3"
|
||||
isarray "^2.0.5"
|
||||
|
||||
safe-buffer@5.1.2:
|
||||
version "5.1.2"
|
||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
|
||||
|
@ -6414,9 +6441,9 @@ strnum@^1.0.5:
|
|||
integrity sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==
|
||||
|
||||
sucrase@^3.32.0:
|
||||
version "3.32.0"
|
||||
resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.32.0.tgz#c4a95e0f1e18b6847127258a75cf360bc568d4a7"
|
||||
integrity sha512-ydQOU34rpSyj2TGyz4D2p8rbktIOZ8QY9s+DGLvFU1i5pWJE8vkpruCjGCMHsdXwnD7JDcS+noSwM/a7zyNFDQ==
|
||||
version "3.33.0"
|
||||
resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.33.0.tgz#092c8d2f99a191f2cd9f1fdd52113772f4241f6e"
|
||||
integrity sha512-ARGC7vbufOHfpvyGcZZXFaXCMZ9A4fffOGC5ucOW7+WHDGlAe8LJdf3Jts1sWhDeiI1RSWrKy5Hodl+JWGdW2A==
|
||||
dependencies:
|
||||
"@jridgewell/gen-mapping" "^0.3.2"
|
||||
commander "^4.0.0"
|
||||
|
@ -6704,6 +6731,25 @@ type@^2.7.2:
|
|||
resolved "https://registry.yarnpkg.com/type/-/type-2.7.2.tgz#2376a15a3a28b1efa0f5350dcf72d24df6ef98d0"
|
||||
integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==
|
||||
|
||||
typed-array-buffer@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60"
|
||||
integrity sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==
|
||||
dependencies:
|
||||
call-bind "^1.0.2"
|
||||
get-intrinsic "^1.2.1"
|
||||
is-typed-array "^1.1.10"
|
||||
|
||||
typed-array-byte-length@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz#d787a24a995711611fb2b87a4052799517b230d0"
|
||||
integrity sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==
|
||||
dependencies:
|
||||
call-bind "^1.0.2"
|
||||
for-each "^0.3.3"
|
||||
has-proto "^1.0.1"
|
||||
is-typed-array "^1.1.10"
|
||||
|
||||
typed-array-byte-offset@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz#cbbe89b51fdef9cd6aaf07ad4707340abbc4ea0b"
|
||||
|
@ -6878,17 +6924,16 @@ which-boxed-primitive@^1.0.2:
|
|||
is-string "^1.0.5"
|
||||
is-symbol "^1.0.3"
|
||||
|
||||
which-typed-array@^1.1.10:
|
||||
version "1.1.10"
|
||||
resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.10.tgz#74baa2789991905c2076abb317103b866c64e69e"
|
||||
integrity sha512-uxoA5vLUfRPdjCuJ1h5LlYdmTLbYfums398v3WLkM+i/Wltl2/XyZpQWKbN++ck5L64SR/grOHqtXCUKmlZPNA==
|
||||
which-typed-array@^1.1.10, which-typed-array@^1.1.11:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.11.tgz#99d691f23c72aab6768680805a271b69761ed61a"
|
||||
integrity sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew==
|
||||
dependencies:
|
||||
available-typed-arrays "^1.0.5"
|
||||
call-bind "^1.0.2"
|
||||
for-each "^0.3.3"
|
||||
gopd "^1.0.1"
|
||||
has-tostringtag "^1.0.0"
|
||||
is-typed-array "^1.1.10"
|
||||
|
||||
which@^2.0.1:
|
||||
version "2.0.2"
|
||||
|
|
Reference in a new issue