Refactored Arch Angel, split off The Flourish. Added try URL util to simplify trying multiple actor URLs.

This commit is contained in:
DebaucheryLibrarian
2026-01-11 00:50:16 +01:00
parent 6cb990dbdb
commit 6338e8fb8d
10 changed files with 332 additions and 225 deletions

View File

@@ -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 = {