From 164681427afb43a703920d76d4f50a4c15fe3191 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Sun, 23 Feb 2020 22:37:14 +0100 Subject: [PATCH] Fixed Kelly Madison posters, marking frontpage video as teaser. --- src/scrapers/kellymadison.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/scrapers/kellymadison.js b/src/scrapers/kellymadison.js index 7dcfaa22..50c99aca 100644 --- a/src/scrapers/kellymadison.js +++ b/src/scrapers/kellymadison.js @@ -50,8 +50,8 @@ function scrapeLatest(html, site) { const durationString = durationEl.textContent.match(/\d+ min/); if (durationString) release.duration = Number(durationString[0].match(/\d+/)[0]) * 60; - release.poster = scene.querySelector('.card-img-top').src; - release.trailer = { + release.poster = scene.querySelector('.card-img-top').dataset.src; + release.teaser = { src: scene.querySelector('video').src, }; @@ -59,14 +59,14 @@ function scrapeLatest(html, site) { }).filter(scene => scene); } -function scrapeScene(html, url, site, shallowRelease) { +function scrapeScene(html, url, site, baseRelease) { const { document } = new JSDOM(html).window; const release = { url, site }; const titleEl = document.querySelector('.card-header.row h4').childNodes; const titleString = extractTextNode(titleEl); - if (!shallowRelease) [release.entryId] = url.match(/\d+/); + if (!baseRelease) [release.entryId] = url.match(/\d+/); release.title = titleString .replace('Trailer: ', '') @@ -107,9 +107,11 @@ function scrapeScene(html, url, site, shallowRelease) { quality: resolutions[index], })); - release.photos = [document.body.innerHTML - .match(/poster: .*\.jpg/)[0] - .match(/https:\/\/.*\.jpg/)[0]]; + const posterPrefix = html.indexOf('poster:'); + const poster = html.slice(html.indexOf('http', posterPrefix), html.indexOf('.jpg', posterPrefix) + 4); + + if (baseRelease?.poster) release.photos = [poster]; + else release.poster = poster; return release; } @@ -154,7 +156,7 @@ async function fetchLatest(site, page = 1) { return null; } -async function fetchScene(url, site, shallowRelease) { +async function fetchScene(url, site, baseRelease) { const { pathname } = new URL(url); const res = await bhttp.get(`https://www.kellymadison.com${pathname}`, { @@ -163,7 +165,7 @@ async function fetchScene(url, site, shallowRelease) { }, }); - return scrapeScene(res.body.toString(), url, site, shallowRelease); + return scrapeScene(res.body.toString(), url, site, baseRelease); } async function fetchProfile(actorName) {