Fixed bug for missing id

This commit is contained in:
dbroqua 2019-12-25 18:34:29 +01:00
parent bda2a1f3d1
commit 3ed371fbda
2 changed files with 6 additions and 4 deletions

View file

@ -30,7 +30,7 @@ const saveSong = (values, callback) => {
.exec(function (err, last) { .exec(function (err, last) {
if (err || if (err ||
last.length === 0 || last.length === 0 ||
(last[0] !== undefined && last[0].id !== values.id) (last[0] !== undefined && last[0].stringId !== values.stringId)
) { ) {
console.log(config.colors.FgBlue, '[INFO][saveSong] song not found:', values.title, values.artist, config.colors.Reset) console.log(config.colors.FgBlue, '[INFO][saveSong] song not found:', values.title, values.artist, config.colors.Reset)
@ -119,7 +119,7 @@ const getRemoteCover = (song, callback) => {
*/ */
const findCover = (song, callback) => { const findCover = (song, callback) => {
mongo.Metadata.findOne({ mongo.Metadata.findOne({
id: song.id stringId: song.stringId
}) })
.exec((err, metadata) => { .exec((err, metadata) => {
if (err) { if (err) {
@ -180,7 +180,8 @@ const getStream = (callback) => {
title: _body.data[0].track.title, title: _body.data[0].track.title,
album: _body.data[0].track.album, album: _body.data[0].track.album,
royaltytrackid: _body.data[0].track.royaltytrackid, royaltytrackid: _body.data[0].track.royaltytrackid,
id: _body.data[0].track.id || `FAKEID_${_body.data[0].track.artist}_${_body.data[0].track.title}_${_body.data[0].track.album}`, id: _body.data[0].track.id,
stringId: _body.data[0].track.id || `FAKEID_${_body.data[0].track.artist}_${_body.data[0].track.title}_${_body.data[0].track.album}`,
playlistId: _body.data[0].track.playlist ? _body.data[0].track.playlist.id : null, playlistId: _body.data[0].track.playlist ? _body.data[0].track.playlist.id : null,
thumbCover: _body.data[0].track.imageurl thumbCover: _body.data[0].track.imageurl
} }

View file

@ -8,7 +8,8 @@ const schemas = {
title: String, title: String,
album: String, album: String,
royaltytrackid: Number, royaltytrackid: Number,
id: String, id: Number,
stringId: String,
playlistId: Number, playlistId: Number,
thumbCover: String, thumbCover: String,
createdAt: { createdAt: {