Refactored Arch Angel, split off The Flourish. Added try URL util to simplify trying multiple actor URLs.
This commit is contained in:
@@ -4,6 +4,7 @@ const unprint = require('unprint');
|
||||
|
||||
const slugify = require('../utils/slugify');
|
||||
const { convert } = require('../utils/convert');
|
||||
const tryUrls = require('../utils/try-urls');
|
||||
|
||||
const channelCodes = {
|
||||
ao: 'analoverdose',
|
||||
@@ -151,36 +152,17 @@ function scrapeProfile({ query }, url) {
|
||||
}
|
||||
|
||||
async function fetchProfile({ name: actorName, url: actorUrl }) {
|
||||
if (actorUrl) {
|
||||
const res = await unprint.get(actorUrl);
|
||||
const { res, url } = await tryUrls([
|
||||
actorUrl,
|
||||
`https://pervcity.com/models/${slugify(actorName)}.html`,
|
||||
`https://pervcity.com/models/${slugify(actorName, '')}.html`,
|
||||
]);
|
||||
|
||||
if (res.ok) {
|
||||
return scrapeProfile(res.context);
|
||||
}
|
||||
if (res.ok) {
|
||||
return scrapeProfile(res.context, url);
|
||||
}
|
||||
|
||||
const url = `https://pervcity.com/models/${slugify(actorName)}.html`;
|
||||
const url2 = `https://pervcity.com/models/${slugify(actorName, '')}.html`;
|
||||
|
||||
if (url !== actorUrl) {
|
||||
const res = await unprint.get(url);
|
||||
|
||||
if (res.ok) {
|
||||
return scrapeProfile(res.context, url);
|
||||
}
|
||||
}
|
||||
|
||||
if (url2 !== actorUrl) {
|
||||
const res = await unprint.get(url2);
|
||||
|
||||
if (res.ok) {
|
||||
return scrapeProfile(res.context, url);
|
||||
}
|
||||
|
||||
return res.status;
|
||||
}
|
||||
|
||||
return null;
|
||||
return res.status;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user