2019-07-26 11:53:09 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-07-26 11:53:09 +03:00
|
|
|
class CNETFranceBridge extends FeedExpander
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'leomaradan';
|
|
|
|
const NAME = 'CNET France';
|
|
|
|
const URI = 'https://www.cnetfrance.fr/';
|
|
|
|
const CACHE_TIMEOUT = 3600; // 1h
|
|
|
|
const DESCRIPTION = 'CNET France RSS with filters';
|
|
|
|
const PARAMETERS = [
|
|
|
|
'filters' => [
|
|
|
|
'title' => [
|
|
|
|
'name' => 'Exclude by title',
|
|
|
|
'required' => false,
|
|
|
|
'title' => 'Title term, separated by semicolon (;)',
|
2022-03-24 13:59:34 +03:00
|
|
|
'exampleValue' => 'bon plan;bons plans;au meilleur prix;des meilleures offres;Amazon Prime Day;RED by SFR ou B&You'
|
2019-07-26 11:53:09 +03:00
|
|
|
],
|
|
|
|
'url' => [
|
|
|
|
'name' => 'Exclude by url',
|
|
|
|
'required' => false,
|
|
|
|
'title' => 'URL term, separated by semicolon (;)',
|
2022-03-24 13:59:34 +03:00
|
|
|
'exampleValue' => 'bon-plan;bons-plans'
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
2019-07-26 11:53:09 +03:00
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-11-01 20:06:38 +03:00
|
|
|
private $bannedTitle = [];
|
|
|
|
private $bannedURL = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-07-26 11:53:09 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$title = $this->getInput('title');
|
|
|
|
$url = $this->getInput('url');
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-07-26 11:53:09 +03:00
|
|
|
if ($title !== null) {
|
|
|
|
$this->bannedTitle = explode(';', $title);
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-07-26 11:53:09 +03:00
|
|
|
if ($url !== null) {
|
|
|
|
$this->bannedURL = explode(';', $url);
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-07-26 11:53:09 +03:00
|
|
|
$this->collectExpandableDatas('https://www.cnetfrance.fr/feeds/rss/news/');
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-10-13 02:59:05 +03:00
|
|
|
protected function parseItem(array $item)
|
2019-07-26 11:53:09 +03:00
|
|
|
{
|
|
|
|
foreach ($this->bannedTitle as $term) {
|
|
|
|
if (preg_match('/' . $term . '/mi', $item['title']) === 1) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-07-26 11:53:09 +03:00
|
|
|
foreach ($this->bannedURL as $term) {
|
2023-10-13 01:25:34 +03:00
|
|
|
if (preg_match('#' . $term . '#mi', $item['uri'])) {
|
2019-07-26 11:53:09 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-07-26 11:53:09 +03:00
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
}
|