From eb50af7b81b2f0da2d3b7d72e322ae179f6c3409 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Tue, 29 Oct 2019 03:50:39 +0100 Subject: [PATCH] Added media support to Brazzers scraper. --- src/scrapers/brazzers.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/scrapers/brazzers.js b/src/scrapers/brazzers.js index 7d6aae1c..1d22f9e3 100644 --- a/src/scrapers/brazzers.js +++ b/src/scrapers/brazzers.js @@ -31,12 +31,17 @@ function scrape(html, site, upcoming) { const likes = Number($(element).find('.label-rating .like-amount').text()); const dislikes = Number($(element).find('.label-rating .dislike-amount').text()); + const poster = `https:${$(element).find('.card-main-img').attr('data-src')}`; + const photos = $(element).find('.card-overlay .image-under').map((photoIndex, photoElement) => `https:${$(photoElement).attr('data-src')}`).toArray(); + return acc.concat({ url, shootId, title, actors, date, + poster, + photos, rating: { likes, dislikes, @@ -48,6 +53,8 @@ function scrape(html, site, upcoming) { async function scrapeScene(html, url, site) { const $ = cheerio.load(html, { normalizeWhitespace: true }); + const videoJson = $('script:contains("window.videoUiOptions")').html(); + const videoData = JSON.parse(videoJson.slice(videoJson.indexOf('{"stream_info":'), videoJson.lastIndexOf('"},') + 2)); const shootId = url.split('/').slice(-3, -2)[0]; const title = $('.scene-title[itemprop="name"]').text(); @@ -71,6 +78,10 @@ async function scrapeScene(html, url, site) { const rawTags = $('.tag-card-container a').map((tagIndex, tagElement) => $(tagElement).text()).toArray(); + const poster = `https:${videoData.poster}`; + const trailer = `https:${videoData.stream_info.http.paths.mp4_480_1500}`; + const photos = $('.carousel-thumb a').map((photoIndex, photoElement) => `https:${$(photoElement).attr('href')}`).toArray(); + const [tags, channelSite] = await Promise.all([ matchTags(rawTags), knex('sites') @@ -86,6 +97,12 @@ async function scrapeScene(html, url, site) { description, actors, date, + poster, + photos, + trailer: { + src: trailer, + quality: 480, + }, duration, rating: { likes,