[ReutersBridge] Only include main headline from Top News feed (#3199)

This commit is contained in:
csisoap 2022-12-31 13:05:25 +07:00 committed by GitHub
parent 910ccd3ad8
commit 5d8ed2df51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 64 deletions

View File

@ -297,10 +297,6 @@ class ReutersBridge extends BridgeAbstract
$url = $this->getAPIURL($feed_uri, 'article', $is_article_uid); $url = $this->getAPIURL($feed_uri, 'article', $is_article_uid);
$rawData = $this->getJson($url); $rawData = $this->getJson($url);
if (json_last_error() != JSON_ERROR_NONE) { // Checking whether a valid JSON or not
return $this->handleRedirectedArticle($url);
}
$article_content = ''; $article_content = '';
$authorlist = ''; $authorlist = '';
$category = []; $category = [];
@ -342,41 +338,6 @@ class ReutersBridge extends BridgeAbstract
return $content_detail; return $content_detail;
} }
private function handleRedirectedArticle($url)
{
$html = getSimpleHTMLDOMCached($url, 86400); // Duration 24h
$description = '';
$author = '';
$images = '';
$meta_items = $html->find('meta');
foreach ($meta_items as $meta) {
switch ($meta->name) {
case 'description':
$description = $meta->content;
break;
case 'author':
case 'twitter:creator':
$author = $meta->content;
break;
case 'twitter:image:src':
case 'twitter:image':
$url = $meta->content;
$images = "<img src=$url" . '>';
break;
}
}
return [
'content' => $description,
'author' => $author,
'category' => '',
'images' => $images,
'published_at' => '',
'status' => 'redirected'
];
}
private function handleImage($images) private function handleImage($images)
{ {
$img_placeholder = ''; $img_placeholder = '';
@ -527,28 +488,6 @@ EOD;
return $description; return $description;
} }
/**
* @param array $stories
*/
private function addRelatedStories($stories)
{
foreach ($stories as $story) {
$story_data = $this->getArticle($story['url']);
$title = $story['caption'];
$url = self::URI . $story['url'];
if (isset($story_data['status']) && $story_data['status'] != 'redirected') {
$article_body = defaultLinkTo($story_data['content'], $this->getURI());
} else {
$article_body = $story_data['content'];
}
$content = $article_body . $story_data['images'];
$timestamp = $story_data['published_at'];
$category = $story_data['category'];
$author = $story_data['author'];
$this->addStories($title, $content, $timestamp, $author, $url, $category);
}
}
public function getName() public function getName()
{ {
return $this->feedName; return $this->feedName;
@ -606,9 +545,6 @@ EOD;
$title = $story['title']; $title = $story['title'];
$article_uri = $story['canonical_url']; $article_uri = $story['canonical_url'];
$source_type = $story['source']['name']; $source_type = $story['source']['name'];
if (isset($story['related_stories'])) {
$this->addRelatedStories($story['related_stories']);
}
} }
// Some article cause unexpected behaviour like redirect to another site not API. // Some article cause unexpected behaviour like redirect to another site not API.