Merge branch 'fixIndividualBridges' of https://framagit.org/peetah/rss-bridge
This commit is contained in:
commit
d98bb25de6
4 changed files with 56 additions and 39 deletions
|
@ -7,7 +7,7 @@ class AcrimedBridge extends FeedExpander {
|
||||||
const DESCRIPTION = "Returns the newest articles.";
|
const DESCRIPTION = "Returns the newest articles.";
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$this->collectExpandableDatas("http://www.acrimed.org/spip.php?page=backend");
|
$this->collectExpandableDatas(static::URI.'spip.php?page=backend');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseItem($newsItem){
|
protected function parseItem($newsItem){
|
||||||
|
@ -16,7 +16,7 @@ class AcrimedBridge extends FeedExpander {
|
||||||
$hs = new HTMLSanitizer();
|
$hs = new HTMLSanitizer();
|
||||||
$articlePage = $this->getSimpleHTMLDOM($newsItem->link);
|
$articlePage = $this->getSimpleHTMLDOM($newsItem->link);
|
||||||
$article = $hs->sanitize($articlePage->find('article.article1', 0)->innertext);
|
$article = $hs->sanitize($articlePage->find('article.article1', 0)->innertext);
|
||||||
$article = HTMLSanitizer::defaultImageSrcTo($article, "http://www.acrimed.org/");
|
$article = HTMLSanitizer::defaultImageSrcTo($article, static::URI);
|
||||||
$item['content'] = $article;
|
$item['content'] = $article;
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
|
|
|
@ -3,35 +3,35 @@ class FourchanBridge extends BridgeAbstract{
|
||||||
|
|
||||||
const MAINTAINER = "mitsukarenai";
|
const MAINTAINER = "mitsukarenai";
|
||||||
const NAME = "4chan";
|
const NAME = "4chan";
|
||||||
const URI = "https://www.4chan.org/";
|
const URI = "https://boards.4chan.org/";
|
||||||
const DESCRIPTION = "Returns posts from the specified thread";
|
const DESCRIPTION = "Returns posts from the specified thread";
|
||||||
|
|
||||||
const PARAMETERS = array( array(
|
const PARAMETERS = array( array(
|
||||||
|
'c'=>array(
|
||||||
|
'name'=>'Thread category',
|
||||||
|
'required'=>true
|
||||||
|
),
|
||||||
't'=>array(
|
't'=>array(
|
||||||
'name'=>'Thread URL',
|
'name'=>'Thread number',
|
||||||
'pattern'=>'(https:\/\/)?boards\.4chan\.org\/.*thread\/.*',
|
'type'=>'number',
|
||||||
'required'=>true
|
'required'=>true
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
public function getURI(){
|
||||||
|
return static::URI.$this->getInput('c').'/thread/'.$this->getInput('t');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
||||||
$thread = parse_url($this->getInput('t'))
|
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||||
or $this->returnClientError('This URL seems malformed, please check it.');
|
|
||||||
if($thread['host'] !== 'boards.4chan.org')
|
|
||||||
$this->returnClientError('4chan thread URL only.');
|
|
||||||
|
|
||||||
if(strpos($thread['path'], 'thread/') === FALSE)
|
|
||||||
$this->returnClientError('You must specify the thread URL.');
|
|
||||||
|
|
||||||
$url = 'https://boards.4chan.org'.$thread['path'];
|
|
||||||
$html = $this->getSimpleHTMLDOM($url)
|
|
||||||
or $this->returnServerError("Could not request 4chan, thread not found");
|
or $this->returnServerError("Could not request 4chan, thread not found");
|
||||||
|
|
||||||
foreach($html->find('div.postContainer') as $element) {
|
foreach($html->find('div.postContainer') as $element) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['id'] = $element->find('.post', 0)->getAttribute('id');
|
$item['id'] = $element->find('.post', 0)->getAttribute('id');
|
||||||
$item['uri'] = $url.'#'.$item['id'];
|
$item['uri'] = $this->getURI().'#'.$item['id'];
|
||||||
$item['timestamp'] = $element->find('span.dateTime', 0)->getAttribute('data-utc');
|
$item['timestamp'] = $element->find('span.dateTime', 0)->getAttribute('data-utc');
|
||||||
$item['author'] = $element->find('span.name', 0)->plaintext;
|
$item['author'] = $element->find('span.name', 0)->plaintext;
|
||||||
|
|
||||||
|
@ -45,10 +45,21 @@ class FourchanBridge extends BridgeAbstract{
|
||||||
if(!empty($element->find('span.subject', 0)->innertext )) {
|
if(!empty($element->find('span.subject', 0)->innertext )) {
|
||||||
$item['subject'] = $element->find('span.subject', 0)->innertext;
|
$item['subject'] = $element->find('span.subject', 0)->innertext;
|
||||||
}
|
}
|
||||||
$item['title'] = (isset($item['subject']) ? $item['subject'].' - ' : '' ) . 'reply '.$item['id'].' | '.$item['author'];
|
|
||||||
|
|
||||||
|
$item['title'] = 'reply '.$item['id'].' | '.$item['author'];
|
||||||
|
if(isset($item['subject'])){
|
||||||
|
$item['title'] = $item['subject'].' - '.$item['title'];
|
||||||
|
}
|
||||||
|
|
||||||
$item['content'] = (isset($item['image']) ? '<a href="'.$item['image'].'"><img alt="'.$item['id'].'" src="'.$item['imageThumb'].'" /></a><br>' : '') . '<span id="'.$item['id'].'">'.$element->find('.postMessage', 0)->innertext.'</span>';
|
$content = $element->find('.postMessage', 0)->innertext;
|
||||||
|
$content = str_replace('href="#p','href="'.$this->getURI().'#p',$content);
|
||||||
|
$item['content'] = '<span id="'.$item['id'].'">'.$content.'</span>';
|
||||||
|
if(isset($item['image'])){
|
||||||
|
$item['content'] = '<a href="'.$item['image'].'">'
|
||||||
|
.'<img alt="'.$item['id'].'" src="'.$item['imageThumb'].'" />'
|
||||||
|
.'</a><br>'
|
||||||
|
.$item['content'];
|
||||||
|
}
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
$this->items = array_reverse($this->items);
|
$this->items = array_reverse($this->items);
|
||||||
|
|
|
@ -7,23 +7,22 @@ class NovelUpdatesBridge extends BridgeAbstract{
|
||||||
const DESCRIPTION = "Returns releases from Novel Updates";
|
const DESCRIPTION = "Returns releases from Novel Updates";
|
||||||
const PARAMETERS = array( array(
|
const PARAMETERS = array( array(
|
||||||
'n'=>array(
|
'n'=>array(
|
||||||
'name'=>'Novel URL',
|
'name'=>'Novel name as found in the url',
|
||||||
'patterns'=>'http:\/\/www.novelupdates.com\/.*',
|
'exampleValue'=>'spirit-realm',
|
||||||
'required'=>true
|
'required'=>true
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
private $seriesTitle='';
|
private $seriesTitle='';
|
||||||
|
|
||||||
|
public function getURI(){
|
||||||
|
return static::URI.'/series/'.$this->getInput('n').'/';
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$thread = parse_url($this->getInput('n'))
|
$fullhtml = $this->getSimpleHTMLDOM($this->getURI())
|
||||||
or $this->returnClientError('This URL seems malformed, please check it.');
|
or $this->returnServerError('Could not request NovelUpdates, novel "'.$this->getInput('n').'" not found');
|
||||||
if($thread['host'] !== 'www.novelupdates.com')
|
|
||||||
$this->returnClientError('NovelUpdates URL only.');
|
|
||||||
if(strpos($thread['path'], 'series/') === FALSE)
|
|
||||||
$this->returnClientError('You must specify the novel URL.');
|
|
||||||
$url = self::URI.$thread['path'].'';
|
|
||||||
$fullhtml = $this->getSimpleHTMLDOM($url) or $this->returnServerError("Could not request NovelUpdates, novel not found");
|
|
||||||
$this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext;
|
$this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext;
|
||||||
// dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259
|
// dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259
|
||||||
// forcefully removes tbody
|
// forcefully removes tbody
|
||||||
|
@ -37,13 +36,17 @@ class NovelUpdatesBridge extends BridgeAbstract{
|
||||||
$item['title'] = $element->find('td', 2)->find('a', 0)->plaintext;
|
$item['title'] = $element->find('td', 2)->find('a', 0)->plaintext;
|
||||||
$item['team'] = $element->find('td', 1)->innertext;
|
$item['team'] = $element->find('td', 1)->innertext;
|
||||||
$item['timestamp'] = strtotime($element->find('td', 0)->plaintext);
|
$item['timestamp'] = strtotime($element->find('td', 0)->plaintext);
|
||||||
$item['content'] = '<a href="'.$item['uri'].'">'.$this->seriesTitle.' - '.$item['title'].'</a> by '.$item['team'].'<br><a href="'.$item['uri'].'">'.$fullhtml->find('div.seriesimg', 0)->innertext.'</a>';
|
$item['content'] =
|
||||||
|
'<a href="'.$item['uri'].'">'
|
||||||
|
.$this->seriesTitle.' - '.$item['title']
|
||||||
|
.'</a> by '.$item['team'].'<br>'
|
||||||
|
.'<a href="'.$item['uri'].'">'.$fullhtml->find('div.seriesimg', 0)->innertext.'</a>';
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return (!empty($this->seriesTitle) ? $this->seriesTitle.' - ' : '') .'Novel Updates';
|
return $this->seriesTitle. ' - ' . static::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheDuration(){
|
public function getCacheDuration(){
|
||||||
|
|
|
@ -6,18 +6,21 @@ class VkBridge extends BridgeAbstract {
|
||||||
const NAME = "VK.com";
|
const NAME = "VK.com";
|
||||||
const URI = "http://vk.com/";
|
const URI = "http://vk.com/";
|
||||||
const DESCRIPTION = "Working with open pages";
|
const DESCRIPTION = "Working with open pages";
|
||||||
const PARAMETERS=array(
|
const PARAMETERS=array( array(
|
||||||
'Url on page group or user' => array(
|
|
||||||
'u'=>array(
|
'u'=>array(
|
||||||
'name'=>'Url',
|
'name'=>'Group or user name',
|
||||||
'required'=>true
|
'required'=>true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function getURI(){
|
||||||
|
return static::URI.urlencode($this->getInput('u'));
|
||||||
|
}
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$text_html = $this->getContents(urldecode($this->getInput('u')))
|
$text_html = $this->getContents($this->getURI())
|
||||||
or $this->returnServerError('No results for this query.');
|
or $this->returnServerError('No results for group or user name "'.$this->getInput('u').'".');
|
||||||
|
|
||||||
$text_html = iconv('windows-1251', 'utf-8', $text_html);
|
$text_html = iconv('windows-1251', 'utf-8', $text_html);
|
||||||
$html = str_get_html($text_html);
|
$html = str_get_html($text_html);
|
||||||
foreach ($html->find('div.post_table') as $post) {
|
foreach ($html->find('div.post_table') as $post) {
|
||||||
|
|
Loading…
Reference in a new issue