Update Y2MateDownloaderBridge.php
This commit is contained in:
@ -3,57 +3,91 @@ class Y2MateDownloaderBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'Akamaru';
|
||||
const NAME = 'Y2Mate Downloader Changelog';
|
||||
const URI = 'https://y2mate.ch/de/y2mate-downloader-changelog';
|
||||
const URI = 'https://y2matedownloader.com/y2mate-downloader-changelog';
|
||||
const CACHE_TIMEOUT = 21600; // 6 hours
|
||||
const DESCRIPTION = 'Changelog for Y2Mate Downloader';
|
||||
const PARAMETERS = [
|
||||
'Language' => [
|
||||
'lang' => [
|
||||
'name' => 'Language',
|
||||
'type' => 'list',
|
||||
'values' => [
|
||||
'English' => 'en',
|
||||
'Spanish' => 'es',
|
||||
'German' => 'de',
|
||||
'French' => 'fr',
|
||||
'Italian' => 'it',
|
||||
'Chinese' => 'zh',
|
||||
],
|
||||
'defaultValue' => 'en'
|
||||
],
|
||||
'platform' => [
|
||||
'name' => 'Platform',
|
||||
'type' => 'list',
|
||||
'values' => [
|
||||
'Windows' => 'win',
|
||||
'Mac' => 'mac'
|
||||
],
|
||||
'defaultValue' => 'win'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
public function collectData() {
|
||||
$html = getSimpleHTMLDOM(self::URI);
|
||||
$lang = $this->getInput('lang');
|
||||
$platform = $this->getInput('platform');
|
||||
|
||||
// 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);
|
||||
$url = 'https://y2matedownloader.com/' . $lang . '/y2mate-downloader-changelog';
|
||||
|
||||
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['uid'] = $item['title'];
|
||||
$item['content'] = $new_features_element->outertext;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
// Füge "-mac" zur URL hinzu, wenn die Mac-Plattform ausgewählt wurde
|
||||
if ($platform === 'mac') {
|
||||
$url .= '-mac';
|
||||
}
|
||||
|
||||
// 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);
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Could not request webpage: ' . $url);
|
||||
|
||||
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;
|
||||
// Extract change log items
|
||||
foreach($html->find('div.change-log-items') as $section) {
|
||||
$title_element = $section->find('p.product-name', 0);
|
||||
$date_element = $section->find('p.version-date', 0);
|
||||
$desc_element = $section->find('div.desc', 0);
|
||||
|
||||
// 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;
|
||||
if ($title_element && $date_element && $desc_element) {
|
||||
$item = [];
|
||||
$item['title'] = $title_element->plaintext;
|
||||
$item['timestamp'] = strtotime($date_element->plaintext);
|
||||
$item['uri'] = $url;
|
||||
$item['uid'] = $item['title'] . '-' . $item['timestamp'];
|
||||
|
||||
$this->items[] = $item;
|
||||
// Extract content from "New" and "Fix" sections
|
||||
$content = '';
|
||||
$new_section = $desc_element->find('div.list-l', 0);
|
||||
$fix_section = $desc_element->find('div.list-r', 0);
|
||||
|
||||
if ($new_section) {
|
||||
$new_title = $new_section->find('p.new-title', 0);
|
||||
if ($new_title) {
|
||||
$content .= '<h3>' . $new_title->plaintext . '</h3>';
|
||||
$content .= $new_section->find('ul', 0)->outertext;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fix_section) {
|
||||
$fix_title = $fix_section->find('p.fix-title', 0);
|
||||
if ($fix_title) {
|
||||
$content .= '<h3>' . $fix_title->plaintext . '</h3>';
|
||||
$content .= $fix_section->find('ul', 0)->outertext;
|
||||
}
|
||||
}
|
||||
|
||||
$item['content'] = $content;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getIcon() {
|
||||
return 'https://y2mate.ch/favicon.ico';
|
||||
return 'https://c1.y2matedownloader.com/favicon.ico';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user