From b0bae45ac6bec55626c0b5c312ea65cbab5df26c Mon Sep 17 00:00:00 2001 From: Akamaru Date: Thu, 3 Apr 2025 21:16:36 +0200 Subject: [PATCH] Update Y2MateDownloaderBridge.php --- Y2MateDownloaderBridge.php | 110 ++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 38 deletions(-) diff --git a/Y2MateDownloaderBridge.php b/Y2MateDownloaderBridge.php index 96591a5..f48c0f7 100644 --- a/Y2MateDownloaderBridge.php +++ b/Y2MateDownloaderBridge.php @@ -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); - - 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; - } + $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'; } - // 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); + + // 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']; - 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; + // 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 .= '

' . $new_title->plaintext . '

'; + $content .= $new_section->find('ul', 0)->outertext; + } } + + if ($fix_section) { + $fix_title = $fix_section->find('p.fix-title', 0); + if ($fix_title) { + $content .= '

' . $fix_title->plaintext . '

'; + $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'; } } \ No newline at end of file