Fixed Evil Angel upcoming and actor association issues. Moving from console.log to logger.

This commit is contained in:
2020-01-10 02:43:04 +01:00
parent 4fdb4ffec3
commit 4b36de2f55
7 changed files with 58 additions and 20 deletions

View File

@@ -4,6 +4,7 @@ const Promise = require('bluebird');
const UrlPattern = require('url-pattern');
const moment = require('moment');
const logger = require('./logger');
const knex = require('./knex');
const argv = require('./argv');
const scrapers = require('./scrapers/scrapers');
@@ -252,7 +253,7 @@ async function storeActor(actor, scraped = false, scrapeSuccess = false) {
await storeSocialLinks(actor.social, actorEntry.id);
console.log(`Added new entry for actor '${actor.name}'`);
logger.info(`Added new entry for actor '${actor.name}'`);
return actorEntry;
}
@@ -267,7 +268,7 @@ async function updateActor(actor, scraped = false, scrapeSuccess = false) {
await storeSocialLinks(actor.social, actor.id);
console.log(`Updated entry for actor '${actor.name}'`);
logger.info(`Updated entry for actor '${actor.name}'`);
return actorEntry;
}
@@ -338,7 +339,7 @@ async function scrapeActors(actorNames) {
const profile = await mergeProfiles(profiles, actorEntry);
if (profile === null) {
console.log(`Could not find profile for actor '${actorName}'`);
logger.warn(`Could not find profile for actor '${actorName}'`);
if (argv.save) {
await updateActor(profile, true, false);
@@ -380,7 +381,7 @@ async function scrapeActors(actorNames) {
}, newActorEntry.name);
}
} catch (error) {
console.warn(actorName, error);
logger.warn(actorName, error);
}
}, {
concurrency: 3,
@@ -404,7 +405,7 @@ async function associateActors(mappedActors, releases) {
knex('releases_actors').whereIn('release_id', releases.map(release => release.id)),
]);
console.log(actorNames, actorSlugs, existingActorEntries.map(actor => actor.name));
console.log(mappedActors);
const associations = await Promise.map(Object.entries(mappedActors), async ([actorName, releaseIds]) => {
try {
@@ -421,7 +422,7 @@ async function associateActors(mappedActors, releases) {
.some(associationEntry => associationEntry.actor_id === association.actor_id
&& associationEntry.release_id === association.release_id));
} catch (error) {
console.error(actorName, error);
logger.error(actorName, error);
return null;
}
});