From 989561ecf42bb255c979ddc45697d8af735a97ab Mon Sep 17 00:00:00 2001 From: Akamaru Date: Wed, 30 Jul 2025 21:11:52 +0200 Subject: [PATCH] =?UTF-8?q?Neue=20Bridge=20f=C3=BCr=20Snowbreak:=20Contain?= =?UTF-8?q?ment=20Zone=20News?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SnowbreakNewsBridge.php | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 SnowbreakNewsBridge.php diff --git a/SnowbreakNewsBridge.php b/SnowbreakNewsBridge.php new file mode 100644 index 0000000..bec82d0 --- /dev/null +++ b/SnowbreakNewsBridge.php @@ -0,0 +1,87 @@ + [ + 'category' => [ + 'name' => 'Category', + 'type' => 'list', + 'values' => [ + 'News' => '613', + 'Updates' => '614', + 'Events' => '615', + 'All' => 'all' + ], + 'defaultValue' => '613' + ] + ] + ]; + const FAVICON = 'https://snowbreak.amazingseasun.com/p/zt/2023/07/13/index/static/favicon.ico'; + + public function collectData() { + $category = $this->getInput('category'); + $articles = []; + + if ($category === 'all') { + // Fetch all categories + $categories = ['613', '614', '615']; + foreach ($categories as $cat) { + $articles = array_merge($articles, $this->fetchCategory($cat)); + } + } else { + $articles = $this->fetchCategory($category); + } + + // Sort articles by date (newest first) + usort($articles, function($a, $b) { + return $b['inputtime'] - $a['inputtime']; + }); + + foreach ($articles as $article) { + $item = []; + $item['title'] = $article['title']; + // Convert inputtime to timestamp + $item['timestamp'] = $article['inputtime']; + $item['uri'] = $article['url']; + + $item['content'] = $article['content']; + $item['author'] = 'Amazing Seasun'; + + if (!empty($article['thumb'])) { + $item['enclosures'] = [$article['thumb']]; + } + $this->items[] = $item; + } + } + + private function fetchCategory($category) { + $api_url = 'https://snowbreak.amazingseasun.com/api.php?op=search_api&action=get_article_list&catid=' . + $category . '&num=50&moreinfo=1'; + + $json = getContents($api_url); + $data = json_decode($json, true); + + if (!isset($data['data']['list']) || !is_array($data['data']['list'])) { + return []; + } + + return $data['data']['list']; + } + + public function getName() { + $category = $this->getInput('category'); + $categories = [ + '613' => 'News', + '614' => 'Updates', + '615' => 'Events', + 'all' => 'All' + ]; + + $categoryName = $categories[$category] ?? 'Unknown'; + return 'Snowbreak: Containment Zone - ' . $categoryName; + } +} \ No newline at end of file