From 90d94cee993c03ae051961d9d6262d87990e4f1a Mon Sep 17 00:00:00 2001 From: Antesam Date: Sun, 22 Sep 2024 18:07:53 +0100 Subject: [PATCH] fix(route): PornHub pornstar pages (#16863) * fix(route): PornHub pornstar pages Fix issue introduced in https://github.com/DIYgod/RSSHub/pull/15616 to accommodate different types of pornstar pages * Update pornstar.ts Fix issue with variables * Update pornstar.ts Fix linter issue --- lib/routes/pornhub/pornstar.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/routes/pornhub/pornstar.ts b/lib/routes/pornhub/pornstar.ts index a2a6a96ed274ca..ec686325925131 100644 --- a/lib/routes/pornhub/pornstar.ts +++ b/lib/routes/pornhub/pornstar.ts @@ -37,16 +37,27 @@ export const route: Route = { async function handler(ctx) { const { language = 'www', username, sort = 'mr' } = ctx.req.param(); - const link = `https://${language}.pornhub.com/pornstar/${username}?o=${sort}`; + let link = `https://${language}.pornhub.com/pornstar/${username}?o=${sort}`; if (!isValidHost(language)) { throw new InvalidParameterError('Invalid language'); } const { data: response } = await got(link, { headers }); - const $ = load(response); - const items = $('#pornstarsVideoSection .videoBox') - .toArray() - .map((e) => parseItems($(e))); + let $ = load(response); + let items; + + if ($('.withBio').length === 0) { + link = `https://${language}.pornhub.com/pornstar/${username}/videos?o=${sort}`; + const { data: response } = await got(link, { headers }); + $ = load(response); + items = $('#mostRecentVideosSection .videoBox') + .toArray() + .map((e) => parseItems($(e))); + } else { + items = $('#pornstarsVideoSection .videoBox') + .toArray() + .map((e) => parseItems($(e))); + } return { title: $('h1').first().text(),