mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-25 10:56:18 +03:00
4f75591060
Reformat code base to PSR12 Co-authored-by: rssbridge <noreply@github.com>
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
class MsnMondeBridge extends FeedExpander
|
|
{
|
|
const MAINTAINER = 'kranack';
|
|
const NAME = 'MSN Actu Monde';
|
|
const DESCRIPTION = 'Returns the 10 newest posts from MSN Actualités (full text)';
|
|
const URI = 'https://www.msn.com/fr-fr/actualite';
|
|
const FEED_URL = 'https://rss.msn.com/fr-fr';
|
|
const JSON_URL = 'https://assets.msn.com/content/view/v2/Detail/fr-fr/';
|
|
const LIMIT = 10;
|
|
|
|
public function getName()
|
|
{
|
|
return 'MSN Actualités';
|
|
}
|
|
|
|
public function getURI()
|
|
{
|
|
return self::URI;
|
|
}
|
|
|
|
public function collectData()
|
|
{
|
|
$this->collectExpandableDatas(self::FEED_URL, self::LIMIT);
|
|
}
|
|
|
|
protected function parseItem($newsItem)
|
|
{
|
|
$item = parent::parseItem($newsItem);
|
|
if (!preg_match('#fr-fr/actualite.*/ar-(?<id>[\w]*)\?#', $item['uri'], $matches)) {
|
|
return;
|
|
}
|
|
|
|
$json = json_decode(getContents(self::JSON_URL . $matches['id']), true);
|
|
$item['content'] = $json['body'];
|
|
if (!empty($json['authors'])) {
|
|
$item['author'] = reset($json['authors'])['name'];
|
|
}
|
|
$item['timestamp'] = $json['createdDateTime'];
|
|
foreach ($json['tags'] as $tag) {
|
|
$item['categories'][] = $tag['label'];
|
|
}
|
|
return $item;
|
|
}
|
|
}
|