Merge branch 'fixIndividualBridges' of https://framagit.org/peetah/rss-bridge

This commit is contained in:
logmanoriginal 2016-09-05 17:31:26 +02:00
commit d98bb25de6
4 changed files with 56 additions and 39 deletions

View file

@ -7,7 +7,7 @@ class AcrimedBridge extends FeedExpander {
const DESCRIPTION = "Returns the newest articles.";
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){
@ -16,7 +16,7 @@ class AcrimedBridge extends FeedExpander {
$hs = new HTMLSanitizer();
$articlePage = $this->getSimpleHTMLDOM($newsItem->link);
$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;
return $item;

View file

@ -3,35 +3,35 @@ class FourchanBridge extends BridgeAbstract{
const MAINTAINER = "mitsukarenai";
const NAME = "4chan";
const URI = "https://www.4chan.org/";
const URI = "https://boards.4chan.org/";
const DESCRIPTION = "Returns posts from the specified thread";
const PARAMETERS = array( array(
'c'=>array(
'name'=>'Thread category',
'required'=>true
),
't'=>array(
'name'=>'Thread URL',
'pattern'=>'(https:\/\/)?boards\.4chan\.org\/.*thread\/.*',
'name'=>'Thread number',
'type'=>'number',
'required'=>true
)
));
public function getURI(){
return static::URI.$this->getInput('c').'/thread/'.$this->getInput('t');
}
public function collectData(){
$thread = parse_url($this->getInput('t'))
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)
$html = $this->getSimpleHTMLDOM($this->getURI())
or $this->returnServerError("Could not request 4chan, thread not found");
foreach($html->find('div.postContainer') as $element) {
$item = array();
$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['author'] = $element->find('span.name', 0)->plaintext;
@ -45,10 +45,21 @@ class FourchanBridge extends BridgeAbstract{
if(!empty($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 = array_reverse($this->items);

View file

@ -7,23 +7,22 @@ class NovelUpdatesBridge extends BridgeAbstract{
const DESCRIPTION = "Returns releases from Novel Updates";
const PARAMETERS = array( array(
'n'=>array(
'name'=>'Novel URL',
'patterns'=>'http:\/\/www.novelupdates.com\/.*',
'name'=>'Novel name as found in the url',
'exampleValue'=>'spirit-realm',
'required'=>true
)
));
private $seriesTitle='';
public function getURI(){
return static::URI.'/series/'.$this->getInput('n').'/';
}
public function collectData(){
$thread = parse_url($this->getInput('n'))
or $this->returnClientError('This URL seems malformed, please check it.');
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");
$fullhtml = $this->getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Could not request NovelUpdates, novel "'.$this->getInput('n').'" not found');
$this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext;
// dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259
// forcefully removes tbody
@ -37,13 +36,17 @@ class NovelUpdatesBridge extends BridgeAbstract{
$item['title'] = $element->find('td', 2)->find('a', 0)->plaintext;
$item['team'] = $element->find('td', 1)->innertext;
$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;
}
}
public function getName(){
return (!empty($this->seriesTitle) ? $this->seriesTitle.' - ' : '') .'Novel Updates';
return $this->seriesTitle. ' - ' . static::NAME;
}
public function getCacheDuration(){

View file

@ -6,18 +6,21 @@ class VkBridge extends BridgeAbstract {
const NAME = "VK.com";
const URI = "http://vk.com/";
const DESCRIPTION = "Working with open pages";
const PARAMETERS=array(
'Url on page group or user' => array(
const PARAMETERS=array( array(
'u'=>array(
'name'=>'Url',
'name'=>'Group or user name',
'required'=>true
)
)
);
public function getURI(){
return static::URI.urlencode($this->getInput('u'));
}
public function collectData(){
$text_html = $this->getContents(urldecode($this->getInput('u')))
or $this->returnServerError('No results for this query.');
$text_html = $this->getContents($this->getURI())
or $this->returnServerError('No results for group or user name "'.$this->getInput('u').'".');
$text_html = iconv('windows-1251', 'utf-8', $text_html);
$html = str_get_html($text_html);
foreach ($html->find('div.post_table') as $post) {