-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bridges] Shimmie v2 based imageboards derive from DanbooruBridge
Signed-off-by: Pierre Mazière <[email protected]>
- Loading branch information
Pierre Mazière
committed
Sep 3, 2016
1 parent
fd6bcbb
commit e7f2bf1
Showing
4 changed files
with
39 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,11 @@ | ||
<?php | ||
class DollbooruBridge extends BridgeAbstract{ | ||
require_once('Shimmie2Bridge.php'); | ||
|
||
class DollbooruBridge extends Shimmie2Bridge{ | ||
|
||
const MAINTAINER = "mitsukarenai"; | ||
const NAME = "Dollbooru"; | ||
const URI = "http://dollbooru.org/"; | ||
const DESCRIPTION = "Returns images from given page"; | ||
|
||
|
||
const PARAMETERS = array( array( | ||
'p'=>array( | ||
'name'=>'page', | ||
'type'=>'number' | ||
), | ||
't'=>array('name'=>'tags') | ||
)); | ||
|
||
public function collectData(){ | ||
$page=$this->getInput('p'); | ||
$tags = urlencode($this->getInput('t')); | ||
$html = $this->getSimpleHTMLDOM(self::URI."post/list/$tags/$page") | ||
or $this->returnServerError('Could not request Dollbooru.'); | ||
|
||
|
||
foreach($html->find('div[class=shm-image-list] a') as $element) { | ||
$item = array(); | ||
$item['uri'] = self::URI.$element->href; | ||
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-post-id')); | ||
$item['timestamp'] = time(); | ||
$thumbnailUri = self::URI.$element->find('img', 0)->src; | ||
$item['tags'] = $element->getAttribute('data-tags'); | ||
$item['title'] = 'Dollbooru | '.$item['postid']; | ||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags']; | ||
$this->items[] = $item; | ||
} | ||
} | ||
|
||
public function getCacheDuration(){ | ||
return 1800; // 30 minutes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,11 @@ | ||
<?php | ||
class MilbooruBridge extends BridgeAbstract{ | ||
require_once('Shimmie2Bridge.php'); | ||
|
||
class MilbooruBridge extends Shimmie2Bridge{ | ||
|
||
const MAINTAINER = "mitsukarenai"; | ||
const NAME = "Milbooru"; | ||
const URI = "http://sheslostcontrol.net/moe/shimmie/"; | ||
const DESCRIPTION = "Returns images from given page"; | ||
|
||
const PARAMETERS = array( array( | ||
'p'=>array( | ||
'name'=>'page', | ||
'type'=>'number' | ||
), | ||
't'=>array('name'=>'tags') | ||
)); | ||
|
||
public function collectData(){ | ||
$html = $this->getSimpleHTMLDOM( | ||
self::URI.'?q=/post/list/'.urlencode($this->getInput('t')).'/'.$this->getInput('p') | ||
)or $this->returnServerError('Could not request Milbooru.'); | ||
|
||
foreach($html->find('div[class=shm-image-list] span[class=thumb]') as $element) { | ||
$item = array(); | ||
$item['uri'] = self::URI.$element->find('a', 0)->href; | ||
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('a', 0)->getAttribute('data-post-id')); | ||
$item['timestamp'] = time(); | ||
$thumbnailUri = self::URI.$element->find('img', 0)->src; | ||
$item['tags'] = $element->find('a', 0)->getAttribute('data-tags'); | ||
$item['title'] = 'Milbooru | '.$item['postid']; | ||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags']; | ||
$this->items[] = $item; | ||
} | ||
} | ||
|
||
public function getCacheDuration(){ | ||
return 1800; // 30 minutes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,10 @@ | ||
<?php | ||
class Rule34pahealBridge extends BridgeAbstract{ | ||
require_once('Shimmie2Bridge.php'); | ||
|
||
class Rule34pahealBridge extends Shimmie2Bridge{ | ||
|
||
const MAINTAINER = "mitsukarenai"; | ||
const NAME = "Rule34paheal"; | ||
const URI = "http://rule34.paheal.net/"; | ||
const DESCRIPTION = "Returns images from given page"; | ||
|
||
const PARAMETERS = array( array( | ||
'p'=>array( | ||
'name'=>'page', | ||
'type'=>'number' | ||
), | ||
't'=>array('name'=>'tags') | ||
)); | ||
|
||
|
||
public function collectData(){ | ||
$html = $this->getSimpleHTMLDOM(self::URI.'post/list/'.$tags.'/'.$page) | ||
or $this->returnServerError('Could not request Rule34paheal.'); | ||
|
||
|
||
foreach($html->find('div[class=shm-image-list] div[class=shm-thumb]') as $element) { | ||
$item = array(); | ||
$item['uri'] = self::URI.$element->find('a', 0)->href; | ||
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('img', 0)->getAttribute('id')); | ||
$item['timestamp'] = time(); | ||
$thumbnailUri = $element->find('img', 0)->src; | ||
$item['tags'] = $element->getAttribute('data-tags'); | ||
$item['title'] = 'Rule34paheal | '.$item['postid']; | ||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags']; | ||
$this->items[] = $item; | ||
} | ||
} | ||
|
||
public function getCacheDuration(){ | ||
return 1800; // 30 minutes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
require_once('DanbooruBridge.php'); | ||
|
||
class Shimmie2Bridge extends DanbooruBridge{ | ||
|
||
const NAME = "Shimmie v2"; | ||
const URI = "http://shimmie.shishnet.org/v2/"; | ||
const DESCRIPTION = "Returns images from given page"; | ||
|
||
const PATHTODATA='.shm-thumb-link'; | ||
const IDATTRIBUTE='data-post-id'; | ||
|
||
protected function getFullURI(){ | ||
return $this->getURI().'post/list/' | ||
.$this->getInput('t').'/' | ||
.$this->getInput('p'); | ||
} | ||
|
||
protected function getItemFromElement($element){ | ||
$item = array(); | ||
$item['uri'] = $this->getURI().$element->href; | ||
$item['id'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute(static::IDATTRIBUTE)); | ||
$item['timestamp'] = time(); | ||
$thumbnailUri = $this->getURI().$element->find('img', 0)->src; | ||
$item['tags'] = $element->getAttribute('data-tags'); | ||
$item['title'] = $this->getName().' | '.$item['id']; | ||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags']; | ||
return $item; | ||
} | ||
|
||
} |