2014-05-26 21:45:10 +04:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
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;
|
2015-11-04 12:47:21 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'MSN Actualités';
|
|
|
|
}
|
2016-08-29 14:40:01 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
return self::URI;
|
|
|
|
}
|
2014-05-26 21:45:10 +04:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2023-10-13 01:25:34 +03:00
|
|
|
$this->collectExpandableDatas(self::FEED_URL, 10);
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2023-10-13 02:59:05 +03:00
|
|
|
protected function parseItem(array $item)
|
2022-07-01 16:10:30 +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-07-01 16:10:30 +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-07-01 16:10:30 +03:00
|
|
|
$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;
|
|
|
|
}
|
2014-05-26 21:45:10 +04:00
|
|
|
}
|