Changed profile network argument to context.

This commit is contained in:
DebaucheryLibrarian 2021-02-03 00:50:00 +01:00
parent a19f235684
commit 824fb9ef37
1 changed files with 5 additions and 5 deletions

View File

@ -286,9 +286,9 @@ async function fetchScene(url, site, baseScene) {
return null; return null;
} }
async function fetchProfile({ name: actorName }, networkOrNetworkSlug) { async function fetchProfile({ name: actorName }, { entity }) {
// const url = `https://www.${networkOrNetworkSlug.slug || networkOrNetworkSlug}.com`; // const url = `https://www.${networkOrNetworkSlug.slug || networkOrNetworkSlug}.com`;
const { session, instanceToken } = await getSession(networkOrNetworkSlug); const { session, instanceToken } = await getSession(entity);
const res = await http.get(`https://site-api.project1service.com/v1/actors/?search=${encodeURI(actorName)}`, { const res = await http.get(`https://site-api.project1service.com/v1/actors/?search=${encodeURI(actorName)}`, {
session, session,
@ -301,7 +301,7 @@ async function fetchProfile({ name: actorName }, networkOrNetworkSlug) {
const actorData = res.body.result.find(actor => actor.name.toLowerCase() === actorName.toLowerCase()); const actorData = res.body.result.find(actor => actor.name.toLowerCase() === actorName.toLowerCase());
if (actorData) { if (actorData) {
const actorUrl = `https://www.${networkOrNetworkSlug.slug || networkOrNetworkSlug}.com/${networkOrNetworkSlug?.parameters?.actorPath || 'model'}/${actorData.id}/`; const actorUrl = `https://www.${entity.slug}.com/${entity.parameters?.actorPath || 'model'}/${actorData.id}/`;
const actorReleasesUrl = `https://site-api.project1service.com/v2/releases?actorId=${actorData.id}&limit=100&offset=0&orderBy=-dateReleased&type=scene`; const actorReleasesUrl = `https://site-api.project1service.com/v2/releases?actorId=${actorData.id}&limit=100&offset=0&orderBy=-dateReleased&type=scene`;
const [actorRes, actorReleasesRes] = await Promise.all([ const [actorRes, actorReleasesRes] = await Promise.all([
@ -315,11 +315,11 @@ async function fetchProfile({ name: actorName }, networkOrNetworkSlug) {
]); ]);
if (actorRes.statusCode === 200 && actorReleasesRes.statusCode === 200 && actorReleasesRes.body.result) { if (actorRes.statusCode === 200 && actorReleasesRes.statusCode === 200 && actorReleasesRes.body.result) {
return scrapeProfile(actorData, actorRes.body.toString(), actorReleasesRes.body.result, networkOrNetworkSlug.slug || networkOrNetworkSlug); return scrapeProfile(actorData, actorRes.body.toString(), actorReleasesRes.body.result, entity.slug);
} }
if (actorRes.statusCode === 200) { if (actorRes.statusCode === 200) {
return scrapeProfile(actorData, actorRes.body.toString(), null, networkOrNetworkSlug.slug || networkOrNetworkSlug); return scrapeProfile(actorData, actorRes.body.toString(), null, entity.slug);
} }
} }
} }