Scraping scene photos from Bang API.

This commit is contained in:
DebaucheryLibrarian 2021-02-04 22:55:19 +01:00
parent 4594dbc763
commit f217b161b4
12 changed files with 39 additions and 15 deletions

View File

@ -402,9 +402,9 @@ function showAlbum() {
} }
async function watchRoute(to, from) { async function watchRoute(to, from) {
if (to.params.pageNumber !== from.params.pageNumber) { console.log(to, from);
await this.fetchActor();
} await this.fetchActor();
} }
async function mounted() { async function mounted() {

BIN
public/img/tags/bts/3.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/img/tags/bts/3b.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -597,7 +597,7 @@ const tagPosters = [
['atm', 2, 'Jureka Del Mar in "Stretched Out" for Her Limit'], ['atm', 2, 'Jureka Del Mar in "Stretched Out" for Her Limit'],
['atogm', 0, 'Alysa Gap and Logan in "Anal Buffet 4" for Evil Angel'], ['atogm', 0, 'Alysa Gap and Logan in "Anal Buffet 4" for Evil Angel'],
['bdsm', 0, 'Dani Daniels in "The Traning of Dani Daniels, Day 2" for The Training of O at Kink'], ['bdsm', 0, 'Dani Daniels in "The Traning of Dani Daniels, Day 2" for The Training of O at Kink'],
['bts', 2, 'Christy Mack for Digital Playground'], ['bts', '3b', 'Brenna Sparks for Bang! Confessions'],
['blindfold', 0, 'Kylie Page in "Natural Blindfolded Beauties" for Hustler'], ['blindfold', 0, 'Kylie Page in "Natural Blindfolded Beauties" for Hustler'],
['blonde', 1, 'Marsha May in "Once You Go Black 7" for Jules Jordan'], ['blonde', 1, 'Marsha May in "Once You Go Black 7" for Jules Jordan'],
['blowbang', 0, 'Lacy Lennon in "Lacy Lennon\'s First Blowbang" for HardX'], ['blowbang', 0, 'Lacy Lennon in "Lacy Lennon\'s First Blowbang" for HardX'],
@ -717,6 +717,7 @@ const tagPhotos = [
['anal-fingering', 2, 'Aidra Fox and Cassidy Klein in "Lesbian Anal Yoga" for LesbianX'], ['anal-fingering', 2, 'Aidra Fox and Cassidy Klein in "Lesbian Anal Yoga" for LesbianX'],
['bts', 0, 'Janice Griffith in "Day With A Pornstar: Janice" for Brazzers'], ['bts', 0, 'Janice Griffith in "Day With A Pornstar: Janice" for Brazzers'],
['bts', 1, 'Madison Ivy in "Day With A Pornstar" for Brazzers'], ['bts', 1, 'Madison Ivy in "Day With A Pornstar" for Brazzers'],
['bts', 2, 'Christy Mack for Digital Playground'],
['blonde', 4, 'Marry Queen for Babespotting.tv'], ['blonde', 4, 'Marry Queen for Babespotting.tv'],
['blonde', 3, 'Kylie Page in "A Juicy Afternoon Delight" for New Sensations'], ['blonde', 3, 'Kylie Page in "A Juicy Afternoon Delight" for New Sensations'],
['blonde', 2, 'Isabelle Deltore for Her Limit'], ['blonde', 2, 'Isabelle Deltore for Her Limit'],

View File

@ -146,7 +146,7 @@ const { argv } = yargs
describe: 'Limit amount of scenes when dates are missing.', describe: 'Limit amount of scenes when dates are missing.',
type: 'number', type: 'number',
default: config.missingDateLimit, default: config.missingDateLimit,
alias: ['null-date-limit', 'limit'], alias: ['null-date-limit'],
}) })
.option('page', { .option('page', {
describe: 'Page to start scraping at', describe: 'Page to start scraping at',

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const http = require('../utils/http'); const http = require('../utils/http');
const qu = require('../utils/qu');
const { extractDate } = require('../utils/qu'); const { extractDate } = require('../utils/qu');
const { inchesToCm } = require('../utils/convert'); const { inchesToCm } = require('../utils/convert');
const slugify = require('../utils/slugify'); const slugify = require('../utils/slugify');
@ -37,7 +38,23 @@ function decodeId(id) {
.toString('hex'); .toString('hex');
} }
function scrapeScene(scene) { async function fetchPhotos(scene) {
const photoPaths = Array.from({ length: scene.photos }, (value, index) => `/${scene.dvd.id}/${scene.identifier}/final/${String(index + 1).padStart(6, '0')}.jpg`);
const res = await http.post('https://www.bang.com/sign-images', {
images: photoPaths,
}, {
encodeJSON: false,
});
if (res.ok) {
return res.body.images.map(image => qu.prefixUrl(image, 'https://photos.bang.com'));
}
return null;
}
async function scrapeScene(scene, entity, options) {
const release = { const release = {
entryId: scene.id, entryId: scene.id,
title: scene.name, title: scene.name,
@ -58,17 +75,23 @@ function scrapeScene(scene) {
if (scene.gay) release.tags.push('gay'); if (scene.gay) release.tags.push('gay');
const defaultPoster = scene.screenshots.find(photo => photo.default === true); const defaultPoster = scene.screenshots.find(photo => photo.default === true);
const photoset = scene.screenshots.filter(photo => photo.default === false); const screens = scene.screenshots.filter(photo => photo.default === false);
const photos = defaultPoster ? photoset : photoset.slice(1); const remainingScreens = defaultPoster ? screens : screens.slice(1);
const poster = defaultPoster || photoset[0]; const poster = defaultPoster || screens[0];
release.poster = getScreenUrl(poster, scene); release.poster = getScreenUrl(poster, scene);
release.photos = photos.map(photo => getScreenUrl(photo, scene)); release.photos = remainingScreens.map(photo => getScreenUrl(photo, scene));
release.trailer = { if (options.includePhotos) {
src: `https://i.bang.com/v/${scene.dvd.id}/${scene.identifier}/preview.mp4`, const photos = await fetchPhotos(scene);
};
if (photos?.length > 0) {
release.photos = photos;
}
}
release.trailer = `https://i.bang.com/v/${scene.dvd.id}/${scene.identifier}/preview.mp4`;
release.channel = scene.series.name release.channel = scene.series.name
.replace(/[! .]/g, '') .replace(/[! .]/g, '')
@ -328,7 +351,7 @@ async function fetchUpcoming(site, page = 1) {
return scrapeAll(res.body.hits.hits, site); return scrapeAll(res.body.hits.hits, site);
} }
async function fetchScene(url) { async function fetchScene(url, entity, baseRelease, options) {
const encodedId = new URL(url).pathname.split('/')[2]; const encodedId = new URL(url).pathname.split('/')[2];
const entryId = decodeId(encodedId); const entryId = decodeId(encodedId);
@ -338,7 +361,7 @@ async function fetchScene(url) {
}, },
}); });
return scrapeScene(res.body._source); // eslint-disable-line no-underscore-dangle return scrapeScene(res.body._source, entity, options); // eslint-disable-line no-underscore-dangle
} }
async function fetchProfile({ name: actorName }, context, include) { async function fetchProfile({ name: actorName }, context, include) {