178 lines
5.8 KiB
PHP
178 lines
5.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
class PornhubModelBridge extends BridgeAbstract
|
|
{
|
|
const NAME = 'Pornhub Model Videos';
|
|
const URI = 'https://www.pornhub.com';
|
|
const DESCRIPTION = 'Returns latest videos from a Pornhub model, pornstar or user';
|
|
const MAINTAINER = 'Akamaru';
|
|
const CACHE_TIMEOUT = 3600; // 1 hour
|
|
|
|
const PARAMETERS = [
|
|
[
|
|
'username' => [
|
|
'name' => 'Username',
|
|
'type' => 'text',
|
|
'required' => true,
|
|
'exampleValue' => 'lolliepopxxx'
|
|
],
|
|
'type' => [
|
|
'name' => 'Profile Type',
|
|
'type' => 'list',
|
|
'values' => [
|
|
'Model' => 'model',
|
|
'Pornstar' => 'pornstar',
|
|
'User' => 'users'
|
|
],
|
|
'defaultValue' => 'model'
|
|
],
|
|
'limit' => [
|
|
'name' => 'Limit',
|
|
'type' => 'number',
|
|
'defaultValue' => 10,
|
|
'required' => false
|
|
]
|
|
]
|
|
];
|
|
|
|
private $profileName = null;
|
|
|
|
public function getIcon()
|
|
{
|
|
return 'https://www.google.com/s2/favicons?domain=pornhub.com&sz=32';
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
$username = $this->getInput('username');
|
|
if ($username) {
|
|
$name = $this->profileName ?? $username;
|
|
return $name . ' - Pornhub';
|
|
}
|
|
return self::NAME;
|
|
}
|
|
|
|
public function getURI()
|
|
{
|
|
$username = $this->getInput('username');
|
|
$type = $this->getInput('type') ?: 'model';
|
|
if ($username) {
|
|
return self::URI . '/' . $type . '/' . $username . '/videos';
|
|
}
|
|
return self::URI;
|
|
}
|
|
|
|
public function collectData()
|
|
{
|
|
$username = $this->getInput('username');
|
|
$type = $this->getInput('type') ?: 'model';
|
|
$limit = $this->getInput('limit') ?: 10;
|
|
|
|
$url = self::URI . '/' . $type . '/' . $username . '/videos';
|
|
|
|
$html = getSimpleHTMLDOM($url);
|
|
if (!$html) {
|
|
returnServerError('Could not fetch page: ' . $url);
|
|
}
|
|
|
|
// Try to get profile name from page title
|
|
$titleElement = $html->find('title', 0);
|
|
if ($titleElement) {
|
|
$pageTitle = html_entity_decode($titleElement->plaintext, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
|
// Extract name from title like "New Marcy Abadir's Porn Videos 2025 | Pornhub"
|
|
if (preg_match('/^New\s+(.+?)\'s\s+Porn\s+Videos/i', $pageTitle, $matches)) {
|
|
$this->profileName = trim($matches[1]);
|
|
} elseif (preg_match('/^(.+?)\s+-\s+Pornhub/i', $pageTitle, $matches)) {
|
|
$this->profileName = trim($matches[1]);
|
|
}
|
|
}
|
|
|
|
$videos = $html->find('li.pcVideoListItem');
|
|
$count = 0;
|
|
|
|
foreach ($videos as $video) {
|
|
if ($count >= $limit) {
|
|
break;
|
|
}
|
|
|
|
$vkey = $video->getAttribute('data-video-vkey');
|
|
if (!$vkey) {
|
|
continue;
|
|
}
|
|
|
|
// Skip videos from other uploaders (channels, other models)
|
|
// Own videos don't have a videoUploaderBlock element
|
|
$uploaderBlock = $video->find('.videoUploaderBlock', 0);
|
|
if ($uploaderBlock) {
|
|
// Check if the uploader link points to a different profile
|
|
$uploaderLink = $uploaderBlock->find('a', 0);
|
|
if ($uploaderLink) {
|
|
$uploaderHref = $uploaderLink->getAttribute('href');
|
|
// If the uploader is different from the current profile, skip this video
|
|
if ($uploaderHref && strpos($uploaderHref, '/' . $username) === false) {
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Get the link element
|
|
$linkElement = $video->find('a.videoPreviewBg', 0);
|
|
if (!$linkElement) {
|
|
$linkElement = $video->find('a.linkVideoThumb', 0);
|
|
}
|
|
|
|
// Get title
|
|
$title = '';
|
|
if ($linkElement) {
|
|
$title = $linkElement->getAttribute('title');
|
|
if (!$title) {
|
|
$title = $linkElement->getAttribute('data-title');
|
|
}
|
|
}
|
|
if (!$title) {
|
|
$titleLink = $video->find('span.title a', 0);
|
|
if ($titleLink) {
|
|
$title = $titleLink->getAttribute('title') ?: trim($titleLink->plaintext);
|
|
}
|
|
}
|
|
if (!$title) {
|
|
$title = 'Video ' . $vkey;
|
|
}
|
|
|
|
// Get thumbnail
|
|
$thumbnail = '';
|
|
$imgElement = $video->find('img.js-videoThumb', 0);
|
|
if (!$imgElement) {
|
|
$imgElement = $video->find('img.thumb', 0);
|
|
}
|
|
if ($imgElement) {
|
|
$thumbnail = $imgElement->getAttribute('src');
|
|
if (!$thumbnail || strpos($thumbnail, 'data:') === 0) {
|
|
$thumbnail = $imgElement->getAttribute('data-image')
|
|
?: $imgElement->getAttribute('data-mediumthumb')
|
|
?: $imgElement->getAttribute('data-thumb_url');
|
|
}
|
|
}
|
|
|
|
// Build content (just the thumbnail)
|
|
$content = '';
|
|
if ($thumbnail) {
|
|
$content = '<img src="' . htmlspecialchars($thumbnail) . '" />';
|
|
}
|
|
|
|
$item = [
|
|
'title' => $title,
|
|
'uri' => self::URI . '/view_video.php?viewkey=' . $vkey,
|
|
'content' => $content,
|
|
'author' => $this->profileName ?? $username,
|
|
'uid' => 'pornhub-' . $vkey
|
|
];
|
|
|
|
$this->items[] = $item;
|
|
$count++;
|
|
}
|
|
}
|
|
}
|