Bridges/KAZENewsBridge.php

49 lines
1.9 KiB
PHP
Raw Normal View History

2023-08-11 22:09:51 +02:00
<?php
class KAZENewsBridge extends BridgeAbstract {
const MAINTAINER = 'Akamaru';
const NAME = 'KAZÉ News';
const URI = 'https://www.kaze-online.de';
const CACHE_TIMEOUT = 21600; // 21600 = 6h
const DESCRIPTION = 'Get the latest news from KAZÉ-Anime.';
public function getIcon(){
return 'https://www.kaze-online.de/media/d5/d7/ce/1622636185/logo.svg';
}
public function collectData() {
// Retrieve webpage
$pageUrl = self::URI . '/news';
$html = getSimpleHTMLDOM($pageUrl)
or returnServerError('Could not request webpage: ' . $pageUrl);
// Process articles
foreach($html->find('div.kaze-news-list__item') as $element) {
if(count($this->items) >= 10) {
break;
}
$article_title = trim(strip_tags($element->find('div.kaze-news-list-item__title', 0)->innertext));
$article_uri = self::URI . substr($element->find('a', 0)->href, 0);
$article_thumbnail = substr($element->find('img', 0)->src, 0);
//$article_content = '<img src="'. $article_thumbnail .'"></a>';
$article_content = trim(strip_tags($element->find('div.kaze-news-list-item__descr', 0)->innertext));
//$article_timestamp = strtotime($element->find('time', 0)->attr['datetime']);
$article_uid = trim(strip_tags($element->find('span.kaze-news-list-item__date', 0)->innertext));
// Store article in items array
if (!empty($article_title)) {
$item = array();
$item['uri'] = $article_uri;
$item['title'] = $article_title;
$item['enclosures'] = array($article_thumbnail);
$item['content'] = $article_content;
//$item['timestamp'] = $article_timestamp;
$item['uid'] = $article_uid;
$this->items[] = $item;
}
}
}
}