Switch to async/await
This commit is contained in:
parent
87459b2acc
commit
18021e0ef8
10 changed files with 53 additions and 8837 deletions
|
@ -13,9 +13,9 @@ const client = amazon.createClient({
|
|||
awsTag: process.env.AWS_TAG,
|
||||
});
|
||||
|
||||
export function* lookupId(id, type) {
|
||||
export async function lookupId(id, type) {
|
||||
try {
|
||||
const results = yield client.itemLookup({
|
||||
const results = await client.itemLookup({
|
||||
itemId: id,
|
||||
responseGroup: 'ItemAttributes,Images,ItemIds',
|
||||
});
|
||||
|
@ -63,15 +63,15 @@ export function* lookupId(id, type) {
|
|||
};
|
||||
}
|
||||
} catch (err) {
|
||||
debug(inspect(err, { depth: 4 }));
|
||||
debug(inspect(err, { depth: null }));
|
||||
}
|
||||
return { service: 'amazon' };
|
||||
}
|
||||
|
||||
export function* search(data) {
|
||||
export async function search(data) {
|
||||
try {
|
||||
const type = data.type;
|
||||
const results = yield client.itemSearch({
|
||||
const results = await client.itemSearch({
|
||||
author: data.artist.name.replace(':', ' '),
|
||||
title: data.name.replace(':', ' '),
|
||||
searchIndex: 'MP3Downloads',
|
||||
|
@ -130,7 +130,7 @@ export function* search(data) {
|
|||
return { service: 'amazon' };
|
||||
}
|
||||
|
||||
export function* parseUrl(url) {
|
||||
export function parseUrl(url) {
|
||||
const matches = parse(url).path.match(/\/(albums|tracks)[/]+([^?]+)/);
|
||||
|
||||
if (matches && matches[2]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue