From 2aba815b5597f73a2d3edfbfcb22101d096d256e Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sun, 10 Jan 2016 00:00:16 +0100 Subject: [PATCH] Implement new Bridge to mangareader.net This Bridge returns information about the last updates on mangareader.net --- bridges/MangareaderBridge.php | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 bridges/MangareaderBridge.php diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php new file mode 100644 index 00000000..8e61056d --- /dev/null +++ b/bridges/MangareaderBridge.php @@ -0,0 +1,77 @@ +maintainer = "logmanoriginal"; + $this->name = "Mangareader Bridge"; + $this->uri = "http://www.mangareader.net"; + $this->description = "Returns the latest Manga updates"; + $this->update = "2016-01-09"; + + $this->parameters["Get latest updates"] = '[]'; + + } + + public function collectData(array $param){ + + /* We'll use the DOM parser for this as it makes navigation easier */ + $html = file_get_contents("http://www.mangareader.net"); + $doc = new DomDocument; + @$doc->loadHTML($html); + + /* The latest updates are on the frontpage, navigate via XPath */ + $xpath = new DomXPath($doc); + + /* Query each item (consists of Manga + chapters) */ + $nodes = $xpath->query("//*[@id='latestchapters']/table//td"); + + foreach ($nodes as $node){ + /* Query the manga */ + $manga = $xpath->query("a[@class='chapter']", $node)->item(0); + + /* Collect the chapters for each Manga */ + $chapters = $xpath->query("a[@class='chaptersrec']", $node); + + if (isset($manga) && $chapters->length >= 1){ + $item = new \Item(); + $item->uri = 'http://www.mangareader.net' . htmlspecialchars($manga->getAttribute('href')); + $item->title = htmlspecialchars($manga->nodeValue); + + /* Add each chapter to the feed */ + $item->content = ""; + + foreach ($chapters as $chapter){ + if($item->content <> ""){ + $item->content .= "
"; + } + $item->content .= "" . htmlspecialchars($chapter->nodeValue) . ""; + } + + $this->items[] = $item; + } + } + + /* Return some dummy-data if no content available */ + if(count($this->items) == 0){ + $item = new \Item(); + $item->content = "

No updates available

"; + + $this->items[] = $item; + } + } + + public function getName(){ + return 'Mangareader Bridge'; + } + + public function getURI(){ + return 'http://www.mangareader.net'; + } + + public function getCacheDuration(){ + return 10800; // 3 hours + } +} +?>