1
0
Files
Bridges/PokemonGOBridge.php
Akamaru efbc4f60da Übernehme Bridges von Brawl
- GenshinImpactNewsBridge
- HolonometriaMangaBridge
- PokemonGOBridge
2025-07-03 21:32:20 +02:00

95 lines
3.2 KiB
PHP

<?php
class PokemonGOBridge extends BridgeAbstract {
const MAINTAINER = 'Brawl, Akamaru';
const NAME = 'Pokémon GO News';
const URI = 'https://pokemongo.com/';
const CACHE_TIMEOUT = 21600; // 21600 = 6h
const DESCRIPTION = 'Get the latest official "Pokémon GO" news.';
const PARAMETERS = array(
array(
'lang' => array(
'name' => 'Language',
'type' => 'list',
'values' => array(
'English' => 'en',
'繁體中文' => 'zh_hant',
'Français' => 'fr',
'Deutsch' => 'de',
'Italiano' => 'it',
'日本語' => 'ja',
'한국어' => 'ko',
'Português' => 'pt_br',
'Español' => 'es',
'Español (México)' => 'es_mx',
'Polski' => 'pl',
'Русский' => 'ru',
'हिन्दी' => 'hi',
'Bahasa Indonesia' => 'id',
'ไทย' => 'th',
'Türkçe' => 'tr',
),
'defaultValue' => 'en'
)
)
);
public function getIcon(){
return 'https://pokemongo.com/img/icons/favicon.ico';
}
public function collectData() {
$lang = $this->getInput('lang');
$pageUrl = self::URI . $lang . '/news';
$html = getSimpleHTMLDOM($pageUrl)
or returnServerError('Konnte die Webseite nicht laden: ' . $pageUrl);
// Finde alle News-Karten
foreach($html->find('a._newsCard_119ao_16') as $element) {
if(count($this->items) >= 10) break;
// Titel
$contentDiv = $element->find('div._newsCardContent_119ao_59', 0);
$title = '';
if ($contentDiv) {
$titleDiv = $contentDiv->find('div', 1); // Das zweite <div> ist der Titel
if ($titleDiv) {
$title = trim($titleDiv->plaintext);
}
}
// Link
$href = $element->href;
if(strpos($href, 'http') !== 0) {
$uri = rtrim(self::URI, '/') . $href;
} else {
$uri = $href;
}
// Datum
$dateElement = $element->find('pg-date-format', 0);
$timestamp = null;
if ($dateElement && isset($dateElement->timestamp)) {
$timestamp = intval($dateElement->timestamp / 1000); // JS ms -> s
}
// Bild
$imgElement = $element->find('img', 0);
$imgHtml = '';
if ($imgElement && isset($imgElement->src)) {
$imgHtml = '<img src="' . htmlspecialchars($imgElement->src) . '" alt="" style="max-width:100%;height:auto;" />';
}
// Content (nur Bild, da kein Teasertext im Listing)
$content = $imgHtml;
$item = array();
$item['uri'] = $uri;
$item['title'] = $title;
if ($timestamp) $item['timestamp'] = $timestamp;
$item['content'] = $content;
$this->items[] = $item;
}
}
}