forked from blallo/rss-bridge
[NotAlways] Add a bridge for the NotAlways family of sites (#537)
NotAlways right found it necessary to remove their RSS feeds recently. This is a *simple* bridge to grab the ones on the front page. It allows you to filter the articles based on their classification (right, working, romantic, related, learning, friendly, hopeless, unfiltered, or all).
This commit is contained in:
parent
887fc7b037
commit
a16ec196c5
1 changed files with 57 additions and 0 deletions
57
bridges/NotAlwaysBridge.php
Normal file
57
bridges/NotAlwaysBridge.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
class NotAlwaysBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'mozes';
|
||||
const NAME = 'Not Always family Bridge';
|
||||
const URI = 'https://notalwaysright.com/';
|
||||
const DESCRIPTION = 'Returns the latest stories';
|
||||
const CACHE_TIMEOUT = 1800; // 30 minutes
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'filter' => array(
|
||||
'type' => 'list',
|
||||
'name' => 'Filter',
|
||||
'values' => array(
|
||||
'All' => 'all',
|
||||
'Right' => 'right',
|
||||
'Working' => 'working',
|
||||
'Romantic' => 'romantic',
|
||||
'Related' => 'related',
|
||||
'Learning' => 'learning',
|
||||
'Friendly' => 'friendly',
|
||||
'Hopeless' => 'hopeless',
|
||||
'Unfiltered' => 'unfiltered'
|
||||
),
|
||||
'required' => true
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request NotAlways.');
|
||||
foreach($html->find('.post') as $post) {
|
||||
#print_r($post);
|
||||
$item = array();
|
||||
$item['uri'] = $post->find('h1', 0)->find('a', 0)->href;
|
||||
$item['content'] = $post;
|
||||
$item['title'] = $post->find('h1', 0)->find('a', 0)->innertext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('filter'))) {
|
||||
return $this->getInput('filter') . ' - NotAlways Bridge';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('filter'))) {
|
||||
return self::URI . $this->getInput('filter') . "/";
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue