2019-06-08 20:30:42 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-06-08 20:30:42 +03:00
|
|
|
class BrutBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Brut Bridge';
|
|
|
|
const URI = 'https://www.brut.media';
|
2022-06-07 19:05:03 +03:00
|
|
|
const DESCRIPTION = 'Returns 10 newest videos by category and edition';
|
2019-06-08 20:30:42 +03:00
|
|
|
const MAINTAINER = 'VerifiedJoseph';
|
|
|
|
const PARAMETERS = [[
|
|
|
|
'category' => [
|
|
|
|
'name' => 'Category',
|
|
|
|
'type' => 'list',
|
|
|
|
'values' => [
|
|
|
|
'News' => 'news',
|
|
|
|
'International' => 'international',
|
|
|
|
'Economy' => 'economy',
|
|
|
|
'Science and Technology' => 'science-and-technology',
|
|
|
|
'Entertainment' => 'entertainment',
|
|
|
|
'Sports' => 'sport',
|
|
|
|
'Nature' => 'nature',
|
2020-11-09 16:14:13 +03:00
|
|
|
'Health' => 'health',
|
2019-06-08 20:30:42 +03:00
|
|
|
],
|
|
|
|
'defaultValue' => 'news',
|
|
|
|
],
|
|
|
|
'edition' => [
|
|
|
|
'name' => ' Edition',
|
|
|
|
'type' => 'list',
|
|
|
|
'values' => [
|
|
|
|
'United States' => 'us',
|
|
|
|
'United Kingdom' => 'uk',
|
|
|
|
'France' => 'fr',
|
2020-11-09 16:14:13 +03:00
|
|
|
'Spain' => 'es',
|
2019-06-08 20:30:42 +03:00
|
|
|
'India' => 'in',
|
|
|
|
'Mexico' => 'mx',
|
|
|
|
],
|
|
|
|
'defaultValue' => 'us',
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
2019-06-08 20:30:42 +03:00
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-06-08 20:30:42 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2023-09-24 19:15:14 +03:00
|
|
|
$url = $this->getURI();
|
|
|
|
$html = getSimpleHTMLDOM($url);
|
|
|
|
$regex = '/window.__PRELOADED_STATE__ = (.*);/';
|
|
|
|
preg_match($regex, $html, $parts);
|
|
|
|
$data = Json::decode($parts[1], false);
|
|
|
|
foreach ($data->medias->index as $uid => $media) {
|
|
|
|
$this->items[] = [
|
|
|
|
'uid' => $uid,
|
|
|
|
'title' => $media->metadata->slug,
|
|
|
|
'uri' => $media->share_url,
|
|
|
|
'timestamp' => $media->published_at,
|
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
}
|
2019-06-08 20:30:42 +03:00
|
|
|
|
2019-06-13 20:13:02 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
2019-06-08 20:30:42 +03:00
|
|
|
if (!is_null($this->getInput('edition')) && !is_null($this->getInput('category'))) {
|
|
|
|
return self::URI . '/' . $this->getInput('edition') . '/' . $this->getInput('category');
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2019-06-13 20:13:02 +03:00
|
|
|
return parent::getURI();
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2019-06-13 20:13:02 +03:00
|
|
|
|
|
|
|
public function getName()
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2019-06-13 20:13:02 +03:00
|
|
|
if (!is_null($this->getInput('edition')) && !is_null($this->getInput('category'))) {
|
2023-09-24 19:15:14 +03:00
|
|
|
return $this->getKey('category') . ' - ' . $this->getKey('edition') . ' - Brut.';
|
2019-06-13 20:13:02 +03:00
|
|
|
}
|
2022-06-07 19:05:03 +03:00
|
|
|
return parent::getName();
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2019-06-08 20:30:42 +03:00
|
|
|
}
|