Fixed wrong MindGeek session acquire URL.

This commit is contained in:
DebaucheryLibrarian 2020-09-18 03:27:00 +02:00
parent 38b90b3d4c
commit 3c9468b0f1
3 changed files with 16 additions and 9 deletions

View File

@ -130,6 +130,9 @@ const networks = [
url: 'https://www.brazzers.com', url: 'https://www.brazzers.com',
description: 'Brazzers homepage is updated daily with official HD porn scenes. Our hottest videos and sex series are filled with big tits, sexy milf, top pornstars and special events.', description: 'Brazzers homepage is updated daily with official HD porn scenes. Our hottest videos and sex series are filled with big tits, sexy milf, top pornstars and special events.',
parent: 'mindgeek', parent: 'mindgeek',
parameters: {
childSession: true,
},
}, },
{ {
slug: 'boobpedia', slug: 'boobpedia',

View File

@ -19,7 +19,7 @@ function curateEntity(entity, includeParameters = false) {
slug: entity.slug, slug: entity.slug,
type: entity.type, type: entity.type,
parameters: includeParameters ? entity.parameters : null, parameters: includeParameters ? entity.parameters : null,
parent: curateEntity(entity.parent), parent: curateEntity(entity.parent, includeParameters),
} : {}; } : {};
if (entity.children) { if (entity.children) {

View File

@ -143,15 +143,19 @@ function getUrl(site) {
throw new Error(`Mind Geek site '${site.name}' (${site.url}) not supported`); throw new Error(`Mind Geek site '${site.name}' (${site.url}) not supported`);
} }
async function getSession(url, site) { async function getSession(site) {
const cookieJar = new CookieJar(); const cookieJar = new CookieJar();
const session = bhttp.session({ cookieJar }); const session = bhttp.session({ cookieJar });
// const res = await session.get(url); // const res = await session.get(url);
const res = await session.get(site.parameters?.siteId ? site.parent.url : site.url); const sessionUrl = site.parameters?.siteId && !(site.parameters?.childSession || site.parent?.parameters?.childSession)
? site.parent.url
: site.url;
const res = await session.get(sessionUrl);
if (res.statusCode === 200) { if (res.statusCode === 200) {
const cookieString = await cookieJar.getCookieStringAsync(url); const cookieString = await cookieJar.getCookieStringAsync(sessionUrl);
const { instance_token: instanceToken } = cookieToData(cookieString); const { instance_token: instanceToken } = cookieToData(cookieString);
return { session, instanceToken }; return { session, instanceToken };
@ -203,7 +207,7 @@ async function fetchLatest(site, page = 1) {
const { searchParams } = new URL(url); const { searchParams } = new URL(url);
const siteId = searchParams.get('site'); const siteId = searchParams.get('site');
const { session, instanceToken } = await getSession(url, site); const { session, instanceToken } = await getSession(site);
const beforeDate = moment().add('1', 'day').format('YYYY-MM-DD'); const beforeDate = moment().add('1', 'day').format('YYYY-MM-DD');
const limit = 10; const limit = 10;
@ -228,7 +232,7 @@ async function fetchLatest(site, page = 1) {
async function fetchUpcoming(site) { async function fetchUpcoming(site) {
const url = getUrl(site); const url = getUrl(site);
const { session, instanceToken } = await getSession(url, site); const { session, instanceToken } = await getSession(site);
const apiUrl = 'https://site-api.project1service.com/v2/upcoming-releases'; const apiUrl = 'https://site-api.project1service.com/v2/upcoming-releases';
@ -254,7 +258,7 @@ async function fetchScene(url, site, baseScene) {
} }
const entryId = url.match(/\d+/)[0]; const entryId = url.match(/\d+/)[0];
const { session, instanceToken } = await getSession(url, site); const { session, instanceToken } = await getSession(site);
const res = await session.get(`https://site-api.project1service.com/v2/releases/${entryId}`, { const res = await session.get(`https://site-api.project1service.com/v2/releases/${entryId}`, {
headers: { headers: {
@ -270,8 +274,8 @@ async function fetchScene(url, site, baseScene) {
} }
async function fetchProfile({ name: actorName }, networkOrNetworkSlug, actorPath = 'model') { async function fetchProfile({ name: actorName }, networkOrNetworkSlug, actorPath = 'model') {
const url = `https://www.${networkOrNetworkSlug.slug || networkOrNetworkSlug}.com`; // const url = `https://www.${networkOrNetworkSlug.slug || networkOrNetworkSlug}.com`;
const { session, instanceToken } = await getSession(url, networkOrNetworkSlug); const { session, instanceToken } = await getSession(networkOrNetworkSlug);
const res = await session.get(`https://site-api.project1service.com/v1/actors/?search=${encodeURI(actorName)}`, { const res = await session.get(`https://site-api.project1service.com/v1/actors/?search=${encodeURI(actorName)}`, {
headers: { headers: {