refactor: FeedExpander::parseItem() descendants (#3744)

This commit is contained in:
Dag 2023-10-13 00:25:34 +02:00 committed by GitHub
parent 9bda9e246a
commit 382648fc22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 314 additions and 281 deletions

View file

@ -22,17 +22,19 @@ class MsnMondeBridge extends FeedExpander
public function collectData()
{
$this->collectExpandableDatas(self::FEED_URL, self::LIMIT);
$this->collectExpandableDatas(self::FEED_URL, 10);
}
protected function parseItem($newsItem)
protected function parseItem($item)
{
$item = parent::parseItem($newsItem);
$item = parent::parseItem($item);
if (!preg_match('#fr-fr/actualite.*/ar-(?<id>[\w]*)\?#', $item['uri'], $matches)) {
return;
return null;
}
$json = json_decode(getContents(self::JSON_URL . $matches['id']), true);
$jsonString = getContents(self::JSON_URL . $matches['id']);
$json = json_decode($jsonString, true);
$item['content'] = $json['body'];
if (!empty($json['authors'])) {
$item['author'] = reset($json['authors'])['name'];