Added Private scraper. Added Vixen scraper to repository.
This commit is contained in:
90
src/scrapers/vixen.js
Normal file
90
src/scrapers/vixen.js
Normal file
@@ -0,0 +1,90 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint-disable */
|
||||
const bhttp = require('bhttp');
|
||||
const cheerio = require('cheerio');
|
||||
const moment = require('moment');
|
||||
|
||||
const { matchTags } = require('../tags');
|
||||
|
||||
function scrapeLatest(html, site) {
|
||||
const $ = cheerio.load(html, { normalizeWhitespace: true });
|
||||
|
||||
const stateObject = $('script:contains("INITIAL_STATE")');
|
||||
const { videos: scenes } = JSON.parse(stateObject.html().trim().slice(27, -1));
|
||||
|
||||
return scenes.map((scene) => {
|
||||
const shootId = scene.newId;
|
||||
const title = scene.title;
|
||||
const url = `${site.url}${scene.targetUrl}`;
|
||||
const date = moment.utc(scene.releaseDateFormatted, 'MMMM DD, YYYY').toDate();
|
||||
const actors = scene.models;
|
||||
const stars = Number(scene.textRating) / 2;
|
||||
|
||||
return {
|
||||
url,
|
||||
shootId,
|
||||
title,
|
||||
actors,
|
||||
date,
|
||||
rating: {
|
||||
stars,
|
||||
},
|
||||
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 scene = data.page.data[`${pathname}${search}`].data.video;
|
||||
|
||||
const shootId = scene.newId;
|
||||
const title = scene.title;
|
||||
const date = new Date(scene.releaseDate);
|
||||
const actors = scene.models;
|
||||
const stars = scene.totalRateVal;
|
||||
|
||||
const rawTags = scene.tags;
|
||||
const tags = await matchTags(rawTags);
|
||||
|
||||
const duration = scene.runLength;
|
||||
const director = scene.directorNames;
|
||||
|
||||
return {
|
||||
url,
|
||||
shootId,
|
||||
title,
|
||||
actors,
|
||||
director,
|
||||
date,
|
||||
duration,
|
||||
tags,
|
||||
rating: {
|
||||
stars,
|
||||
},
|
||||
site,
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchLatest(site) {
|
||||
const res = await bhttp.get(`${site.url}/videos`);
|
||||
|
||||
return scrapeLatest(res.body.toString(), site);
|
||||
}
|
||||
|
||||
async function fetchScene(url, site) {
|
||||
const res = await bhttp.get(url);
|
||||
|
||||
return scrapeScene(res.body.toString(), url, site);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchLatest,
|
||||
fetchScene,
|
||||
};
|
||||
Reference in New Issue
Block a user