Fix missing tracks too.

This commit is contained in:
Jonathan Cremin 2017-11-13 18:40:40 +00:00
parent a919d80f64
commit 82bac11f5a

View file

@ -24,11 +24,11 @@ const query = {
], ],
}; };
function* search(data, done) { function* search(data) {
const share = data.share; const share = data.share;
const service = services.find(item => data.service.id === item.id); const service = services.find(item => data.service.id === item.id);
debug(`Matching ${share.name} on ${data.service.id}`) debug(`Matching ${share.name} on ${data.service.id}`);
const match = yield service.search(share); const match = yield service.search(share);
@ -61,10 +61,10 @@ function* search(data, done) {
} }
} }
co(function* () { function* find(model) {
const albums = yield models.album.findAll(query); const items = yield models[model].findAll(query);
for (const item of albums) { for (const item of items) {
const unmatched = serviceIds; let unmatched = serviceIds;
for (const match of item.matches) { for (const match of item.matches) {
unmatched = unmatched.filter(id => match.service !== id); unmatched = unmatched.filter(id => match.service !== id);
} }
@ -74,14 +74,14 @@ co(function* () {
yield search({ share: item, service: { id: toMatch } }); yield search({ share: item, service: { id: toMatch } });
} }
} else { } else {
debug(`No broken matches for ${item.name}`) debug(`No broken matches for ${item.name}`);
} }
} }
}).catch(function (err) { }
co(function* main() {
yield find('album');
yield find('track');
}).catch((err) => {
debug(err.stack); debug(err.stack);
}); });