Compare commits
No commits in common. "89c0776045ff76c5d985219034ad22e8b52fc5f4" and "6b493f11d7df84082b2a3173559ad8fad0b88a89" have entirely different histories.
89c0776045
...
6b493f11d7
|
@ -442,12 +442,10 @@ async function associateActors(mappedActors, releases) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await knex('releases_actors').insert(associations.filter(association => association).flat());
|
await Promise.all([
|
||||||
|
knex('releases_actors').insert(associations.filter(association => association).flat()),
|
||||||
// basic actor scraping is failure prone, don't together with actor association
|
scrapeBasicActors(),
|
||||||
// await scrapebasicactors(),
|
]);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
16
src/media.js
16
src/media.js
|
@ -37,8 +37,7 @@ function pluckPhotos(photos, specifiedLimit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createThumbnail(buffer) {
|
async function createThumbnail(buffer) {
|
||||||
try {
|
return sharp(buffer)
|
||||||
const thumbnail = sharp(buffer)
|
|
||||||
.resize({
|
.resize({
|
||||||
height: config.media.thumbnailSize,
|
height: config.media.thumbnailSize,
|
||||||
withoutEnlargement: true,
|
withoutEnlargement: true,
|
||||||
|
@ -47,12 +46,6 @@ async function createThumbnail(buffer) {
|
||||||
quality: config.media.thumbnailQuality,
|
quality: config.media.thumbnailQuality,
|
||||||
})
|
})
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
return thumbnail;
|
|
||||||
} catch (error) {
|
|
||||||
logger.error(`Failed to create thumbnail: ${error.message}`);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createMediaDirectory(domain, subpath) {
|
async function createMediaDirectory(domain, subpath) {
|
||||||
|
@ -145,7 +138,6 @@ async function savePhotos(files, {
|
||||||
naming = 'index',
|
naming = 'index',
|
||||||
}) {
|
}) {
|
||||||
return Promise.map(files, async (file, index) => {
|
return Promise.map(files, async (file, index) => {
|
||||||
try {
|
|
||||||
const timestamp = new Date().getTime();
|
const timestamp = new Date().getTime();
|
||||||
const thumbnail = await createThumbnail(file.photo);
|
const thumbnail = await createThumbnail(file.photo);
|
||||||
|
|
||||||
|
@ -167,10 +159,6 @@ async function savePhotos(files, {
|
||||||
filepath,
|
filepath,
|
||||||
thumbpath,
|
thumbpath,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
|
||||||
logger.error(`Failed to store ${domain} ${role} to ${subpath}: ${error.message}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +193,7 @@ async function storePhotos(photos, {
|
||||||
naming,
|
naming,
|
||||||
});
|
});
|
||||||
|
|
||||||
const curatedPhotoEntries = curatePhotoEntries(savedPhotos.filter(Boolean), domain, role, targetId);
|
const curatedPhotoEntries = curatePhotoEntries(savedPhotos, domain, role, targetId);
|
||||||
|
|
||||||
const newPhotos = await knex('media').insert(curatedPhotoEntries).returning('*');
|
const newPhotos = await knex('media').insert(curatedPhotoEntries).returning('*');
|
||||||
const photoEntries = Array.isArray(newPhotos)
|
const photoEntries = Array.isArray(newPhotos)
|
||||||
|
|
|
@ -8,7 +8,7 @@ const knex = require('./knex');
|
||||||
const argv = require('./argv');
|
const argv = require('./argv');
|
||||||
const whereOr = require('./utils/where-or');
|
const whereOr = require('./utils/where-or');
|
||||||
const { associateTags } = require('./tags');
|
const { associateTags } = require('./tags');
|
||||||
const { associateActors, scrapeBasicActors } = require('./actors');
|
const { associateActors } = require('./actors');
|
||||||
const {
|
const {
|
||||||
createMediaDirectory,
|
createMediaDirectory,
|
||||||
storePhotos,
|
storePhotos,
|
||||||
|
@ -425,8 +425,6 @@ async function storeReleases(releases) {
|
||||||
storeReleaseAssets(storedReleases),
|
storeReleaseAssets(storedReleases),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await scrapeBasicActors(),
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
releases: storedReleases,
|
releases: storedReleases,
|
||||||
actors,
|
actors,
|
||||||
|
|
|
@ -131,11 +131,7 @@ async function scrapeScene(html, url, site) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchLatest(site, page = 1) {
|
async function fetchLatest(site, page = 1) {
|
||||||
console.time('dogfart');
|
|
||||||
console.log('scraping...', site.name);
|
|
||||||
const res = await bhttp.get(`https://dogfartnetwork.com/tour/scenes/?p=${page}`);
|
const res = await bhttp.get(`https://dogfartnetwork.com/tour/scenes/?p=${page}`);
|
||||||
console.timeEnd('dogfart');
|
|
||||||
console.log('done!', site.name);
|
|
||||||
|
|
||||||
return scrapeLatest(res.body.toString(), site);
|
return scrapeLatest(res.body.toString(), site);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue