73 lines
2.5 KiB
PHP
73 lines
2.5 KiB
PHP
<?php
|
|
class CUIIBridge extends BridgeAbstract
|
|
{
|
|
|
|
const MAINTAINER = 'Brawl, ChatGPT';
|
|
const NAME = 'CUII-Sperrungen';
|
|
const URI = 'https://cuii.info/empfehlungen/';
|
|
const CACHE_TIMEOUT = 21600; // 21600 = 6h
|
|
const DESCRIPTION = 'Zeigt die neuesten Sperrungen der CUII (Clearingstelle Urheberrecht im Internet)';
|
|
|
|
public function getIcon()
|
|
{
|
|
return 'https://cuii.info/typo3conf/ext/cuii_template/Resources/Public/Images/favicon.png';
|
|
}
|
|
|
|
public function collectData()
|
|
{
|
|
$html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request cuii.info.');
|
|
|
|
foreach ($html->find('.card') as $card) {
|
|
$item = array();
|
|
|
|
$title = $card->find('span[itemprop=text]', 0);
|
|
if ($title) {
|
|
$item['title'] = $title->plaintext;
|
|
|
|
$pattern = '/vom ([0-9]{1,2}\\. [a-zA-ZäöüÄÖÜß]+ [0-9]{4})/';
|
|
preg_match($pattern, $item['title'], $matches);
|
|
if (!empty($matches)) {
|
|
$date_parts = explode(' ', $matches[1]);
|
|
$date_parts[1] = $this->translateMonth($date_parts[1]);
|
|
$english_date = implode(' ', $date_parts);
|
|
$date = DateTime::createFromFormat('d. F Y', $english_date);
|
|
if ($date !== false) {
|
|
$date->setTime(0, 0);
|
|
$item['timestamp'] = $date->getTimestamp();
|
|
}
|
|
}
|
|
}
|
|
|
|
$pdf_link = $card->find('p.pdf a', 0);
|
|
if ($pdf_link) {
|
|
$item['uri'] = 'https://cuii.info' . $pdf_link->href;
|
|
$item['uid'] = $item['uri'];
|
|
$item['content'] = '<a href="' . $item['uri'] . '">Empfehlung zum Download als PDF</a>';
|
|
} else {
|
|
$item['content'] = 'Empfehlung zum Download als PDF';
|
|
}
|
|
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
|
|
private function translateMonth($month)
|
|
{
|
|
$months = array(
|
|
'Januar' => 'January',
|
|
'Februar' => 'February',
|
|
'März' => 'March',
|
|
'April' => 'April',
|
|
'Mai' => 'May',
|
|
'Juni' => 'June',
|
|
'Juli' => 'July',
|
|
'August' => 'August',
|
|
'September' => 'September',
|
|
'Oktober' => 'October',
|
|
'November' => 'November',
|
|
'Dezember' => 'December'
|
|
);
|
|
return $months[$month] ?? $month;
|
|
}
|
|
}
|