Skip to content

Commit

Permalink
fix(route): PornHub pornstar pages (#16863)
Browse files Browse the repository at this point in the history
* fix(route): PornHub pornstar pages

Fix issue introduced in #15616 to accommodate different types of pornstar pages

* Update pornstar.ts

Fix issue with variables

* Update pornstar.ts

Fix linter issue
  • Loading branch information
Antesam authored Sep 22, 2024
1 parent da72591 commit 90d94ce
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/routes/pornhub/pornstar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 90d94ce

Please sign in to comment.