From 4e4323704ac2fb7abbbe9b9cf72e3a5746aa31fa Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Sat, 18 Jan 2020 23:10:31 +0100 Subject: [PATCH] Getting more and higher quality Vixen photos. --- config/default.js | 1 + src/media.js | 2 +- src/scrapers/vixen.js | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config/default.js b/config/default.js index ed84e228..02aad849 100644 --- a/config/default.js +++ b/config/default.js @@ -43,6 +43,7 @@ module.exports = { media: { path: './', thumbnailSize: 320, // width for 16:9 will be exactly 576px + thumbnailQuality: 90, limit: 25, // max number of photos per release }, }; diff --git a/src/media.js b/src/media.js index 374e9f27..7deac3cb 100644 --- a/src/media.js +++ b/src/media.js @@ -43,7 +43,7 @@ async function createThumbnail(buffer) { withoutEnlargement: true, }) .jpeg({ - quality: 75, + quality: config.media.thumbnailQuality, }) .toBuffer(); } diff --git a/src/scrapers/vixen.js b/src/scrapers/vixen.js index 78fff80f..5c40a809 100644 --- a/src/scrapers/vixen.js +++ b/src/scrapers/vixen.js @@ -60,15 +60,16 @@ function scrapeLatest(html, site) { async function scrapeScene(html, url, site) { const $ = cheerio.load(html, { normalizeWhitespace: true }); - const { pathname, search } = new URL(url); const stateObject = $('script:contains("INITIAL_STATE")'); const data = JSON.parse(stateObject.html().trim().slice(27, -1)); - const entryId = data.page.data[`${pathname}${search}`].data.video; + const pageData = data.page.data[data.location.pathname].data; + const entryId = pageData.video; const scene = data.videos.find(video => video.newId === entryId); - const [poster, ...photos] = scene.rotatingThumbsUrlSizes.map(photo => photo['1040w']); + const poster = scene.rotatingThumbsUrlSizes[0]['1040w']; + const photos = pageData.pictureset.map(photo => photo.main[0].src); const trailer = scene.previews.listing.find(preview => preview.height === 353) || null; const {