Refactored media module to generalize avatar and poster storage into photo storage.

This commit is contained in:
2019-12-13 03:28:52 +01:00
parent 20011a74e8
commit 77307d2d13
7 changed files with 183 additions and 142 deletions

View File

@@ -9,7 +9,7 @@ const argv = require('./argv');
const scrapers = require('./scrapers/scrapers');
const whereOr = require('./utils/where-or');
const resolvePlace = require('./utils/resolve-place');
const { createActorMediaDirectory, storeAvatars } = require('./media');
const { createMediaDirectory, storePhotos } = require('./media');
async function curateActor(actor) {
const [aliases, photos, social] = await Promise.all([
@@ -352,11 +352,19 @@ async function scrapeActors(actorNames) {
if (argv.save) {
if (actorEntry && profile) {
await createActorMediaDirectory(profile, actorEntry);
await createMediaDirectory('actors', `${actorEntry.slug}/`);
await Promise.all([
updateActor(profile, true, true),
storeAvatars(profile, actorEntry),
// storeAvatars(profile, actorEntry),
storePhotos(profile.avatars, {
domain: 'actors',
role: 'photo',
primaryRole: 'avatar',
targetId: actorEntry.id,
subpath: `${actorEntry.slug}/`,
naming: 'timestamp',
}, actorEntry.name),
]);
return;
@@ -364,8 +372,15 @@ async function scrapeActors(actorNames) {
const newActorEntry = await storeActor(profile, true, true);
await createActorMediaDirectory(profile, newActorEntry);
await storeAvatars(profile, newActorEntry);
await createMediaDirectory('actors', `${newActorEntry.slug}/`);
await storePhotos(profile.avatars, {
domain: 'actors',
role: 'photo',
primaryRole: 'avatar',
targetId: newActorEntry.id,
subpath: `${newActorEntry.slug}/`,
naming: 'timestamp',
}, newActorEntry.name);
}
} catch (error) {
console.warn(actorName, error);