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