Fixed include object. Fixed qu's undefined URL handling.

This commit is contained in:
DebaucheryLibrarian
2020-09-08 03:26:34 +02:00
parent 7c6243cf33
commit 03ba35d65a
8 changed files with 24 additions and 14 deletions

View File

@@ -310,7 +310,7 @@ async function fetchActorReleases(profileUrl, getActorReleasesUrl, page = 1, acc
if (!res.ok) return [];
const releases = scrapeAll(res.item.html, null, origin);
const nextPage = res.item.qu.url('.Gamma_Paginator a.next');
const nextPage = res.item.query.url('.Gamma_Paginator a.next');
if (nextPage) {
return fetchActorReleases(profileUrl, getActorReleasesUrl, page + 1, accReleases.concat(releases));
@@ -434,8 +434,6 @@ async function fetchApiLatest(site, page = 1, preData, include, upcoming = false
encodeJSON: true,
});
console.log(page, res.statusCode, res.body.results);
if (res.statusCode === 200 && res.body.results?.[0]?.hits) {
return scrapeApiReleases(res.body.results[0].hits, site);
}
@@ -592,7 +590,7 @@ async function fetchProfile({ name: actorName }, context, altSearchUrl, getActor
return null;
}
async function fetchApiProfile(actorName, context, include) {
async function fetchApiProfile({ name: actorName }, context, include) {
const siteSlug = context.entity.slug || context.site?.slug || context.network?.slug;
const actorSlug = encodeURI(actorName);
@@ -600,7 +598,7 @@ async function fetchApiProfile(actorName, context, include) {
const { apiUrl } = await fetchApiCredentials(referer);
const res = await bhttp.post(apiUrl, {
const res = await http.post(apiUrl, {
requests: [
{
indexName: 'all_actors',
@@ -608,13 +606,12 @@ async function fetchApiProfile(actorName, context, include) {
},
],
}, {
headers: {
Referer: referer,
},
Referer: referer,
}, {
encodeJSON: true,
});
if (res.statusCode === 200 && res.body.results[0].hits.length > 0) {
if (res.status === 200 && res.body.results[0].hits.length > 0) {
const actorData = res.body.results[0].hits.find(actor => slugify(actor.name) === slugify(actorName));
if (actorData) {

View File

@@ -7,8 +7,8 @@ function include(argv) {
photos: argv.media && argv.photos,
poster: argv.media && argv.posters,
posters: argv.media && argv.posters,
releases: argv.withScenes,
scenes: argv.withScenes,
releases: argv.actorsScenes,
scenes: argv.actorsScenes,
teaser: argv.media && argv.videos && argv.teasers,
teasers: argv.media && argv.videos && argv.teasers,
trailer: argv.media && argv.videos && argv.trailers,

View File

@@ -40,6 +40,10 @@ function formatDate(dateValue, format, inputFormat) {
}
function prefixUrl(urlValue, origin, protocol = 'https') {
if (!urlValue) {
return null;
}
if (/^http/.test(urlValue)) {
return urlValue;
}
@@ -52,7 +56,11 @@ function prefixUrl(urlValue, origin, protocol = 'https') {
return `${origin}${urlValue}`;
}
return `${origin}/${urlValue}`;
if (origin) {
return `${origin}/${urlValue}`;
}
return urlValue;
}
function q(context, selector, attrArg, applyTrim = true) {
@@ -217,7 +225,7 @@ function images(context, selector = 'img', attr, { origin, protocol = 'https' }
function url(context, selector = 'a', attr = 'href', { origin, protocol = 'https' } = {}) {
const urlEl = q(context, selector, attr);
return attr ? prefixUrl(urlEl, origin, protocol) : urlEl;
return prefixUrl(urlEl, origin, protocol);
}
function urls(context, selector = 'a', attr = 'href', { origin, protocol = 'https' } = {}) {