1
0
Fork 0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2024-12-30 16:18:23 +03:00
rss-bridge/bridges/VixenBridge.php

112 lines
3.4 KiB
PHP
Raw Normal View History

2022-06-09 17:53:26 +03:00
<?php
class VixenBridge extends BridgeAbstract
{
const NAME = 'Vixen Network Bridge';
const URI = 'https://www.vixen.com';
const DESCRIPTION = 'Latest videos from Vixen Network sites';
const MAINTAINER = 'pubak42';
2022-06-09 17:53:26 +03:00
/**
* The pictures on the pages are referenced with temporary links with
* limited validity. Greater cache timeout results in invalid links in
* the feed
*/
const CACHE_TIMEOUT = 60;
2022-06-09 17:53:26 +03:00
const PARAMETERS = [
[
'site' => [
'type' => 'list',
'name' => 'Site',
'title' => 'Choose site of interest',
'values' => [
'Blacked' => 'Blacked',
'BlackedRaw' => 'BlackedRaw',
'Tushy' => 'Tushy',
'TushyRaw' => 'TushyRaw',
'Vixen' => 'Vixen',
'Slayed' => 'Slayed',
'Deeper' => 'Deeper'
],
]
]
];
2022-06-09 17:53:26 +03:00
public function collectData()
{
$videosURL = $this->getURI() . '/videos';
2022-06-09 17:53:26 +03:00
$website = getSimpleHTMLDOM($videosURL);
$json = $website->getElementById('__NEXT_DATA__');
$data = json_decode($json->innertext(), true);
$nodes = array_column($data['props']['pageProps']['edges'], 'node');
2022-06-09 17:53:26 +03:00
foreach ($nodes as $n) {
$imageURL = $n['images']['listing'][2]['highdpi']['triple'];
2022-06-09 17:53:26 +03:00
$item = [
'title' => $n['title'],
'uri' => "$videosURL/$n[slug]",
'uid' => $n['videoId'],
'timestamp' => strtotime($n['releaseDate']),
'enclosures' => [ $imageURL ],
'author' => implode(' & ', array_column($n['modelsSlugged'], 'name')),
];
2022-06-09 17:53:26 +03:00
/*
* No images retrieved from here. Should be cached for as long as
* possible to avoid rate throttling
*/
$target = getSimpleHtmlDOMCached($item['uri'], 86400);
$item['content'] = $this->generateContent(
$imageURL,
$target->find('meta[name=description]', 0)->content,
$n['modelsSlugged']
);
2022-06-09 17:53:26 +03:00
$item['categories'] = array_map(
'ucwords',
explode(',', $target->find('meta[name=keywords]', 0)->content)
);
2022-06-09 17:53:26 +03:00
$this->items[] = $item;
}
}
2022-06-09 17:53:26 +03:00
public function getURI()
{
$param = $this->getInput('site');
return $param ? "https://www.$param.com" : self::URI;
}
2022-06-09 17:53:26 +03:00
/**
* Return name of the bridge. Default is needed for bridge index list
*/
public function getName()
{
$param = $this->getInput('site');
return $param ? "$param Bridge" : self::NAME;
}
2022-06-09 17:53:26 +03:00
private static function makeLink($URI, $text)
{
return "<a href=\"$URI\">$text</a>";
}
private function generateContent($imageURI, $description, $models)
{
$content = "<img src=\"$imageURI\" referrerpolicy=\"no-referrer\"/><p>$description</p>";
$modelLinks = array_map(
function ($model) {
return self::makeLink(
$this->getURI() . "/models/$model[slugged]",
$model['name']
);
},
$models
);
return $content . '<p>Starring: ' . implode(' & ', $modelLinks) . '</p>';
}
2022-06-09 17:53:26 +03:00
}