Update to Koa 2
This commit is contained in:
parent
42b6cd5a32
commit
87459b2acc
15 changed files with 467 additions and 419 deletions
40
lib/share.js
40
lib/share.js
|
@ -47,43 +47,3 @@ export function create(music) {
|
|||
],
|
||||
});
|
||||
}
|
||||
|
||||
export function findMatchesAsync(share) {
|
||||
process.nextTick(() => {
|
||||
for (const service of services) {
|
||||
if (service.id === share.service) {
|
||||
continue; // eslint-disable-line no-continue
|
||||
}
|
||||
co(function* gen() { // eslint-disable-line no-loop-func
|
||||
const match = yield service.search(share);
|
||||
if (match.id) {
|
||||
models.match.create({
|
||||
trackId: share.$modelOptions.name.singular == 'track' ? share.id : null,
|
||||
albumId: share.$modelOptions.name.singular == 'album' ? share.id : null,
|
||||
externalId: match.id.toString(),
|
||||
service: match.service,
|
||||
name: match.name,
|
||||
streamUrl: match.streamUrl,
|
||||
purchaseUrl: match.purchaseUrl,
|
||||
artworkSmall: match.artwork.small,
|
||||
artworkLarge: match.artwork.large,
|
||||
});
|
||||
} else {
|
||||
models.match.create({
|
||||
trackId: share.$modelOptions.name.singular == 'track' ? share.id : null,
|
||||
albumId: share.$modelOptions.name.singular == 'album' ? share.id : null,
|
||||
externalId: null,
|
||||
service: match.service,
|
||||
name: null,
|
||||
streamUrl: null,
|
||||
purchaseUrl: null,
|
||||
artworkSmall: null,
|
||||
artworkLarge: null,
|
||||
});
|
||||
}
|
||||
}).catch((err) => {
|
||||
debug(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue