2014-05-26 21:45:10 +04:00
|
|
|
<?php
|
|
|
|
|
2022-06-14 16:45:46 +03:00
|
|
|
class MsnMondeBridge extends FeedExpander
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2017-02-11 18:16:56 +03:00
|
|
|
const MAINTAINER = 'kranack';
|
2016-08-30 12:23:55 +03:00
|
|
|
const NAME = 'MSN Actu Monde';
|
2017-02-11 18:16:56 +03:00
|
|
|
const DESCRIPTION = 'Returns the 10 newest posts from MSN Actualités (full text)';
|
2022-06-14 16:45:46 +03:00
|
|
|
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;
|
2015-11-04 12:47:21 +03:00
|
|
|
|
2022-06-14 16:45:46 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'MSN Actualités';
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2016-08-29 14:40:01 +03:00
|
|
|
|
2022-06-14 16:45:46 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
return self::URI;
|
2016-08-03 22:12:43 +03:00
|
|
|
}
|
2014-05-26 21:45:10 +04:00
|
|
|
|
2022-06-14 16:45:46 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$this->collectExpandableDatas(self::FEED_URL, self::LIMIT);
|
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2022-06-14 16:45:46 +03:00
|
|
|
protected function parseItem($newsItem)
|
|
|
|
{
|
|
|
|
$item = parent::parseItem($newsItem);
|
|
|
|
if (!preg_match('#fr-fr/actualite.*/ar-(?<id>[\w]*)\?#', $item['uri'], $matches)) {
|
|
|
|
return;
|
|
|
|
}
|
2022-04-13 00:37:30 +03:00
|
|
|
|
2022-06-14 16:45:46 +03:00
|
|
|
$json = json_decode(getContents(self::JSON_URL . $matches['id']), true);
|
|
|
|
$item['content'] = $json['body'];
|
|
|
|
if (!empty($json['authors'])) {
|
|
|
|
$item['author'] = reset($json['authors'])['name'];
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2022-06-14 16:45:46 +03:00
|
|
|
$item['timestamp'] = $json['createdDateTime'];
|
|
|
|
foreach ($json['tags'] as $tag) {
|
|
|
|
$item['categories'][] = $tag['label'];
|
2016-08-03 22:14:46 +03:00
|
|
|
}
|
2022-06-14 16:45:46 +03:00
|
|
|
return $item;
|
2016-08-03 22:14:46 +03:00
|
|
|
}
|
2014-05-26 21:45:10 +04:00
|
|
|
}
|