chore: scrobbling

This commit is contained in:
Cory Dransfeldt 2024-03-29 17:01:22 -07:00
parent f140ce22fe
commit b575d25d14

View file

@ -15,11 +15,6 @@ const weekStop = () => {
const filterOldScrobbles = (scrobbles) => {
const twoWeeksAgo = DateTime.now().minus({ weeks: 2 });
console.log(scrobbles)
console.log(scrobbles.filter(scrobble => {
const timestamp = DateTime.fromISO(scrobble.timestamp);
return timestamp >= twoWeeksAgo;
}))
return scrobbles.filter(scrobble => {
const timestamp = DateTime.fromISO(scrobble.timestamp);
return timestamp >= twoWeeksAgo;
@ -104,11 +99,11 @@ export default async (request) => {
genre,
image: `https://cdn.coryd.dev/artists/${encodeURIComponent(sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase())}.jpg`
}
artistInfo = artistData
await artists.setJSON(artistKey, artistData)
}
// scrobble logic
artistInfo = await artists.get(artistKey, { type: 'json'})
const trackScrobbleData = {
track,
album,
@ -118,10 +113,6 @@ export default async (request) => {
}
const scrobbleData = await scrobbles.get(`${weekStop()}`, { type: 'json'})
const windowData = await scrobbles.get('window', { type: 'json'})
console.log('### SCROBBLE START')
console.log(scrobbleData);
console.log('### WINDOW START')
console.log(windowData);
await scrobbles.setJSON('now-playing', {...trackScrobbleData, ...{ url: `https://musicbrainz.org/artist/${artistInfo?.['mbid']}`}})
let scrobbleUpdate = scrobbleData
let windowUpdate = windowData;