Bridges/ThumbzillaFeedBridge.php

44 lines
1.5 KiB
PHP
Raw Normal View History

2023-08-11 22:09:51 +02:00
<?php
class ThumbzillaFeedBridge extends BridgeAbstract {
const MAINTAINER = 'Akamaru';
const NAME = 'Thumbzilla Feed';
const URI = 'https://www.thumbzilla.com';
const CACHE_TIMEOUT = 21600; // 21600 = 6h
const DESCRIPTION = 'Get the latest Videos from Thumbzilla.';
public function getIcon(){
return 'https://ci.phncdn.com/www-static/thumbzilla/images/favicon.ico';
}
public function collectData() {
// Retrieve webpage
$pageUrl = self::URI . '/newest';
$html = getSimpleHTMLDOM($pageUrl)
or returnServerError('Could not request webpage: ' . $pageUrl);
// Process articles
foreach($html->find('a.js-thumb') as $element) {
if(count($this->items) >= 10) {
break;
}
$article_title = trim(strip_tags($element->find('span.title', 0)->innertext));
$article_thumbnail = substr($element->find('img', 0)->src, 0);
$article_content = '<img src="'. $article_thumbnail .'"></a>';
$article_uid = trim(strip_tags($element->find('span.title', 0)->innertext));
// Store article in items array
if (!empty($article_title)) {
$item = array();
$item['uri'] = $pageUrl;
$item['title'] = $article_title;
$item['content'] = $article_content;
$item['uid'] = $article_uid;
$this->items[] = $item;
}
}
}
}