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()
|
|
|
|
{
|
2023-10-13 01:25:34 +03:00
|
|
|
$this->collectExpandableDatas(self::FEED_URL, 10);
|
2022-06-14 16:45:46 +03:00
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2023-10-13 02:59:05 +03:00
|
|
|
protected function parseItem(array $item)
|
2022-06-14 16:45:46 +03:00
|
|
|
{
|
|
|
|
if (!preg_match('#fr-fr/actualite.*/ar-(?<id>[\w]*)\?#', $item['uri'], $matches)) {
|
2023-10-13 01:25:34 +03:00
|
|
|
return null;
|
2022-06-14 16:45:46 +03:00
|
|
|
}
|
2022-04-13 00:37:30 +03:00
|
|
|
|
2023-10-13 01:25:34 +03:00
|
|
|
$jsonString = getContents(self::JSON_URL . $matches['id']);
|
|
|
|
$json = json_decode($jsonString, true);
|
2022-06-14 16:45:46 +03:00
|
|
|
$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
|
|
|
}
|