From 1b0a6f281386d12f70b094193d6bf15dcf61729b Mon Sep 17 00:00:00 2001 From: pubak42 <106606827+pubak42@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:53:26 +0200 Subject: [PATCH] [VixenBridge] New bridge (#2763) --- bridges/VixenBridge.php | 99 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 bridges/VixenBridge.php diff --git a/bridges/VixenBridge.php b/bridges/VixenBridge.php new file mode 100644 index 00000000..721524e9 --- /dev/null +++ b/bridges/VixenBridge.php @@ -0,0 +1,99 @@ + array( + 'type' => 'list', + 'name' => 'Site', + 'title' => 'Choose site of interest', + 'values' => array( + 'Blacked' => 'Blacked', + 'BlackedRaw' => 'BlackedRaw', + 'Tushy' => 'Tushy', + 'TushyRaw' => 'TushyRaw', + 'Vixen' => 'Vixen', + 'Slayed' => 'Slayed', + 'Deeper' => 'Deeper' + ), + ) + ) + ); + + public function collectData() { + $videosURL = $this->getURI() . '/videos'; + + $website = getSimpleHTMLDOM($videosURL); + $json = $website->getElementById('__NEXT_DATA__'); + $data = json_decode($json->innertext(), true); + $nodes = array_column($data['props']['pageProps']['edges'], 'node'); + + foreach($nodes as $n) { + $imageURL = $n['images']['listing'][2]['highdpi']['triple']; + + $item = [ + 'title' => $n['title'], + 'uri' => "$videosURL/$n[slug]", + 'uid' => $n['videoId'], + 'timestamp' => strtotime($n['releaseDate']), + 'enclosures' => [ $imageURL ], + 'author' => implode(' & ', array_column($n['modelsSlugged'], 'name')), + ]; + + /* + * 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']); + + $item['categories'] = array_map('ucwords', + explode(',', $target->find('meta[name=keywords]', 0)->content)); + + $this->items[] = $item; + } + } + + public function getURI() { + $param = $this->getInput('site'); + return $param ? "https://www.$param.com" : self::URI; + } + + /** + * 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; + } + + private static function makeLink($URI, $text) { + return "$text"; + } + + private function generateContent($imageURI, $description, $models) { + $content = "

$description

"; + $modelLinks = array_map( + function($model) { + return self::makeLink( + $this->getURI() . "/models/$model[slugged]", + $model['name']); + }, + $models + ); + return $content . '

Starring: ' . implode(' & ', $modelLinks) . '

'; + } +}