From de36ed97e4f42c91c5466699fb562cc964624cbf Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Thu, 21 Nov 2019 11:43:07 +0100 Subject: [PATCH] Added profile scraping in try/catch block. Re-added boobs enhanced info to actor page. --- assets/components/actor/actor.vue | 4 +-- src/actors.js | 60 ++++++++++++++++--------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/assets/components/actor/actor.vue b/assets/components/actor/actor.vue index 073e1f0a..a4f63c54 100644 --- a/assets/components/actor/actor.vue +++ b/assets/components/actor/actor.vue @@ -73,12 +73,12 @@
  • Measurements - {{ actor.bust || '??' }}-{{ actor.waist || '??' }}-{{ actor.hip || '??' }} + {{ actor.bust || '??' }}-{{ actor.waist || '??' }}-{{ actor.hip || '??' }} ({{ actor.naturalBoobs ? 'Natural' : 'Enhanced' }})
  • Social - {{ social }} + {{ actor.social.join(',') }}
  • diff --git a/src/actors.js b/src/actors.js index 9b3e3169..afe17f0a 100644 --- a/src/actors.js +++ b/src/actors.js @@ -183,39 +183,43 @@ function mergeProfiles(profiles, actor) { async function scrapeActors(actorNames) { await Promise.map(actorNames || argv.actors, async (actorName) => { - const actorSlug = actorName.toLowerCase().replace(/\s+/g, '-'); + try { + const actorSlug = actorName.toLowerCase().replace(/\s+/g, '-'); - const actorEntry = await knex('actors').where({ slug: actorSlug }).first(); - const profiles = await Promise.all( - Object.values(scrapers.actors) - .map(scraper => scraper.fetchProfile(actorEntry ? actorEntry.name : actorName)), - ); + const actorEntry = await knex('actors').where({ slug: actorSlug }).first(); + const profiles = await Promise.all( + Object.values(scrapers.actors) + .map(scraper => scraper.fetchProfile(actorEntry ? actorEntry.name : actorName)), + ); - const profile = mergeProfiles(profiles, actorEntry); + const profile = mergeProfiles(profiles, actorEntry); - if (profile === null) { - console.log(`Could not find profile for actor '${actorName}'`); - await updateActor(profile, true, false); + if (profile === null) { + console.log(`Could not find profile for actor '${actorName}'`); + await updateActor(profile, true, false); - return; + return; + } + + + if (actorEntry && profile) { + await createActorMediaDirectory(profile, actorEntry); + + await Promise.all([ + updateActor(profile, true, true), + storeAvatars(profile, actorEntry), + ]); + + return; + } + + const newActorEntry = await storeActor(profile, true, true); + + await createActorMediaDirectory(profile, newActorEntry); + await storeAvatars(profile, newActorEntry); + } catch (error) { + console.warn(actorName, error); } - - - if (actorEntry && profile) { - await createActorMediaDirectory(profile, actorEntry); - - await Promise.all([ - updateActor(profile, true, true), - storeAvatars(profile, actorEntry), - ]); - - return; - } - - const newActorEntry = await storeActor(profile, true, true); - - await createActorMediaDirectory(profile, newActorEntry); - await storeAvatars(profile, newActorEntry); }, { concurrency: 3, });