[Mangareader] Add functions to collect data
This commit is contained in:
parent
f9a8f16685
commit
99f00e57b5
1 changed files with 103 additions and 97 deletions
|
@ -94,7 +94,38 @@ class MangareaderBridge extends BridgeAbstract {
|
|||
switch($this->queriedContext){
|
||||
case 'Get latest updates':
|
||||
$this->request = 'Latest updates';
|
||||
$this->get_latest_updates($xpath);
|
||||
break;
|
||||
case 'Get popular mangas':
|
||||
// Find manga name within "Popular mangas for ..."
|
||||
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
|
||||
$this->request = substr($pagetitle, 0, strrpos($pagetitle, " -"));
|
||||
$this->get_popular_mangas($xpath);
|
||||
break;
|
||||
case 'Get manga updates':
|
||||
$limit = $this->getInput('limit');
|
||||
if(empty($limit)){
|
||||
$limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue'];
|
||||
}
|
||||
|
||||
$this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")
|
||||
->item(0)
|
||||
->nodeValue;
|
||||
|
||||
$this->get_manga_updates($xpath, $limit);
|
||||
break;
|
||||
}
|
||||
|
||||
// Return some dummy-data if no content available
|
||||
if(empty($this->items)){
|
||||
$item = array();
|
||||
$item['content'] = "<p>No updates available</p>";
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_latest_updates($xpath){
|
||||
// Query each item (consists of Manga + chapters)
|
||||
$nodes = $xpath->query("//*[@id='latestchapters']/table//td");
|
||||
|
||||
|
@ -129,14 +160,9 @@ class MangareaderBridge extends BridgeAbstract {
|
|||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Get popular mangas':
|
||||
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
|
||||
|
||||
// Find manga name within "Popular mangas for ..."
|
||||
$this->request = substr($pagetitle, 0, strrpos($pagetitle, " -"));
|
||||
}
|
||||
|
||||
private function get_popular_mangas($xpath){
|
||||
// Query all mangas
|
||||
$mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
|
||||
|
||||
|
@ -172,23 +198,13 @@ class MangareaderBridge extends BridgeAbstract {
|
|||
EOD;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Get manga updates':
|
||||
$limit = $this->getInput('limit');
|
||||
if(empty($limit)){
|
||||
$limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue'];
|
||||
}
|
||||
|
||||
$this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")
|
||||
->item(0)
|
||||
->nodeValue;
|
||||
|
||||
private function get_manga_updates($xpath, $limit){
|
||||
$query = "(.//*[@id='listing']//tr)[position() > 1]";
|
||||
|
||||
if($limit !== -1){
|
||||
$query =
|
||||
"(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]";
|
||||
$query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]";
|
||||
}
|
||||
|
||||
$chapters = $xpath->query($query);
|
||||
|
@ -206,16 +222,6 @@ EOD;
|
|||
->nodeValue);
|
||||
array_unshift($this->items, $item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Return some dummy-data if no content available
|
||||
if(empty($this->items)){
|
||||
$item = array();
|
||||
$item['content'] = "<p>No updates available</p>";
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
|
|
Loading…
Reference in a new issue