Update Y2MateDownloaderBridge.php
This commit is contained in:
parent
079498163a
commit
f96a71ab8a
|
@ -4,45 +4,56 @@ class Y2MateDownloaderBridge extends BridgeAbstract {
|
||||||
const MAINTAINER = 'Akamaru';
|
const MAINTAINER = 'Akamaru';
|
||||||
const NAME = 'Y2Mate Downloader Changelog';
|
const NAME = 'Y2Mate Downloader Changelog';
|
||||||
const URI = 'https://y2mate.ch/de/y2mate-downloader-changelog';
|
const URI = 'https://y2mate.ch/de/y2mate-downloader-changelog';
|
||||||
const CACHE_TIMEOUT = 3600; // 1 hour
|
const CACHE_TIMEOUT = 21600; // 6 hours
|
||||||
const DESCRIPTION = 'Changelog for Y2Mate Downloader';
|
const DESCRIPTION = 'Changelog for Y2Mate Downloader';
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
$html = getSimpleHTMLDOM(self::URI)
|
$html = getSimpleHTMLDOM(self::URI);
|
||||||
or returnServerError('Could not load content');
|
|
||||||
|
// Extract main updates
|
||||||
// Extract article title
|
foreach($html->find('div.container') as $section) {
|
||||||
$articleTitle = $html->find('h2.title.tc', 0)->innertext;
|
$title_element = $section->find('p.edition.tc', 0);
|
||||||
$edition = $html->find('p.edition.tc', 0)->innertext;
|
$new_features_element = $section->find('div.list', 0);
|
||||||
$articleTitle = $articleTitle . ' ' . $edition;
|
$date_element = $section->find('p.tc.time', 0);
|
||||||
|
|
||||||
// Extract article content
|
if ($title_element && $new_features_element && $date_element) {
|
||||||
$articleContent = $html->find('div.list', 0)->innertext;
|
$item = [];
|
||||||
|
$item['title'] = str_replace(' ChangeLog', '', $title_element->plaintext); // Remove "ChangeLog"
|
||||||
// Extract release date
|
$item['timestamp'] = strtotime(str_replace('Freigegeben am', '', $date_element->plaintext));
|
||||||
$releaseDate = $html->find('p.tc.time', 0)->innertext;
|
$item['uri'] = self::URI;
|
||||||
$releaseDate = str_replace('Freigegeben am', '', $releaseDate);
|
$item['uid'] = $item['title'];
|
||||||
|
$item['content'] = $new_features_element->outertext;
|
||||||
// Extract article uid
|
|
||||||
$articleUid = $edition;
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
// Build the item
|
}
|
||||||
$item = array();
|
|
||||||
$item['uri'] = self::URI;
|
// Extract updates from the history section
|
||||||
$item['title'] = $articleTitle;
|
$history_section = $html->find('div.update-his', 0);
|
||||||
$item['timestamp'] = strtotime($releaseDate);
|
if ($history_section) {
|
||||||
$item['content'] = $articleContent;
|
foreach($history_section->find('div.list') as $history_update) {
|
||||||
$item['uid'] = $articleUid;
|
$title_element = $history_update->find('p.edition.tl', 0);
|
||||||
|
$date_element = $history_update->find('p.tl.time', 0);
|
||||||
// Add the item to the feed
|
|
||||||
$this->items[] = $item;
|
if ($title_element && $date_element) {
|
||||||
|
$item = [];
|
||||||
|
$item['title'] = $title_element->plaintext;
|
||||||
|
$item['timestamp'] = strtotime(str_replace('Freigegeben am', '', $date_element->plaintext));
|
||||||
|
$item['uri'] = self::URI;
|
||||||
|
$item['uid'] = $title_element->plaintext;
|
||||||
|
|
||||||
|
// Remove the title and date from the content
|
||||||
|
$history_update->find('p.edition.tl', 0)->outertext = '';
|
||||||
|
$history_update->find('p.tl.time', 0)->outertext = '';
|
||||||
|
$item['content'] = $history_update->innertext;
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getIcon() {
|
||||||
return self::NAME;
|
return 'https://y2mate.ch/favicon.ico';
|
||||||
}
|
|
||||||
|
|
||||||
public function getURI() {
|
|
||||||
return self::URI;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue