Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BakaUpdatesMangaReleasesBridge] reworked to parse new layout #1052

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions bridges/BakaUpdatesMangaReleasesBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BakaUpdatesMangaReleasesBridge extends BridgeAbstract {
'exampleValue' => '12345'
)
));
const LIMIT_COLS = 5;
const LIMIT_ITEMS = 10;

private $feedName = '';
Expand All @@ -20,21 +21,21 @@ 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)
// content is an unstructured pile of divs, ugly to parse
$cols = $html->find('div#main_content div.row > div.text');
if (!$cols)
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;
$rows = array_slice(
array_chunk($cols, self::LIMIT_COLS), 0, self::LIMIT_ITEMS
);

if (isset($rows[0][1])) {
$this->feedName = html_entity_decode($rows[0][1]->plaintext);
}

foreach($rows as $cols) {
if (count($cols) < self::LIMIT_COLS) continue;

$item = array();
$title = array();
Expand Down Expand Up @@ -65,14 +66,11 @@ public function collectData() {
$item['content'] .= '<p>Groups: ' . $objAuthor->innertext . '</p>';
}

$item['title'] = implode(' ', $title);
$item['uri'] = $this->getURI() . '#' . hash('sha1', $item['title']);
$item['title'] = implode(' ', $title);
$item['uri'] = $this->getURI();
$item['uid'] = hash('sha1', $item['title']);

$this->items[] = $item;

if(count($this->items) >= $limit) {
break;
}
}
}

Expand Down