Bridges/Y2MateDownloaderBridge.php
2023-08-11 22:09:51 +02:00

48 lines
1.4 KiB
PHP

<?php
class Y2MateDownloaderBridge extends BridgeAbstract {
const MAINTAINER = 'Akamaru';
const NAME = 'Y2Mate Downloader Changelog';
const URI = 'https://y2mate.ch/de/y2mate-downloader-changelog';
const CACHE_TIMEOUT = 3600; // 1 hour
const DESCRIPTION = 'Changelog for Y2Mate Downloader';
public function collectData() {
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not load content');
// Extract article title
$articleTitle = $html->find('h2.title.tc', 0)->innertext;
$edition = $html->find('p.edition.tc', 0)->innertext;
$articleTitle = $articleTitle . ' ' . $edition;
// Extract article content
$articleContent = $html->find('div.list', 0)->innertext;
// Extract release date
$releaseDate = $html->find('p.tc.time', 0)->innertext;
$releaseDate = str_replace('Freigegeben am', '', $releaseDate);
// Extract article uid
$articleUid = $edition;
// Build the item
$item = array();
$item['uri'] = self::URI;
$item['title'] = $articleTitle;
$item['timestamp'] = strtotime($releaseDate);
$item['content'] = $articleContent;
$item['uid'] = $articleUid;
// Add the item to the feed
$this->items[] = $item;
}
public function getName() {
return self::NAME;
}
public function getURI() {
return self::URI;
}
}