Only curating release ID when present.
This commit is contained in:
parent
682f299c8f
commit
7723b2b698
|
@ -48,7 +48,7 @@ function scrapeScene({ query }, url, channel) {
|
|||
release.director = query.cnt('.director')?.split(/\s*:\s*/)[1];
|
||||
|
||||
const fallbackPoster = query.img('.player img');
|
||||
release.poster = query.sourceSet('.player img', 'data-srcset') || [fallbackPoster.replace('_crop', ''), fallbackPoster];
|
||||
release.poster = query.sourceSet('.player img', 'data-srcset') || [fallbackPoster?.replace('_crop', ''), fallbackPoster];
|
||||
|
||||
const movieUrl = query.url('.movie a', 'href', { origin: channel.url });
|
||||
|
||||
|
@ -173,7 +173,7 @@ async function fetchMovies(channel, page = 1) {
|
|||
Referer: 'https://www.dorcelclub.com/en/porn-movie?sorting=new', // might be used to derive sorting
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
if (res.ok && res.items) {
|
||||
return scrapeMovies(res.items, channel);
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ async function fetchMovie(url, channel) {
|
|||
Referer: `${channel.url}/en/porn-movie`,
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
if (res.ok && res.item) {
|
||||
return scrapeMovie(res.item, url, channel);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
|
|||
});
|
||||
|
||||
const curatedRelease = {
|
||||
id: release.id, // release is updated
|
||||
title: decode(release.title),
|
||||
entry_id: release.entryId || null,
|
||||
entity_id: release.entity.id,
|
||||
|
@ -46,6 +45,11 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
|
|||
updated_batch_id: batchId,
|
||||
};
|
||||
|
||||
if (release.id) {
|
||||
// release is updated
|
||||
curatedRelease.id = release.id;
|
||||
}
|
||||
|
||||
if (type === 'scene') {
|
||||
curatedRelease.shoot_id = release.shootId || null;
|
||||
curatedRelease.production_date = Number(release.productionDate) ? release.productionDate : null;
|
||||
|
@ -474,8 +478,6 @@ async function storeScenes(releases, useBatchId) {
|
|||
const curatedDuplicateReleases = await Promise.all(duplicateReleasesWithId.map((release) => curateReleaseEntry(release, batchId)));
|
||||
const releasesWithId = uniqueReleasesWithId.concat(duplicateReleasesWithId);
|
||||
|
||||
console.log(curatedDuplicateReleases);
|
||||
|
||||
const updated = await knex.raw(`
|
||||
UPDATE releases
|
||||
SET url = COALESCE(new.url, releases.url),
|
||||
|
|
Loading…
Reference in New Issue