1
0
Files
Bridges/Y2MateDownloaderBridge.php
2025-04-03 21:16:36 +02:00

93 lines
3.4 KiB
PHP

<?php
class Y2MateDownloaderBridge extends BridgeAbstract {
const MAINTAINER = 'Akamaru';
const NAME = '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() {
$lang = $this->getInput('lang');
$platform = $this->getInput('platform');
$url = 'https://y2matedownloader.com/' . $lang . '/y2mate-downloader-changelog';
// Füge "-mac" zur URL hinzu, wenn die Mac-Plattform ausgewählt wurde
if ($platform === 'mac') {
$url .= '-mac';
}
$html = getSimpleHTMLDOM($url)
or returnServerError('Could not request webpage: ' . $url);
// 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);
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'];
// 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://c1.y2matedownloader.com/favicon.ico';
}
}