1
0
Fork 0
forked from blallo/rss-bridge

[bridges] Shimmie v2 based imageboards derive from DanbooruBridge

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-09-04 01:25:05 +02:00
parent fd6bcbbafe
commit e7f2bf19f3
4 changed files with 39 additions and 95 deletions

View file

@ -1,41 +1,11 @@
<?php <?php
class DollbooruBridge extends BridgeAbstract{ require_once('Shimmie2Bridge.php');
class DollbooruBridge extends Shimmie2Bridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Dollbooru"; const NAME = "Dollbooru";
const URI = "http://dollbooru.org/"; const URI = "http://dollbooru.org/";
const DESCRIPTION = "Returns images from given page"; 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
}
} }

View file

@ -1,39 +1,11 @@
<?php <?php
class MilbooruBridge extends BridgeAbstract{ require_once('Shimmie2Bridge.php');
class MilbooruBridge extends Shimmie2Bridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Milbooru"; const NAME = "Milbooru";
const URI = "http://sheslostcontrol.net/moe/shimmie/"; const URI = "http://sheslostcontrol.net/moe/shimmie/";
const DESCRIPTION = "Returns images from given page"; 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
}
} }

View file

@ -1,39 +1,10 @@
<?php <?php
class Rule34pahealBridge extends BridgeAbstract{ require_once('Shimmie2Bridge.php');
class Rule34pahealBridge extends Shimmie2Bridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Rule34paheal"; const NAME = "Rule34paheal";
const URI = "http://rule34.paheal.net/"; const URI = "http://rule34.paheal.net/";
const DESCRIPTION = "Returns images from given page"; 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
}
} }

View file

@ -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;
}
}