2021-05-13 21:35:42 +03:00
|
|
|
<?php
|
|
|
|
|
2022-01-10 13:44:18 +03:00
|
|
|
class ExplosmBridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2022-07-08 01:23:29 +03:00
|
|
|
const NAME = 'Explosm: Cyanide & Happiness';
|
|
|
|
const URI = 'https://explosm.net/';
|
|
|
|
const DESCRIPTION = 'A Webcomic by Kris Wilson, Rob DenBleyker, and Dave McElfatrick.';
|
|
|
|
const MAINTAINER = 'sal0max, bockiii';
|
|
|
|
const CACHE_TIMEOUT = 60 * 60 * 2; // 2 hours
|
|
|
|
const PARAMETERS = [[
|
2022-01-10 13:44:18 +03:00
|
|
|
'limit' => [
|
2022-07-08 01:23:29 +03:00
|
|
|
'name' => 'Limit',
|
2022-01-10 13:44:18 +03:00
|
|
|
'type' => 'number',
|
2022-07-08 01:23:29 +03:00
|
|
|
'title' => 'The number of recent comics to get.',
|
2022-01-10 13:44:18 +03:00
|
|
|
'defaultValue' => 5
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2022-07-08 01:23:29 +03:00
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return self::URI . 'favicon-32x32.png';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
return self::URI . 'comics/latest#comic';
|
|
|
|
}
|
2021-05-13 21:35:42 +03:00
|
|
|
|
|
|
|
public function collectData()
|
|
|
|
{
|
2022-01-10 13:44:18 +03:00
|
|
|
$limit = $this->getInput('limit');
|
2022-07-08 01:23:29 +03:00
|
|
|
$url = $this->getUri();
|
|
|
|
|
|
|
|
for ($i = 0; $i < $limit; $i++) {
|
|
|
|
$html = getSimpleHTMLDOM($url);
|
|
|
|
|
|
|
|
$element = $html->find('[class*=ComicImage]', 0);
|
|
|
|
$date = $element->find('[class^=Author__Right] p', 0)->plaintext;
|
|
|
|
$author = str_replace('by ', '', $element->find('[class^=Author__Right] p', 1)->plaintext);
|
|
|
|
$image = $element->find('img', 0)->src;
|
|
|
|
$link = $html->find('[rel=canonical]', 0)->href;
|
|
|
|
|
|
|
|
$item = [
|
|
|
|
'uid' => $link,
|
|
|
|
'author' => $author,
|
|
|
|
'title' => $date,
|
|
|
|
'uri' => $link . '#comic',
|
|
|
|
'timestamp' => str_replace('.', '-', $date) . 'T00:00:00Z',
|
|
|
|
'content' => "<img src=\"$image\" />"
|
|
|
|
];
|
2022-01-10 13:44:18 +03:00
|
|
|
$this->items[] = $item;
|
2022-07-08 01:23:29 +03:00
|
|
|
|
|
|
|
// get next url
|
|
|
|
$url = self::URI . $html->find('[class*=ComicSelector]>a', 0)->href;
|
2022-01-10 13:44:18 +03:00
|
|
|
}
|
2021-05-13 21:35:42 +03:00
|
|
|
}
|
|
|
|
}
|