mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 09:35:28 +03:00
37f1ab726b
* fix: Undefined offset: 4 * fix: Trying to access array offset on value of type bool * fix: Undefined variable: photo at bridges/TelegramBridge.php line 287 * fix: Trying to get property innertext of non-object at bridges/ZDNetBridge.php line 186 * fix: Undefined index: Category at bridges/UnraidCommunityApplicationsBridge.php line 42 * fix: Undefined index: fullUrl at bridges/EuronewsBridge.php line 61
105 lines
3.4 KiB
PHP
105 lines
3.4 KiB
PHP
<?php
|
|
|
|
class PornhubBridge extends BridgeAbstract
|
|
{
|
|
const MAINTAINER = 'Mitsukarenai';
|
|
const NAME = 'Pornhub';
|
|
const URI = 'https://www.pornhub.com/';
|
|
const CACHE_TIMEOUT = 3600; // 1h
|
|
const DESCRIPTION = 'Returns videos from specified user,model,pornstar';
|
|
|
|
const PARAMETERS = [[
|
|
'q' => [
|
|
'name' => 'User name',
|
|
'exampleValue' => 'asa-akira',
|
|
'required' => true,
|
|
],
|
|
'type' => [
|
|
'name' => 'User type',
|
|
'type' => 'list',
|
|
'values' => [
|
|
'user' => 'users',
|
|
'model' => 'model',
|
|
'pornstar' => 'pornstar',
|
|
],
|
|
'defaultValue' => 'pornstar',
|
|
],
|
|
'sort' => [
|
|
'name' => 'Sort by',
|
|
'type' => 'list',
|
|
'values' => [
|
|
'Most recent' => '?',
|
|
'Most views' => '?o=mv',
|
|
'Top rated' => '?o=tr',
|
|
'Longest' => '?o=lg',
|
|
],
|
|
'defaultValue' => '?',
|
|
],
|
|
'show_images' => [
|
|
'name' => 'Show thumbnails',
|
|
'type' => 'checkbox',
|
|
],
|
|
]];
|
|
|
|
public function getName()
|
|
{
|
|
if (!is_null($this->getInput('type')) && !is_null($this->getInput('q'))) {
|
|
return 'PornHub ' . $this->getInput('type') . ':' . $this->getInput('q');
|
|
}
|
|
|
|
return parent::getName();
|
|
}
|
|
|
|
public function collectData()
|
|
{
|
|
$uri = 'https://www.pornhub.com/' . $this->getInput('type') . '/';
|
|
switch ($this->getInput('type')) { // select proper permalink format per user type...
|
|
case 'model':
|
|
$uri .= urlencode($this->getInput('q')) . '/videos' . $this->getInput('sort');
|
|
break;
|
|
case 'users':
|
|
$uri .= urlencode($this->getInput('q')) . '/videos/public' . $this->getInput('sort');
|
|
break;
|
|
case 'pornstar':
|
|
$uri .= urlencode($this->getInput('q')) . '/videos/upload' . $this->getInput('sort');
|
|
break;
|
|
}
|
|
|
|
$show_images = $this->getInput('show_images');
|
|
|
|
$html = getSimpleHTMLDOM($uri);
|
|
|
|
foreach ($html->find('div.videoUList ul.videos li.videoblock') as $element) {
|
|
$item = [];
|
|
|
|
$item['author'] = $this->getInput('q');
|
|
|
|
// Title
|
|
$title = $element->find('a', 0)->getAttribute('title');
|
|
if (is_null($title)) {
|
|
continue;
|
|
}
|
|
$item['title'] = $title;
|
|
|
|
// Url
|
|
$url = $element->find('a', 0)->href;
|
|
$item['uri'] = 'https://www.pornhub.com' . $url;
|
|
|
|
// Content
|
|
$image = $element->find('img', 0)->getAttribute('data-src');
|
|
if ($show_images === true) {
|
|
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $image . '"></a>';
|
|
}
|
|
|
|
$uploaded = explode('/', $image);
|
|
if (isset($uploaded[4])) {
|
|
// date hack, guess upload YYYYMMDD from thumbnail URL (format: https://ci.phncdn.com/videos/201907/25/--- )
|
|
$uploadTimestamp = strtotime($uploaded[4] . $uploaded[5]);
|
|
$item['timestamp'] = $uploadTimestamp;
|
|
} else {
|
|
// The thumbnail url did not have a date in it for some unknown reason
|
|
}
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|