Added Diabolic and Cum Louder, added content type expect option to media sources to fix Vixen thumbnails.

This commit is contained in:
DebaucheryLibrarian
2021-08-09 10:31:12 +02:00
parent 65c3053b49
commit a848d6991b
259 changed files with 880 additions and 15825 deletions

View File

@@ -22,7 +22,13 @@ function getPosterFallbacks(poster) {
// high DPI images for full HD source are huge, only prefer for smaller fallback sources
return image.height === 1080 ? sources : sources.reverse();
})
.flat();
.flat()
.map(src => ({
src,
expectType: {
'binary/octet-stream': 'image/jpeg',
},
}));
}
function getTeaserFallbacks(teaser) {
@@ -135,6 +141,26 @@ async function getTrailer(scene, channel, url) {
return null;
}
async function getPhotos(url) {
const htmlRes = await http.get(url, {
extract: {
runScripts: 'dangerously',
},
});
const state = htmlRes?.window.__APOLLO_STATE__;
const key = Object.values(state.ROOT_QUERY).find(query => query?.__ref)?.__ref;
const data = state[key];
console.log(data);
if (!data) {
return [];
}
return data.carousel.slice(1).map(photo => photo.main?.[0].src).filter(Boolean);
}
function scrapeAll(scenes, site, origin) {
return scenes.map((scene) => {
const release = {};
@@ -183,7 +209,7 @@ function scrapeUpcoming(scene, site) {
return [release];
}
async function scrapeScene(data, url, site, baseRelease) {
async function scrapeScene(data, url, site, baseRelease, options) {
const scene = data.video;
const release = {
@@ -206,7 +232,11 @@ async function scrapeScene(data, url, site, baseRelease) {
release.actors = baseRelease?.actors || scene.models;
release.poster = getPosterFallbacks(scene.images.poster);
release.photos = data.pictureset.map(photo => photo.main[0].src);
// release.photos = data.pictureset.map(photo => photo.main[0]?.src).filter(Boolean);
if (options.includePhotos) {
release.photos = await getPhotos(url);
}
release.teaser = getTeaserFallbacks(scene.previews.poster);
@@ -300,15 +330,19 @@ async function fetchUpcoming(site) {
return res.status;
}
async function fetchScene(url, site, baseRelease) {
async function fetchScene(url, site, baseRelease, options) {
const { origin, pathname } = new URL(url);
const apiUrl = `${origin}/api/${pathname.split('/').slice(-1)[0]}`;
const res = await http.get(apiUrl);
const res = await http.get(apiUrl, {
extract: {
runScripts: 'dangerously',
},
});
if (res.ok) {
if (res.body.data) {
return scrapeScene(res.body.data, url, site, baseRelease);
return scrapeScene(res.body.data, url, site, baseRelease, options);
}
return null;