fix: missing timestamp
This commit is contained in:
parent
23fd06b2ca
commit
dc1cad3d92
1 changed files with 19 additions and 17 deletions
|
@ -14,26 +14,28 @@ module.exports = async function () {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
}).catch()
|
}).catch()
|
||||||
const data = await res
|
const data = await res
|
||||||
const submission = data['recenttracks']['track'].map((track) => {
|
let submissions = []
|
||||||
|
data['recenttracks']['track'].forEach((track) => {
|
||||||
let artistMbid = track['artist']['mbid']['mbid']
|
let artistMbid = track['artist']['mbid']['mbid']
|
||||||
|
|
||||||
// mbid mismatches
|
// mbid mismatches
|
||||||
if (mbidMap(track['artist']['#text']) !== '') artistMbid = mbidMap(track['artist']['#text'])
|
if (mbidMap(track['artist']['#text']) !== '') artistMbid = mbidMap(track['artist']['#text'])
|
||||||
|
|
||||||
return {
|
if (track['date'])
|
||||||
track_metadata: {
|
submissions.push({
|
||||||
track_name: track['name'],
|
track_metadata: {
|
||||||
artist_name: track['artist']['#text'],
|
track_name: track['name'],
|
||||||
release_name: track['album']['#text'],
|
artist_name: track['artist']['#text'],
|
||||||
additional_info: {
|
release_name: track['album']['#text'],
|
||||||
submission_client: 'coryd.dev last.fm importer',
|
additional_info: {
|
||||||
lastfm_track_mbid: track['mbid'],
|
submission_client: 'coryd.dev last.fm importer',
|
||||||
lastfm_release_mbid: track['album']['mbid'],
|
lastfm_track_mbid: track['mbid'],
|
||||||
lastfm_artist_mbid: artistMbid,
|
lastfm_release_mbid: track['album']['mbid'],
|
||||||
|
lastfm_artist_mbid: artistMbid,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
listened_at: track['date']['uts'],
|
||||||
listened_at: track['date']['uts'],
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await fetch('https://api.listenbrainz.org/1/submit-listens', {
|
await fetch('https://api.listenbrainz.org/1/submit-listens', {
|
||||||
|
@ -44,7 +46,7 @@ module.exports = async function () {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
listen_type: 'import',
|
listen_type: 'import',
|
||||||
payload: submission,
|
payload: submissions,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -56,11 +58,11 @@ module.exports = async function () {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
service: 'lastfm',
|
service: 'lastfm',
|
||||||
ts: submission[0]['listened_at'],
|
ts: submissions[0]['listened_at'],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listenbrainz_submission: submission,
|
listenbrainz_submissions: submissions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue