Renamed chapters to clips. Fixed Vixen trailers.
This commit is contained in:
@@ -38,7 +38,7 @@ function scrapeScene({ query, html }, url, channel) {
|
||||
|
||||
release.poster = qu.prefixUrl(html.match(/background-image: url\('(.*)'\)/)?.[1], channel.url);
|
||||
|
||||
release.chapters = query.all('.ClipOuter').map((el) => {
|
||||
release.clips = query.all('.ClipOuter').map((el) => {
|
||||
const chapter = {};
|
||||
|
||||
chapter.title = query.text(el, 'h4');
|
||||
|
||||
@@ -49,7 +49,10 @@ async function getTrailer(scene, site, url) {
|
||||
file: scene.previewVideoUrl1080P,
|
||||
sizes: qualities.join('+'),
|
||||
type: 'trailer',
|
||||
}, { referer: url });
|
||||
}, {
|
||||
referer: url,
|
||||
origin: site.url,
|
||||
});
|
||||
|
||||
if (!tokenRes.ok) {
|
||||
return null;
|
||||
|
||||
@@ -243,44 +243,44 @@ async function updateReleasesSearch(releaseIds) {
|
||||
}
|
||||
}
|
||||
|
||||
async function storeChapters(releases) {
|
||||
const chapters = releases.map(release => release.chapters?.map((chapter, index) => ({
|
||||
title: chapter.title,
|
||||
description: chapter.description,
|
||||
async function storeClips(releases) {
|
||||
const clips = releases.map(release => release.clips?.map((clip, index) => ({
|
||||
title: clip.title,
|
||||
description: clip.description,
|
||||
releaseId: release.id,
|
||||
chapter: index + 1,
|
||||
duration: chapter.duration,
|
||||
poster: chapter.poster,
|
||||
photos: chapter.photos,
|
||||
tags: chapter.tags,
|
||||
clip: index + 1,
|
||||
duration: clip.duration,
|
||||
poster: clip.poster,
|
||||
photos: clip.photos,
|
||||
tags: clip.tags,
|
||||
}))).flat().filter(Boolean);
|
||||
|
||||
const curatedChapterEntries = chapters.map(chapter => ({
|
||||
title: chapter.title,
|
||||
description: chapter.description,
|
||||
duration: chapter.duration,
|
||||
release_id: chapter.releaseId,
|
||||
chapter: chapter.chapter,
|
||||
const curatedClipEntries = clips.map(clip => ({
|
||||
title: clip.title,
|
||||
description: clip.description,
|
||||
duration: clip.duration,
|
||||
release_id: clip.releaseId,
|
||||
clip: clip.clip,
|
||||
}));
|
||||
|
||||
const storedChapters = await bulkInsert('chapters', curatedChapterEntries);
|
||||
const chapterIdsByReleaseIdAndChapter = storedChapters.reduce((acc, chapter) => ({
|
||||
const storedClips = await bulkInsert('clips', curatedClipEntries);
|
||||
const clipIdsByReleaseIdAndClip = storedClips.reduce((acc, clip) => ({
|
||||
...acc,
|
||||
[chapter.release_id]: {
|
||||
...acc[chapter.release_id],
|
||||
[chapter.chapter]: chapter.id,
|
||||
[clip.release_id]: {
|
||||
...acc[clip.release_id],
|
||||
[clip.clip]: clip.id,
|
||||
},
|
||||
}), {});
|
||||
|
||||
const chaptersWithId = chapters.map(chapter => ({
|
||||
...chapter,
|
||||
id: chapterIdsByReleaseIdAndChapter[chapter.releaseId][chapter.chapter],
|
||||
const clipsWithId = clips.map(clip => ({
|
||||
...clip,
|
||||
id: clipIdsByReleaseIdAndClip[clip.releaseId][clip.clip],
|
||||
}));
|
||||
|
||||
await associateReleaseTags(chaptersWithId, 'chapter');
|
||||
await associateReleaseTags(clipsWithId, 'clip');
|
||||
|
||||
// media is more error-prone, associate separately
|
||||
await associateReleaseMedia(chaptersWithId, 'chapter');
|
||||
await associateReleaseMedia(clipsWithId, 'clip');
|
||||
}
|
||||
|
||||
async function storeScenes(releases) {
|
||||
@@ -318,7 +318,7 @@ async function storeScenes(releases) {
|
||||
await scrapeActors(actors.map(actor => actor.name));
|
||||
}
|
||||
|
||||
await storeChapters(releasesWithId);
|
||||
await storeClips(releasesWithId);
|
||||
|
||||
logger.info(`Stored ${storedReleaseEntries.length} releases`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user