Übernehme Bridges von Brawl
- GenshinImpactNewsBridge - HolonometriaMangaBridge - PokemonGOBridge
This commit is contained in:
75
HolonometriaMangaBridge.php
Normal file
75
HolonometriaMangaBridge.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
class HolonometriaMangaBridge extends BridgeAbstract
|
||||
{
|
||||
const MAINTAINER = 'Brawl, Akamaru';
|
||||
const NAME = 'Holonometria Manga Series';
|
||||
const URI = 'https://holoearth.com/en/alt/holonometria/manga/';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = 'Get the latest chapters of the Holonometria Manga series.';
|
||||
|
||||
const PARAMETERS = [
|
||||
[
|
||||
'manga' => [
|
||||
'name' => 'Manga',
|
||||
'type' => 'list',
|
||||
'values' => [
|
||||
'Vesta de Cooking' => 'vestadecooking',
|
||||
'Underworld Academy Overload!!' => 'soreyukemakaigakko',
|
||||
'Yamato Phantasia' => 'yamatokasoukaiitan',
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return 'https://holoearth.com/assets/img/favicon_holonometria.ico';
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$manga = $this->getInput('manga');
|
||||
$pageUrl = self::URI . $manga . '/';
|
||||
$html = getSimpleHTMLDOM($pageUrl)
|
||||
or returnServerError('Konnte die Webseite nicht laden: ' . $pageUrl);
|
||||
|
||||
$items = [];
|
||||
foreach ($html->find('ul.manga-detail__list li.manga-detail__list-item') as $element) {
|
||||
$a = $element->find('a.manga-detail__list-link', 0);
|
||||
if (!$a) continue;
|
||||
$item = [];
|
||||
$item['uri'] = $a->href;
|
||||
$title = $a->find('p.manga-detail__list-title', 0);
|
||||
$date = $a->find('p.manga-detail__list-date', 0);
|
||||
$timestamp = null;
|
||||
$date_str = '';
|
||||
if ($date) {
|
||||
$date_raw = trim(strip_tags($date->innertext));
|
||||
if (preg_match('/^(\d{4})\.(\d{2})\.(\d{2})$/', $date_raw, $m)) {
|
||||
$timestamp = mktime(0, 0, 0, $m[2], $m[3], $m[1]);
|
||||
} else {
|
||||
$timestamp = strtotime($date_raw);
|
||||
}
|
||||
if ($timestamp && $timestamp > 0) {
|
||||
$date_str = ' (' . date('d.m.Y', $timestamp) . ')';
|
||||
$item['timestamp'] = $timestamp;
|
||||
}
|
||||
}
|
||||
$item['title'] = ($title ? trim(strip_tags($title->innertext)) : 'Kapitel') . $date_str;
|
||||
$thumb = $a->find('p.manga-detail__list-thumb img', 0);
|
||||
if ($thumb) {
|
||||
$item['enclosures'] = [$thumb->src];
|
||||
$item['content'] = '<img src="' . $thumb->src . '" />';
|
||||
}
|
||||
$item['uid'] = $item['uri'];
|
||||
$items[] = $item;
|
||||
}
|
||||
// Nach Datum absteigend sortieren (neustes zuerst, ohne 0-Timestamps)
|
||||
usort($items, function($a, $b) {
|
||||
$at = isset($a['timestamp']) ? $a['timestamp'] : 0;
|
||||
$bt = isset($b['timestamp']) ? $b['timestamp'] : 0;
|
||||
return $bt <=> $at;
|
||||
});
|
||||
$this->items = array_slice($items, 0, 15);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user