Refactored database to separate IDs from slugs
This commit is contained in:
@@ -13,7 +13,7 @@ const { argv } = yargs
|
||||
.option('deep', {
|
||||
describe: 'Fetch details for all releases',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
default: true,
|
||||
})
|
||||
.option('networks', {
|
||||
describe: 'Networks to include (overrides config)',
|
||||
@@ -33,7 +33,7 @@ const { argv } = yargs
|
||||
.option('save', {
|
||||
describe: 'Save fetched releases to database',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
default: true,
|
||||
})
|
||||
.option('render', {
|
||||
describe: 'Fetch data without rendering interface',
|
||||
|
||||
@@ -77,6 +77,23 @@ async function findDuplicateReleases(latestReleases, _siteId) {
|
||||
.orWhereIn('entry_id', latestReleasesEntryIds);
|
||||
}
|
||||
|
||||
async function storePhotos(release, releaseEntry) {
|
||||
const photoPath = path.join(config.photoPath, release.site.id, releaseEntry.rows[0].id.toString());
|
||||
|
||||
await fs.mkdir(photoPath, { recursive: true });
|
||||
|
||||
console.log(`Storing photos for (${release.site.name}, ${release.id}) "${release.title}"`);
|
||||
|
||||
await Promise.map(release.photos, async (photoUrl, index) => {
|
||||
const res = await bhttp.get(photoUrl);
|
||||
await fs.writeFile(path.join(photoPath, `${index + 1}.jpg`), res.body);
|
||||
|
||||
return photoUrl;
|
||||
}, {
|
||||
concurrency: 2,
|
||||
});
|
||||
}
|
||||
|
||||
async function storeReleases(releases = []) {
|
||||
return Promise.map(releases, async (release) => {
|
||||
const curatedRelease = {
|
||||
@@ -121,20 +138,7 @@ async function storeReleases(releases = []) {
|
||||
}
|
||||
|
||||
if (release.photos && release.photos.length > 0) {
|
||||
const photoPath = path.join(config.photoPath, release.site.id, releaseEntry.rows[0].id.toString());
|
||||
|
||||
await fs.mkdir(photoPath, { recursive: true });
|
||||
|
||||
console.log(`Storing photos for (${release.site.name}, ${release.id}) "${release.title}"`);
|
||||
|
||||
await Promise.map(release.photos, async (photoUrl, index) => {
|
||||
const res = await bhttp.get(photoUrl);
|
||||
await fs.writeFile(path.join(photoPath, `${index + 1}.jpg`), res.body);
|
||||
|
||||
return photoUrl;
|
||||
}, {
|
||||
concurrency: 2,
|
||||
});
|
||||
await storePhotos(release, releaseEntry);
|
||||
}
|
||||
}, {
|
||||
concurrency: 2,
|
||||
|
||||
@@ -52,7 +52,7 @@ async function scrapeScene(html, url, shootId, ratingRes, site) {
|
||||
const title = $('h1.shoot-title span.favorite-button').attr('data-title');
|
||||
const actorsRaw = $('.shoot-info p.starring');
|
||||
|
||||
const photos = $('.gallery .thumb img').map((photoIndex, photoElement) => `https://cdnp.kink.com${$(photoElement).attr('data-image-file')}`).toArray();
|
||||
const photos = $('.gallery .thumb img').map((photoIndex, photoElement) => $(photoElement).attr('data-image-file')).toArray();
|
||||
const trailerVideo = $('.player span[data-type="trailer-src"]').attr('data-url');
|
||||
const trailerPoster = $('.player video#kink-player').attr('poster');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user