Added teaser support. Added Score network with scraper for Scoreland. Improved q. Added assets.

This commit is contained in:
2020-02-02 05:14:58 +01:00
parent 14e5695b6e
commit a97c6defca
52 changed files with 4291 additions and 3435 deletions

View File

@@ -188,7 +188,7 @@ async function storePhotos(photos, {
targetId,
subpath,
primaryRole, // role to assign to first photo if not already in database, used mainly for avatars
entropy = 2.5, // filter out fallback avatars and other generic clipart
entropyFilter = 2.5, // filter out fallback avatars and other generic clipart
}, label) {
if (!photos || photos.length === 0) {
logger.info(`No ${role}s available for ${label}`);
@@ -200,7 +200,7 @@ async function storePhotos(photos, {
const metaFiles = await Promise.map(sourceOriginals, async (photoUrl, index) => fetchPhoto(photoUrl, index, label), {
concurrency: 10,
}).filter(photo => photo && photo.entropy > entropy);
}).filter(photo => photo && photo.entropy > entropyFilter);
const metaFilesByHash = metaFiles.reduce((acc, photo) => ({ ...acc, [photo.hash]: photo }), {}); // pre-filter hash duplicates within set; may occur through fallbacks
const [hashDuplicates, hashOriginals] = await findDuplicates(Object.values(metaFilesByHash), 'hash', 'hash', label);
@@ -285,6 +285,7 @@ async function storeReleasePhotos(releases, label) {
async function storeTrailer(trailers, {
domain = 'releases',
role = 'trailer',
targetId,
subpath,
}, label) {
@@ -294,7 +295,7 @@ async function storeTrailer(trailers, {
: trailers;
if (!trailer || !trailer.src) {
logger.info(`No trailer available for ${label}`);
logger.info(`No ${role} available for ${label}`);
return;
}
@@ -306,7 +307,7 @@ async function storeTrailer(trailers, {
const res = await bhttp.get(trailerX.src);
const hash = getHash(res.body);
const filepath = path.join(domain, subpath, `trailer${trailerX.quality ? `_${trailerX.quality}` : ''}.${mime.getExtension(mimetype)}`);
const filepath = path.join(domain, subpath, `${role}${trailerX.quality ? `_${trailerX.quality}` : ''}.${mime.getExtension(mimetype)}`);
return {
trailer: res.body,
@@ -327,6 +328,7 @@ async function storeTrailer(trailers, {
source: trailerX.source,
quality: trailerX.quality,
hash: trailerX.hash,
type: role,
})))
.returning('*');
@@ -336,7 +338,7 @@ async function storeTrailer(trailers, {
? [...sourceDuplicates, ...hashDuplicates, ...newTrailers]
: [...sourceDuplicates, ...hashDuplicates];
await upsert('releases_trailers', trailerEntries.map(trailerEntry => ({
await upsert(`releases_${role}s`, trailerEntries.map(trailerEntry => ({
release_id: targetId,
media_id: trailerEntry.id,
})), ['release_id', 'media_id']);