mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 09:35:28 +03:00
[BakaUpdatesMangaReleasesBridge] Add new bridge (#999)
This commit is contained in:
parent
37d882a8d5
commit
493e76e4b9
1 changed files with 93 additions and 0 deletions
93
bridges/BakaUpdatesMangaReleasesBridge.php
Normal file
93
bridges/BakaUpdatesMangaReleasesBridge.php
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
class BakaUpdatesMangaReleasesBridge extends BridgeAbstract {
|
||||
const NAME = 'Baka Updates Manga Releases';
|
||||
const URI = 'https://www.mangaupdates.com/';
|
||||
const DESCRIPTION = 'Get the latest series releases';
|
||||
const MAINTAINER = 'fulmeek';
|
||||
const PARAMETERS = array(array(
|
||||
'series_id' => array(
|
||||
'name' => 'Series ID',
|
||||
'type' => 'number',
|
||||
'required' => true,
|
||||
'exampleValue' => '12345'
|
||||
)
|
||||
));
|
||||
const LIMIT_ITEMS = 10;
|
||||
|
||||
private $feedName = '';
|
||||
|
||||
public function collectData() {
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Series not found');
|
||||
|
||||
$objTitle = $html->find('td[class="text pad"]', 1);
|
||||
if ($objTitle)
|
||||
$this->feedName = $objTitle->plaintext;
|
||||
|
||||
$itemlist = $html->find('td#main_content table table table tr');
|
||||
if (!$itemlist)
|
||||
returnServerError('No releases');
|
||||
|
||||
$limit = self::LIMIT_ITEMS;
|
||||
foreach($itemlist as $element) {
|
||||
$cols = $element->find('td[class="text pad"]');
|
||||
if (!$cols)
|
||||
continue;
|
||||
if ($limit <= 0)
|
||||
break;
|
||||
|
||||
$item = array();
|
||||
$title = array();
|
||||
|
||||
$item['content'] = '';
|
||||
|
||||
$objDate = $cols[0];
|
||||
if ($objDate)
|
||||
$item['timestamp'] = strtotime($objDate->plaintext);
|
||||
|
||||
$objTitle = $cols[1];
|
||||
if ($objTitle) {
|
||||
$title[] = html_entity_decode($objTitle->plaintext);
|
||||
$item['content'] .= '<p>Series: ' . $objTitle->innertext . '</p>';
|
||||
}
|
||||
|
||||
$objVolume = $cols[2];
|
||||
if ($objVolume && !empty($objVolume->plaintext))
|
||||
$title[] = 'Vol.' . $objVolume->plaintext;
|
||||
|
||||
$objChapter = $cols[3];
|
||||
if ($objChapter && !empty($objChapter->plaintext))
|
||||
$title[] = 'Chp.' . $objChapter->plaintext;
|
||||
|
||||
$objAuthor = $cols[4];
|
||||
if ($objAuthor && !empty($objAuthor->plaintext)) {
|
||||
$item['author'] = html_entity_decode($objAuthor->plaintext);
|
||||
$item['content'] .= '<p>Groups: ' . $objAuthor->innertext . '</p>';
|
||||
}
|
||||
|
||||
$item['title'] = implode(' ', $title);
|
||||
$item['uri'] = $this->getURI() . '#' . hash('sha1', $item['title']);
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
if(count($this->items) >= $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
$series_id = $this->getInput('series_id');
|
||||
if (!empty($series_id)) {
|
||||
return self::URI . 'releases.html?search=' . $series_id . '&stype=series';
|
||||
}
|
||||
return self::URI;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!empty($this->feedName)) {
|
||||
return $this->feedName . ' - ' . self::NAME;
|
||||
}
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue