2020-03-25 22:02:09 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
class MediapartBlogsBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Mediapart Blogs';
|
|
|
|
const BASE_URI = 'https://blogs.mediapart.fr';
|
|
|
|
const URI = self::BASE_URI . '/blogs';
|
|
|
|
const MAINTAINER = 'somini';
|
|
|
|
const PARAMETERS = [
|
2022-07-01 16:10:30 +03:00
|
|
|
[
|
2020-03-25 22:02:09 +03:00
|
|
|
'slug' => [
|
|
|
|
'name' => 'Blog Slug',
|
|
|
|
'type' => 'text',
|
|
|
|
'title' => 'Blog user name',
|
2022-03-24 13:59:34 +03:00
|
|
|
'required' => true,
|
2020-03-25 22:02:09 +03:00
|
|
|
'exampleValue' => 'jean-vincot',
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
2020-03-25 22:02:09 +03:00
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return 'https://static.mediapart.fr/favicon/favicon-club.ico?v=2';
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM(self::BASE_URI . '/' . $this->getInput('slug') . '/blog');
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
foreach ($html->find('ul.post-list li') as $element) {
|
|
|
|
$item = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
$item_title = $element->find('h3.title a', 0);
|
|
|
|
$item_divs = $element->find('div');
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
$item['title'] = $item_title->innertext;
|
|
|
|
$item['uri'] = self::BASE_URI . trim($item_title->href);
|
2024-03-31 22:02:55 +03:00
|
|
|
|
|
|
|
$author = $element->find('.author .subscriber', 0);
|
|
|
|
if ($author) {
|
|
|
|
$item['author'] = $author->innertext;
|
|
|
|
}
|
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
$item['content'] = $item_divs[count($item_divs) - 2] . $item_divs[count($item_divs) - 1];
|
|
|
|
$item['timestamp'] = strtotime($element->find('.author time', 0)->datetime);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-03-25 22:02:09 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
if ($this->getInput('slug')) {
|
|
|
|
return self::NAME . ' | ' . $this->getInput('slug');
|
|
|
|
}
|
|
|
|
return parent::getName();
|
|
|
|
}
|
|
|
|
}
|