2019-05-06 00:01:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-02-04 02:12:09 +00:00
|
|
|
const config = require('config');
|
2019-11-16 02:33:36 +00:00
|
|
|
const Promise = require('bluebird');
|
2019-12-10 21:35:00 +00:00
|
|
|
const moment = require('moment');
|
|
|
|
|
2020-01-10 01:43:04 +00:00
|
|
|
const logger = require('./logger');
|
2019-05-06 00:01:57 +00:00
|
|
|
const knex = require('./knex');
|
2019-11-16 02:33:36 +00:00
|
|
|
const argv = require('./argv');
|
2019-11-15 00:27:58 +00:00
|
|
|
const whereOr = require('./utils/where-or');
|
2019-11-19 03:36:15 +00:00
|
|
|
const { associateTags } = require('./tags');
|
2020-01-27 00:41:04 +00:00
|
|
|
const { associateActors, scrapeBasicActors } = require('./actors');
|
2019-11-16 02:33:36 +00:00
|
|
|
const {
|
2019-12-13 02:28:52 +00:00
|
|
|
createMediaDirectory,
|
2019-11-16 02:33:36 +00:00
|
|
|
storePhotos,
|
2020-01-08 22:33:24 +00:00
|
|
|
// storeReleasePhotos,
|
2019-11-16 02:33:36 +00:00
|
|
|
storeTrailer,
|
|
|
|
} = require('./media');
|
2019-12-05 00:26:22 +00:00
|
|
|
const { fetchSites, findSiteByUrl } = require('./sites');
|
2020-02-04 02:12:09 +00:00
|
|
|
const slugify = require('./utils/slugify');
|
2019-05-06 00:01:57 +00:00
|
|
|
|
2019-12-15 04:42:51 +00:00
|
|
|
function commonQuery(queryBuilder, {
|
|
|
|
filter = [],
|
|
|
|
after = new Date(0), // January 1970
|
|
|
|
before = new Date(2 ** 44), // May 2109
|
|
|
|
limit = 100,
|
|
|
|
}) {
|
|
|
|
const finalFilter = [].concat(filter); // ensure filter is array
|
|
|
|
|
|
|
|
queryBuilder
|
|
|
|
.leftJoin('sites', 'releases.site_id', 'sites.id')
|
|
|
|
.leftJoin('studios', 'releases.studio_id', 'studios.id')
|
|
|
|
.leftJoin('networks', 'sites.network_id', 'networks.id')
|
|
|
|
.select(
|
|
|
|
'releases.*',
|
|
|
|
'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id', 'sites.parameters as site_parameters',
|
|
|
|
'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url',
|
|
|
|
'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url', 'networks.description as network_description',
|
|
|
|
)
|
|
|
|
.whereNotExists((builder) => {
|
|
|
|
// apply tag filters
|
|
|
|
builder
|
|
|
|
.select('*')
|
|
|
|
.from('tags_associated')
|
|
|
|
.leftJoin('tags', 'tags_associated.tag_id', 'tags.id')
|
|
|
|
.whereIn('tags.slug', finalFilter)
|
|
|
|
.where('tags_associated.domain', 'releases')
|
|
|
|
.whereRaw('tags_associated.target_id = releases.id');
|
|
|
|
})
|
|
|
|
.andWhere('releases.date', '>', after)
|
|
|
|
.andWhere('releases.date', '<=', before)
|
|
|
|
.orderBy([{ column: 'date', order: 'desc' }, { column: 'created_at', order: 'desc' }])
|
|
|
|
.limit(limit);
|
|
|
|
}
|
|
|
|
|
2019-12-15 22:46:42 +00:00
|
|
|
async function curateRelease(release) {
|
|
|
|
const [actors, tags, media] = await Promise.all([
|
2019-12-15 04:42:51 +00:00
|
|
|
knex('actors_associated')
|
|
|
|
.select(
|
|
|
|
'actors.id', 'actors.name', 'actors.gender', 'actors.slug', 'actors.birthdate',
|
|
|
|
'birth_countries.alpha2 as birth_country_alpha2', 'birth_countries.name as birth_country_name', 'birth_countries.alias as birth_country_alias',
|
|
|
|
'media.thumbnail as avatar',
|
|
|
|
)
|
|
|
|
.where({ release_id: release.id })
|
|
|
|
.leftJoin('actors', 'actors.id', 'actors_associated.actor_id')
|
|
|
|
.leftJoin('countries as birth_countries', 'actors.birth_country_alpha2', 'birth_countries.alpha2')
|
|
|
|
.leftJoin('media', (builder) => {
|
|
|
|
builder
|
|
|
|
.on('media.target_id', 'actors.id')
|
|
|
|
.andOnVal('media.domain', 'actors')
|
|
|
|
.andOnVal('media.index', '0');
|
|
|
|
})
|
|
|
|
.orderBy('actors.gender'),
|
|
|
|
knex('tags_associated')
|
|
|
|
.select('tags.name', 'tags.slug')
|
|
|
|
.where({
|
|
|
|
domain: 'releases',
|
|
|
|
target_id: release.id,
|
|
|
|
})
|
|
|
|
.leftJoin('tags', 'tags.id', 'tags_associated.tag_id')
|
|
|
|
.orderBy('tags.priority', 'desc'),
|
|
|
|
knex('media')
|
|
|
|
.where({
|
|
|
|
target_id: release.id,
|
|
|
|
domain: 'releases',
|
|
|
|
})
|
|
|
|
.orderBy(['role', 'index']),
|
|
|
|
]);
|
|
|
|
|
|
|
|
const curatedRelease = {
|
|
|
|
id: release.id,
|
|
|
|
type: release.type,
|
|
|
|
title: release.title,
|
|
|
|
date: release.date,
|
|
|
|
dateAdded: release.created_at,
|
|
|
|
description: release.description,
|
|
|
|
url: release.url,
|
|
|
|
shootId: release.shoot_id,
|
|
|
|
entryId: release.entry_id,
|
|
|
|
actors: actors.map(actor => ({
|
|
|
|
id: actor.id,
|
|
|
|
slug: actor.slug,
|
|
|
|
name: actor.name,
|
|
|
|
gender: actor.gender,
|
|
|
|
birthdate: actor.birthdate,
|
|
|
|
age: moment().diff(actor.birthdate, 'years'),
|
|
|
|
ageThen: moment(release.date).diff(actor.birthdate, 'years'),
|
|
|
|
avatar: actor.avatar,
|
|
|
|
origin: actor.birth_country_alpha2
|
|
|
|
? {
|
|
|
|
country: {
|
|
|
|
name: actor.birth_country_alias,
|
|
|
|
alpha2: actor.birth_country_alpha2,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: null,
|
|
|
|
})),
|
|
|
|
director: release.director,
|
|
|
|
tags,
|
|
|
|
duration: release.duration,
|
|
|
|
photos: media.filter(item => item.role === 'photo'),
|
|
|
|
poster: media.filter(item => item.role === 'poster')[0],
|
|
|
|
covers: media.filter(item => item.role === 'cover'),
|
|
|
|
trailer: media.filter(item => item.role === 'trailer')[0],
|
|
|
|
site: {
|
|
|
|
id: release.site_id,
|
|
|
|
name: release.site_name,
|
|
|
|
independent: release.site_parameters
|
|
|
|
? (JSON.parse(release.site_parameters).independent || false)
|
|
|
|
: false,
|
|
|
|
slug: release.site_slug,
|
|
|
|
url: release.site_url,
|
|
|
|
},
|
|
|
|
studio: release.studio_id
|
|
|
|
? {
|
|
|
|
id: release.studio_id,
|
|
|
|
name: release.studio_name,
|
|
|
|
slug: release.studio_slug,
|
|
|
|
url: release.studio_url,
|
|
|
|
}
|
|
|
|
: null,
|
|
|
|
network: {
|
|
|
|
id: release.network_id,
|
|
|
|
name: release.network_name,
|
|
|
|
description: release.network_description,
|
|
|
|
slug: release.network_slug,
|
|
|
|
url: release.network_url,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return curatedRelease;
|
|
|
|
}
|
|
|
|
|
2019-05-06 00:01:57 +00:00
|
|
|
function curateReleases(releases) {
|
|
|
|
return Promise.all(releases.map(async release => curateRelease(release)));
|
|
|
|
}
|
|
|
|
|
2019-12-15 21:16:55 +00:00
|
|
|
async function attachChannelSite(release) {
|
2019-12-15 22:14:43 +00:00
|
|
|
if (!release.site.isFallback) {
|
2019-12-15 22:46:42 +00:00
|
|
|
return release;
|
2019-12-15 22:14:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!release.channel) {
|
2020-01-22 21:25:58 +00:00
|
|
|
throw new Error(`Unable to derive channel site from generic URL: ${release.url}`);
|
2019-12-15 21:16:55 +00:00
|
|
|
}
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2019-12-15 21:16:55 +00:00
|
|
|
const [site] = await fetchSites({
|
|
|
|
name: release.channel,
|
|
|
|
slug: release.channel,
|
|
|
|
});
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2019-12-15 21:16:55 +00:00
|
|
|
if (site) {
|
|
|
|
return {
|
|
|
|
...release,
|
|
|
|
site,
|
|
|
|
};
|
2019-12-05 00:26:22 +00:00
|
|
|
}
|
2019-12-15 21:16:55 +00:00
|
|
|
|
2020-01-07 03:23:28 +00:00
|
|
|
try {
|
|
|
|
const urlSite = await findSiteByUrl(release.channel);
|
2019-12-15 21:16:55 +00:00
|
|
|
|
2020-01-07 03:23:28 +00:00
|
|
|
return {
|
|
|
|
...release,
|
|
|
|
site: urlSite,
|
|
|
|
};
|
|
|
|
} catch (error) {
|
2020-01-22 21:25:58 +00:00
|
|
|
throw new Error(`Unable to derive channel site from generic URL: ${release.url}`);
|
2020-01-07 03:23:28 +00:00
|
|
|
}
|
2019-12-05 00:26:22 +00:00
|
|
|
}
|
|
|
|
|
2020-01-06 04:19:38 +00:00
|
|
|
async function attachStudio(release) {
|
|
|
|
if (!release.studio) {
|
|
|
|
return release;
|
|
|
|
}
|
|
|
|
|
|
|
|
const studio = await knex('studios')
|
|
|
|
.where('name', release.studio)
|
|
|
|
.orWhere('slug', release.studio)
|
|
|
|
.orWhere('url', release.studio)
|
|
|
|
.first();
|
|
|
|
|
|
|
|
return {
|
|
|
|
...release,
|
|
|
|
studio,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-12-15 04:42:51 +00:00
|
|
|
async function curateReleaseEntry(release) {
|
2020-02-04 02:12:09 +00:00
|
|
|
const slug = slugify(release.title, {
|
|
|
|
encode: true,
|
|
|
|
limit: config.titleSlugLength,
|
|
|
|
});
|
|
|
|
|
2019-12-05 00:26:22 +00:00
|
|
|
const curatedRelease = {
|
2019-11-16 02:33:36 +00:00
|
|
|
site_id: release.site.id,
|
|
|
|
studio_id: release.studio ? release.studio.id : null,
|
|
|
|
shoot_id: release.shootId || null,
|
|
|
|
entry_id: release.entryId || null,
|
2019-12-15 04:42:51 +00:00
|
|
|
parent_id: release.parentId,
|
|
|
|
type: release.type,
|
2019-11-16 02:33:36 +00:00
|
|
|
url: release.url,
|
|
|
|
title: release.title,
|
2020-02-04 02:12:09 +00:00
|
|
|
slug,
|
2019-11-16 02:33:36 +00:00
|
|
|
date: release.date,
|
|
|
|
description: release.description,
|
|
|
|
// director: release.director,
|
|
|
|
duration: release.duration,
|
2019-12-11 04:15:23 +00:00
|
|
|
// likes: release.rating && release.rating.likes,
|
|
|
|
// dislikes: release.rating && release.rating.dislikes,
|
|
|
|
// rating: release.rating && release.rating.stars && Math.floor(release.rating.stars),
|
2019-12-09 04:00:49 +00:00
|
|
|
deep: typeof release.deep === 'boolean' ? release.deep : false,
|
2019-11-16 02:33:36 +00:00
|
|
|
};
|
2019-12-05 00:26:22 +00:00
|
|
|
|
|
|
|
return curatedRelease;
|
2019-11-16 02:33:36 +00:00
|
|
|
}
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
async function fetchReleases(queryObject = {}, options = {}) {
|
|
|
|
const releases = await knex('releases')
|
|
|
|
.modify(commonQuery, options)
|
|
|
|
.andWhere(builder => whereOr(queryObject, 'releases', builder));
|
2019-11-09 03:43:58 +00:00
|
|
|
|
|
|
|
return curateReleases(releases);
|
|
|
|
}
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
async function fetchSiteReleases(queryObject, options = {}) {
|
2019-11-09 03:43:58 +00:00
|
|
|
const releases = await knex('releases')
|
2019-11-15 00:27:58 +00:00
|
|
|
.modify(commonQuery, options)
|
|
|
|
.where(builder => whereOr(queryObject, 'sites', builder));
|
2019-11-09 03:43:58 +00:00
|
|
|
|
|
|
|
return curateReleases(releases);
|
|
|
|
}
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
async function fetchNetworkReleases(queryObject, options = {}) {
|
2019-11-09 03:43:58 +00:00
|
|
|
const releases = await knex('releases')
|
2019-11-15 00:27:58 +00:00
|
|
|
.modify(commonQuery, options)
|
|
|
|
.where(builder => whereOr(queryObject, 'networks', builder));
|
2019-05-06 00:01:57 +00:00
|
|
|
|
|
|
|
return curateReleases(releases);
|
|
|
|
}
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
async function fetchActorReleases(queryObject, options = {}) {
|
2019-11-10 03:20:22 +00:00
|
|
|
const releases = await knex('actors_associated')
|
2019-11-15 00:27:58 +00:00
|
|
|
.leftJoin('releases', 'actors_associated.release_id', 'releases.id')
|
|
|
|
.leftJoin('actors', 'actors_associated.actor_id', 'actors.id')
|
2019-11-10 03:20:22 +00:00
|
|
|
.select(
|
|
|
|
'actors.name as actor_name',
|
|
|
|
)
|
2019-11-15 00:27:58 +00:00
|
|
|
.modify(commonQuery, options)
|
|
|
|
.where(builder => whereOr(queryObject, 'actors', builder));
|
2019-11-10 03:20:22 +00:00
|
|
|
|
|
|
|
return curateReleases(releases);
|
|
|
|
}
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
async function fetchTagReleases(queryObject, options = {}) {
|
2019-11-11 04:18:28 +00:00
|
|
|
const releases = await knex('tags_associated')
|
2019-12-07 03:41:16 +00:00
|
|
|
.leftJoin('releases', 'tags_associated.target_id', 'releases.id')
|
2019-11-15 00:27:58 +00:00
|
|
|
.leftJoin('tags', 'tags_associated.tag_id', 'tags.id')
|
2019-11-11 04:18:28 +00:00
|
|
|
.select(
|
|
|
|
'tags.name as tag_name',
|
|
|
|
)
|
2019-11-15 00:27:58 +00:00
|
|
|
.modify(commonQuery, options)
|
2019-12-07 03:41:16 +00:00
|
|
|
.where('tags_associated.domain', 'releases')
|
2019-11-15 00:27:58 +00:00
|
|
|
.where(builder => whereOr(queryObject, 'tags', builder));
|
2019-11-11 04:18:28 +00:00
|
|
|
|
|
|
|
return curateReleases(releases);
|
|
|
|
}
|
|
|
|
|
2019-12-15 04:42:51 +00:00
|
|
|
function accumulateActors(releases) {
|
|
|
|
return releases.reduce((acc, release) => {
|
2020-02-02 23:39:43 +00:00
|
|
|
if (!Array.isArray(release.actors)) return acc;
|
2019-12-15 04:42:51 +00:00
|
|
|
|
|
|
|
release.actors.forEach((actor) => {
|
2020-02-02 23:39:43 +00:00
|
|
|
const actorName = actor.name ? actor.name.trim() : actor.trim();
|
2019-12-15 04:42:51 +00:00
|
|
|
|
2020-02-05 22:57:55 +00:00
|
|
|
if (!acc[actorName]) acc[actorName] = new Set();
|
|
|
|
acc[actorName].add(release.id);
|
2019-12-15 04:42:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
function accumulateMovies(releases) {
|
|
|
|
return releases.reduce((acc, release) => {
|
|
|
|
if (release.movie) {
|
|
|
|
if (acc[release.movie]) {
|
|
|
|
acc[release.movie] = acc[release.movie].concat(release.id);
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
acc[release.movie] = [release.id];
|
|
|
|
}
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
|
2020-01-08 22:33:24 +00:00
|
|
|
async function storeReleaseAssets(releases) {
|
|
|
|
// await storeReleasePhotos(releases);
|
2019-12-13 02:28:52 +00:00
|
|
|
|
2020-01-08 22:33:24 +00:00
|
|
|
await Promise.map(releases, async (release) => {
|
|
|
|
const subpath = `${release.site.network.slug}/${release.site.slug}/${release.id}/`;
|
|
|
|
const identifier = `"${release.title}" (${release.id})`;
|
2019-12-13 02:28:52 +00:00
|
|
|
|
2020-01-14 20:45:30 +00:00
|
|
|
try {
|
|
|
|
await createMediaDirectory('releases', subpath);
|
2020-01-08 22:33:24 +00:00
|
|
|
|
|
|
|
// don't use Promise.all to prevent concurrency issues with duplicate detection
|
|
|
|
if (release.poster) {
|
|
|
|
await storePhotos([release.poster], {
|
|
|
|
role: 'poster',
|
|
|
|
targetId: release.id,
|
|
|
|
subpath,
|
|
|
|
}, identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
await storePhotos(release.photos, {
|
|
|
|
targetId: release.id,
|
2019-12-13 02:28:52 +00:00
|
|
|
subpath,
|
2020-01-08 22:33:24 +00:00
|
|
|
primaryRole: release.poster ? null : 'poster',
|
2020-01-06 04:19:38 +00:00
|
|
|
}, identifier);
|
|
|
|
|
2020-01-08 22:33:24 +00:00
|
|
|
await storePhotos(release.covers, {
|
|
|
|
role: 'cover',
|
|
|
|
targetId: release.id,
|
|
|
|
subpath,
|
|
|
|
}, identifier);
|
|
|
|
|
|
|
|
await storeTrailer(release.trailer, {
|
|
|
|
targetId: release.id,
|
|
|
|
subpath,
|
2020-02-02 04:14:58 +00:00
|
|
|
role: 'trailer',
|
|
|
|
}, identifier);
|
|
|
|
|
|
|
|
await storeTrailer(release.teaser, {
|
|
|
|
targetId: release.id,
|
|
|
|
subpath,
|
|
|
|
role: 'teaser',
|
2020-01-08 22:33:24 +00:00
|
|
|
}, identifier);
|
2020-01-14 20:45:30 +00:00
|
|
|
} catch (error) {
|
|
|
|
logger.error(error.message);
|
|
|
|
}
|
2020-01-08 22:33:24 +00:00
|
|
|
}, {
|
|
|
|
concurrency: 10,
|
|
|
|
});
|
2019-11-19 03:36:15 +00:00
|
|
|
}
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-11-19 03:36:15 +00:00
|
|
|
async function storeRelease(release) {
|
2020-01-08 18:23:50 +00:00
|
|
|
const existingRelease = await knex('releases')
|
|
|
|
.where({
|
|
|
|
entry_id: release.entryId,
|
|
|
|
site_id: release.site.id,
|
|
|
|
})
|
|
|
|
.first();
|
2020-02-05 22:57:55 +00:00
|
|
|
|
2019-12-15 04:42:51 +00:00
|
|
|
const curatedRelease = await curateReleaseEntry(release);
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-11-19 03:36:15 +00:00
|
|
|
if (existingRelease && !argv.redownload) {
|
2020-02-05 22:57:55 +00:00
|
|
|
return existingRelease;
|
2019-11-19 03:36:15 +00:00
|
|
|
}
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-11-19 03:36:15 +00:00
|
|
|
if (existingRelease && argv.redownload) {
|
|
|
|
const [updatedRelease] = await knex('releases')
|
2020-01-08 18:23:50 +00:00
|
|
|
.where('id', existingRelease.id)
|
2019-11-19 03:36:15 +00:00
|
|
|
.update({
|
|
|
|
...existingRelease,
|
|
|
|
...curatedRelease,
|
|
|
|
})
|
|
|
|
.returning('*');
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-12-12 02:12:05 +00:00
|
|
|
if (updatedRelease) {
|
|
|
|
await associateTags(release, updatedRelease.id);
|
2020-01-10 01:43:04 +00:00
|
|
|
logger.info(`Updated release "${release.title}" (${existingRelease.id}, ${release.site.name})`);
|
2019-12-12 02:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
await associateTags(release, existingRelease.id);
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2020-02-05 22:57:55 +00:00
|
|
|
return existingRelease;
|
2019-11-17 02:56:45 +00:00
|
|
|
}
|
|
|
|
|
2019-11-19 03:36:15 +00:00
|
|
|
const [releaseEntry] = await knex('releases')
|
|
|
|
.insert(curatedRelease)
|
|
|
|
.returning('*');
|
|
|
|
|
2019-12-12 02:12:05 +00:00
|
|
|
await associateTags(release, releaseEntry.id);
|
|
|
|
|
2020-01-10 01:43:04 +00:00
|
|
|
logger.info(`Stored release "${release.title}" (${releaseEntry.id}, ${release.site.name})`);
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2020-02-04 02:12:09 +00:00
|
|
|
return releaseEntry;
|
2019-11-17 02:56:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function storeReleases(releases) {
|
2019-12-04 20:58:08 +00:00
|
|
|
const storedReleases = await Promise.map(releases, async (release) => {
|
2019-11-17 02:56:45 +00:00
|
|
|
try {
|
2019-12-15 21:16:55 +00:00
|
|
|
const releaseWithChannelSite = await attachChannelSite(release);
|
2020-01-07 03:23:28 +00:00
|
|
|
const releaseWithStudio = await attachStudio(releaseWithChannelSite);
|
2020-02-04 02:12:09 +00:00
|
|
|
const { id, slug } = await storeRelease(releaseWithStudio);
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-12-04 20:58:08 +00:00
|
|
|
return {
|
2020-02-04 02:12:09 +00:00
|
|
|
id,
|
|
|
|
slug,
|
2019-12-15 21:16:55 +00:00
|
|
|
...releaseWithChannelSite,
|
2019-12-04 20:58:08 +00:00
|
|
|
};
|
2019-11-17 02:56:45 +00:00
|
|
|
} catch (error) {
|
2020-01-13 22:45:09 +00:00
|
|
|
logger.error(error.message);
|
2019-11-17 02:56:45 +00:00
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}, {
|
2019-12-04 20:58:08 +00:00
|
|
|
concurrency: 10,
|
2019-12-09 04:00:49 +00:00
|
|
|
}).filter(release => release);
|
2019-12-04 20:58:08 +00:00
|
|
|
|
2019-12-15 04:42:51 +00:00
|
|
|
const actors = accumulateActors(storedReleases);
|
|
|
|
const movies = accumulateMovies(storedReleases);
|
2019-12-04 20:58:08 +00:00
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
associateActors(actors, storedReleases),
|
2020-01-08 22:33:24 +00:00
|
|
|
storeReleaseAssets(storedReleases),
|
2019-12-04 20:58:08 +00:00
|
|
|
]);
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-02-03 01:04:47 +00:00
|
|
|
if (argv.withProfiles && Object.keys(actors).length > 0) {
|
2020-02-01 00:15:40 +00:00
|
|
|
await scrapeBasicActors();
|
|
|
|
}
|
2020-01-27 00:41:04 +00:00
|
|
|
|
2019-12-15 04:42:51 +00:00
|
|
|
return {
|
|
|
|
releases: storedReleases,
|
|
|
|
actors,
|
|
|
|
movies,
|
|
|
|
};
|
2019-11-17 02:56:45 +00:00
|
|
|
}
|
|
|
|
|
2019-05-06 00:01:57 +00:00
|
|
|
module.exports = {
|
|
|
|
fetchReleases,
|
2019-11-10 03:20:22 +00:00
|
|
|
fetchActorReleases,
|
2019-11-09 03:43:58 +00:00
|
|
|
fetchSiteReleases,
|
|
|
|
fetchNetworkReleases,
|
2019-11-11 04:18:28 +00:00
|
|
|
fetchTagReleases,
|
2019-11-16 02:33:36 +00:00
|
|
|
storeRelease,
|
|
|
|
storeReleases,
|
2019-05-06 00:01:57 +00:00
|
|
|
};
|