');
- return $text;
- }
-
- $rssFeed = $this->getSimpleHTMLDOM($this->uri.'/feed')
- or $this->returnServerError('Could not request '.$this->uri.'/feed');
- $limit = 0;
-
- foreach($rssFeed->find('item') as $element) {
- if($limit < 15) {
- $item = array();
- $item['title'] = $element->find('title', 0)->innertext;
- $item['uri'] = $element->find('guid', 0)->plaintext;
- $item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
- $item['content'] = GizmodoFRExtractContent($item['uri']);
- $this->items[] = $item;
- $limit++;
- }
- }
-
- }
-
- public function getCacheDuration(){
- return 1800; // 30min
- }
-}
diff --git a/bridges/GooglePlusPostBridge.php b/bridges/GooglePlusPostBridge.php
index a55620f2..1c1e1d99 100644
--- a/bridges/GooglePlusPostBridge.php
+++ b/bridges/GooglePlusPostBridge.php
@@ -4,12 +4,13 @@ class GooglePlusPostBridge extends BridgeAbstract
protected $_title;
protected $_url;
- public $maintainer = "Grummfy";
- public $name = "Google Plus Post Bridge";
- public $uri = "https://plus.google.com/";
- public $description = "Returns user public post (without API).";
+ const MAINTAINER = "Grummfy";
+ const NAME = "Google Plus Post Bridge";
+ const URI = "https://plus.google.com/";
+ const CACHE_TIMEOUT = 600; //10min
+ const DESCRIPTION = "Returns user public post (without API).";
- public $parameters = array( array(
+ const PARAMETERS = array( array(
'username'=>array(
'name'=>'username or Id',
'required'=>true
@@ -19,13 +20,13 @@ class GooglePlusPostBridge extends BridgeAbstract
public function collectData()
{
// get content parsed
-// $html = $this->getSimpleHTMLDOM(__DIR__ . '/../posts2.html'
- $html = $this->getSimpleHTMLDOM($this->uri . urlencode($this->getInput('username')) . '/posts'
+// $html = getSimpleHTMLDOM(__DIR__ . '/../posts2.html'
+ $html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('username')) . '/posts'
// force language
, false, stream_context_create(array('http'=> array(
'header' => 'Accept-Language: fr,fr-be,fr-fr;q=0.8,en;q=0.4,en-us;q=0.2;*' . "\r\n"
)))
- ) OR $this->returnServerError('No results for this query.');
+ ) OR returnServerError('No results for this query.');
// get title, url, ... there is a lot of intresting stuff in meta
$this->_title = $html->find('meta[property]', 0)->getAttribute('content');
@@ -48,7 +49,7 @@ class GooglePlusPostBridge extends BridgeAbstract
// $item['title'] = $item['fullname'] = $post->find('header.lea', 0)->plaintext;
$item['avatar'] = $post->find('div.ys img', 0)->src;
// var_dump((($post->find('a.o-U-s', 0)->getAllAttributes())));
- $item['uri'] = $this->uri . $post->find('a.o-U-s', 0)->href;
+ $item['uri'] = self::URI . $post->find('a.o-U-s', 0)->href;
$item['timestamp'] = strtotime($post->find('a.o-U-s', 0)->plaintext);
$this->items[] = $item;
@@ -56,21 +57,21 @@ class GooglePlusPostBridge extends BridgeAbstract
$hashtags = array();
foreach($post->find('a.d-s') as $hashtag)
{
- $hashtags[ trim($hashtag->plaintext) ] = $this->uri . $hashtag->href;
+ $hashtags[ trim($hashtag->plaintext) ] = self::URI . $hashtag->href;
}
$item['content'] = '';
// avatar display
- $item['content'] .= '';
$content = $post->find('div.Al', 0);
// alter link
// $content = $content->innertext;
-// $content = str_replace('href="./', 'href="' . $this->uri, $content);
-// $content = str_replace('href="photos', 'href="' . $this->uri . 'photos', $content);
+// $content = str_replace('href="./', 'href="' . self::URI, $content);
+// $content = str_replace('href="photos', 'href="' . self::URI . 'photos', $content);
// XXX ugly but I don't have any idea how to do a better stuff, str_replace on link doesn't work as expected and ask too many checks
foreach($content->find('a') as $link)
{
@@ -86,7 +87,7 @@ class GooglePlusPostBridge extends BridgeAbstract
{
$link->href = substr($link->href, 1);
}
- $link->href = $this->uri . $link->href;
+ $link->href = self::URI . $link->href;
}
}
$content = $content->innertext;
@@ -107,11 +108,6 @@ class GooglePlusPostBridge extends BridgeAbstract
public function getURI()
{
- return $this->_url ?: $this->uri;
- }
-
- public function getCacheDuration()
- {
- return 1; // 600; // 10 minutes
+ return $this->_url ?: self::URI;
}
}
diff --git a/bridges/GoogleSearchBridge.php b/bridges/GoogleSearchBridge.php
index fb3d7403..53d8a953 100644
--- a/bridges/GoogleSearchBridge.php
+++ b/bridges/GoogleSearchBridge.php
@@ -9,12 +9,13 @@
*/
class GoogleSearchBridge extends BridgeAbstract{
- public $maintainer = "sebsauvage";
- public $name = "Google search";
- public $uri = "https://www.google.com/";
- public $description = "Returns most recent results from Google search.";
+ const MAINTAINER = "sebsauvage";
+ const NAME = "Google search";
+ const URI = "https://www.google.com/";
+ const CACHE_TIMEOUT = 1800; // 30min
+ const DESCRIPTION = "Returns most recent results from Google search.";
- public $parameters = array( array(
+ const PARAMETERS = array( array(
'q'=>array(
'name'=>"keyword",
'required'=>true
@@ -25,10 +26,10 @@ class GoogleSearchBridge extends BridgeAbstract{
public function collectData(){
$html = '';
- $html = $this->getSimpleHTMLDOM($this->uri
+ $html = getSimpleHTMLDOM(self::URI
.'search?q=' . urlencode($this->getInput('q'))
.'&num=100&complete=0&tbs=qdr:y,sbd:1')
- or $this->returnServerError('No results for this query.');
+ or returnServerError('No results for this query.');
$emIsRes = $html->find('div[id=ires]',0);
if( !is_null($emIsRes) ){
@@ -50,8 +51,4 @@ class GoogleSearchBridge extends BridgeAbstract{
public function getName(){
return $this->getInput('q') .' - Google search';
}
-
- public function getCacheDuration(){
- return 1800; // 30 minutes
- }
}
diff --git a/bridges/GuruMedBridge.php b/bridges/GuruMedBridge.php
deleted file mode 100644
index 297dc56d..00000000
--- a/bridges/GuruMedBridge.php
+++ /dev/null
@@ -1,32 +0,0 @@
-', '', $string);
- return $string;
- }
-
- public function collectData(){
- $html = $this->getSimpleHTMLDOM($this->uri.'feed')
- or $this->returnServerError('Could not request Gurumed.');
- $limit = 0;
-
- foreach($html->find('item') as $element) {
- if($limit < 5) {
- $item = array();
- $item['title'] = $this->GurumedStripCDATA($element->find('title', 0)->innertext);
- $item['uri'] = $this->GurumedStripCDATA($element->find('guid', 0)->plaintext);
- $item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
- $item['content'] = $this->GurumedStripCDATA(strip_tags($element->find('description', 0), '
'));
- $this->items[] = $item;
- $limit++;
- }
- }
- }
-}
diff --git a/bridges/HDWallpapersBridge.php b/bridges/HDWallpapersBridge.php
index fde1aaab..740b7005 100644
--- a/bridges/HDWallpapersBridge.php
+++ b/bridges/HDWallpapersBridge.php
@@ -1,11 +1,12 @@
array(
'name'=>'category',
'defaultValue'=>'latest_wallpapers'
@@ -29,8 +30,8 @@ class HDWallpapersBridge extends BridgeAbstract {
$lastpage = 1;
for ($page = 1; $page <= $lastpage; $page++) {
- $link = $this->uri.'/'.$category.'/page/'.$page;
- $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.');
+ $link = self::URI.'/'.$category.'/page/'.$page;
+ $html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.');
if ($page === 1) {
preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches);
@@ -42,10 +43,10 @@ class HDWallpapersBridge extends BridgeAbstract {
$item = array();
// http://www.hdwallpapers.in/download/yosemite_reflections-1680x1050.jpg
- $item['uri'] = $this->uri.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href);
+ $item['uri'] = self::URI.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href);
$item['timestamp'] = time();
$item['title'] = $element->find('p', 0)->text();
- $item['content'] = $item['title'].'
';
+ $item['content'] = $item['title'].'
';
$this->items[] = $item;
$num++;
@@ -58,8 +59,4 @@ class HDWallpapersBridge extends BridgeAbstract {
public function getName(){
return 'HDWallpapers - '.str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')).' ['.$this->getInput('r').']';
}
-
- public function getCacheDuration(){
- return 43200; // 12 hours
- }
}
diff --git a/bridges/HentaiHavenBridge.php b/bridges/HentaiHavenBridge.php
index e970d00d..f075cb6a 100644
--- a/bridges/HentaiHavenBridge.php
+++ b/bridges/HentaiHavenBridge.php
@@ -1,14 +1,15 @@
getSimpleHTMLDOM($this->uri)
- or $this->returnServerError('Could not request Hentai Haven.');
+ $html = getSimpleHTMLDOM(self::URI)
+ or returnServerError('Could not request Hentai Haven.');
foreach($html->find('div.zoe-grid') as $element) {
$item = array();
$item['uri'] = $element->find('div.brick-content h3 a', 0)->href;
@@ -19,8 +20,4 @@ class HentaiHavenBridge extends BridgeAbstract{
$this->items[] = $item;
}
}
-
- public function getCacheDuration(){
- return 21600; // 6 hours
- }
}
diff --git a/bridges/IdenticaBridge.php b/bridges/IdenticaBridge.php
index f99bde71..a0c3bb2e 100644
--- a/bridges/IdenticaBridge.php
+++ b/bridges/IdenticaBridge.php
@@ -1,12 +1,13 @@
array(
'name'=>'username',
'required'=>true
@@ -14,8 +15,8 @@ class IdenticaBridge extends BridgeAbstract{
));
public function collectData(){
- $html = $this->getSimpleHTMLDOM($this->getURI())
- or $this->returnServerError('Requested username can\'t be found.');
+ $html = getSimpleHTMLDOM($this->getURI())
+ or returnServerError('Requested username can\'t be found.');
foreach($html->find('li.major') as $dent) {
$item = array();
@@ -32,10 +33,6 @@ class IdenticaBridge extends BridgeAbstract{
}
public function getURI(){
- return $this->uri.urlencode($this->getInput('u'));
- }
-
- public function getCacheDuration(){
- return 300; // 5 minutes
+ return self::URI.urlencode($this->getInput('u'));
}
}
diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php
index bec19b2c..e3c4b511 100644
--- a/bridges/InstagramBridge.php
+++ b/bridges/InstagramBridge.php
@@ -1,12 +1,12 @@
array(
'name'=>'username',
'required'=>true
@@ -14,8 +14,8 @@ class InstagramBridge extends BridgeAbstract{
));
public function collectData(){
- $html = $this->getSimpleHTMLDOM($this->getURI())
- or $this->returnServerError('Could not request Instagram.');
+ $html = getSimpleHTMLDOM($this->getURI())
+ or returnServerError('Could not request Instagram.');
$innertext = null;
@@ -46,7 +46,7 @@ class InstagramBridge extends BridgeAbstract{
{
$item = array();
- $item['uri'] = $this->uri.'/p/'.$media->code.'/';
+ $item['uri'] = self::URI.'p/'.$media->code.'/';
$item['content'] = '
';
if (isset($media->caption))
{
@@ -65,7 +65,7 @@ class InstagramBridge extends BridgeAbstract{
}
public function getURI(){
- return $this->uri.urlencode($this->getInput('u'));
+ return self::URI.urlencode($this->getInput('u'));
}
}
diff --git a/bridges/IsoHuntBridge.php b/bridges/IsoHuntBridge.php
index f99ceef5..a95c85bb 100644
--- a/bridges/IsoHuntBridge.php
+++ b/bridges/IsoHuntBridge.php
@@ -1,11 +1,12 @@
uri;
+ $uri=self::URI;
switch($this->queriedContext){
case 'By "Latest" category':
switch($this->getInput('latest_category')){
@@ -132,27 +133,27 @@ class IsoHuntBridge extends BridgeAbstract{
$categoryName =
array_search(
$this->getInput('latest_category'),
- $this->parameters['By "Latest" category']['latest_category']['values']
+ self::PARAMETERS['By "Latest" category']['latest_category']['values']
);
- $name = 'Latest '.$categoryName.' - ' . $this->name;
+ $name = 'Latest '.$categoryName.' - ' . self::NAME;
break;
case 'By "Torrent" category':
$categoryName =
array_search(
$this->getInput('torrent_category'),
- $this->parameters['By "Torrent" category']['torrent_category']['values']
+ self::PARAMETERS['By "Torrent" category']['torrent_category']['values']
);
- $name = 'Category: ' . $categoryName . ' - ' . $this->name;
+ $name = 'Category: ' . $categoryName . ' - ' . self::NAME;
break;
case 'Search torrent by name':
$categoryName =
array_search(
$this->getInput('search_category'),
- $this->parameters['Search torrent by name']['search_category']['values']
+ self::PARAMETERS['Search torrent by name']['search_category']['values']
);
- $name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . $this->name;
+ $name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . self::NAME;
break;
}
@@ -199,30 +200,26 @@ class IsoHuntBridge extends BridgeAbstract{
}
}
- public function getCacheDuration(){
- return 300; // 5 minutes
- }
-
#region Helper functions for "Movie Torrents"
private function get_movie_torrents($html){
$container = $html->find('div#w0', 0);
if(!$container)
- $this->returnServerError('Unable to find torrent container!');
+ returnServerError('Unable to find torrent container!');
$torrents = $container->find('article');
if(!$torrents)
- $this->returnServerError('Unable to find torrents!');
+ returnServerError('Unable to find torrents!');
foreach($torrents as $torrent){
$anchor = $torrent->find('a', 0);
if(!$anchor)
- $this->returnServerError('Unable to find anchor!');
+ returnServerError('Unable to find anchor!');
$date = $torrent->find('small', 0);
if(!$date)
- $this->returnServerError('Unable to find date!');
+ returnServerError('Unable to find date!');
$item = array();
@@ -243,11 +240,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function get_latest_hot_torrents($html){
$container = $html->find('div#serps', 0);
if(!$container)
- $this->returnServerError('Unable to find torrent container!');
+ returnServerError('Unable to find torrent container!');
$torrents = $container->find('tr');
if(!$torrents)
- $this->returnServerError('Unable to find torrents!');
+ returnServerError('Unable to find torrents!');
// Remove first element (header row)
$torrents = array_slice($torrents, 1);
@@ -256,11 +253,11 @@ class IsoHuntBridge extends BridgeAbstract{
$cell = $torrent->find('td', 0);
if(!$cell)
- $this->returnServerError('Unable to find cell!');
+ returnServerError('Unable to find cell!');
$element = $cell->find('a', 0);
if(!$element)
- $this->returnServerError('Unable to find element!');
+ returnServerError('Unable to find element!');
$item = array();
@@ -281,11 +278,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function get_latest_news($html){
$container = $html->find('div#postcontainer', 0);
if(!$container)
- $this->returnServerError('Unable to find post container!');
+ returnServerError('Unable to find post container!');
$posts = $container->find('div.index-post');
if(!$posts)
- $this->returnServerError('Unable to find posts!');
+ returnServerError('Unable to find posts!');
foreach($posts as $post){
$item = array();
@@ -303,7 +300,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_author($post){
$author = $post->find('small', 0);
if(!$author)
- $this->returnServerError('Unable to find author!');
+ returnServerError('Unable to find author!');
// The author is hidden within a string like: 'Posted by {author} on {date}'
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches);
@@ -314,7 +311,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_timestamp($post){
$date = $post->find('small', 0);
if(!$date)
- $this->returnServerError('Unable to find date!');
+ returnServerError('Unable to find date!');
// The date is hidden within a string like: 'Posted by {author} on {date}'
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches);
@@ -332,7 +329,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_title($post){
$title = $post->find('a', 0);
if(!$title)
- $this->returnServerError('Unable to find title!');
+ returnServerError('Unable to find title!');
return $title->plaintext;
}
@@ -340,7 +337,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_uri($post){
$uri = $post->find('a', 0);
if(!$uri)
- $this->returnServerError('Unable to find uri!');
+ returnServerError('Unable to find uri!');
return $uri->href;
}
@@ -348,7 +345,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_content($post){
$content = $post->find('div', 0);
if(!$content)
- $this->returnServerError('Unable to find content!');
+ returnServerError('Unable to find content!');
// Remove
...
(title)
foreach($content->find('h2') as $element){
@@ -370,11 +367,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function get_latest_torrents($html){
$container = $html->find('div#serps', 0);
if(!$container)
- $this->returnServerError('Unable to find torrent container!');
+ returnServerError('Unable to find torrent container!');
$torrents = $container->find('tr[data-key]');
if(!$torrents)
- $this->returnServerError('Unable to find torrents!');
+ returnServerError('Unable to find torrents!');
foreach($torrents as $torrent){
$item = array();
@@ -392,11 +389,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_torrents_extract_title($torrent){
$cell = $torrent->find('td.title-row', 0);
if(!$cell)
- $this->returnServerError('Unable to find title cell!');
+ returnServerError('Unable to find title cell!');
$title = $cell->find('span', 0);
if(!$title)
- $this->returnServerError('Unable to find title!');
+ returnServerError('Unable to find title!');
return $title->plaintext;
}
@@ -404,11 +401,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_torrents_extract_uri($torrent){
$cell = $torrent->find('td.title-row', 0);
if(!$cell)
- $this->returnServerError('Unable to find title cell!');
+ returnServerError('Unable to find title cell!');
$uri = $cell->find('a', 0);
if(!$uri)
- $this->returnServerError('Unable to find uri!');
+ returnServerError('Unable to find uri!');
return $this->fix_relative_uri($uri->href);
}
@@ -420,7 +417,7 @@ class IsoHuntBridge extends BridgeAbstract{
$user = $cell->find('a', 0);
if(!$user)
- $this->returnServerError('Unable to find user!');
+ returnServerError('Unable to find user!');
return $user->plaintext;
}
@@ -428,7 +425,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_torrents_extract_timestamp($torrent){
$cell = $torrent->find('td.date-row', 0);
if(!$cell)
- $this->returnServerError('Unable to find date cell!');
+ returnServerError('Unable to find date cell!');
return strtotime('-' . $cell->plaintext, time());
}
@@ -438,15 +435,15 @@ class IsoHuntBridge extends BridgeAbstract{
#region Generic helper functions
private function load_html($uri){
- $html = $this->getSimpleHTMLDOM($uri);
+ $html = getSimpleHTMLDOM($uri);
if(!$html)
- $this->returnServerError('Unable to load ' . $uri . '!');
+ returnServerError('Unable to load ' . $uri . '!');
return $html;
}
private function fix_relative_uri($uri){
- return preg_replace('/\//i', $this->uri, $uri, 1);
+ return preg_replace('/\//i', self::URI, $uri, 1);
}
private function build_category_uri($category, $order_popularity = false){
diff --git a/bridges/JapanExpoBridge.php b/bridges/JapanExpoBridge.php
index b02304a9..72dd0a6c 100644
--- a/bridges/JapanExpoBridge.php
+++ b/bridges/JapanExpoBridge.php
@@ -1,11 +1,12 @@
array(
'name'=>'Show full contents',
'type'=>'checkbox',
@@ -42,8 +43,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
}
};
- $html = $this->getSimpleHTMLDOM($this->uri)
- or $this->returnServerError('Could not request JapanExpo: '.$this->uri);
+ $html = getSimpleHTMLDOM(self::URI)
+ or returnServerError('Could not request JapanExpo: '.self::URI);
$fullcontent = $this->getInput('mode');
$count = 0;
@@ -59,10 +60,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
if ($count >= 5) {
break;
}
- if($this->get_cached_time($url) <= strtotime('-24 hours'))
- $this->remove_from_cache($url);
- $article_html = $this->get_cached($url) or $this->returnServerError('Could not request JapanExpo: '.$url);
+ $article_html = getSimpleHTMLDOMCached('Could not request JapanExpo: '.$url);
$header = $article_html->find('header.pageHeadBox', 0);
$timestamp = strtotime($header->find('time', 0)->datetime);
$title_html = $header->find('div.section', 0)->next_sibling();
@@ -87,8 +86,4 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
$count++;
}
}
-
- public function getCacheDuration(){
- return 14400; // 4 hours
- }
}
diff --git a/bridges/KonachanBridge.php b/bridges/KonachanBridge.php
index 50730dc9..6d170312 100644
--- a/bridges/KonachanBridge.php
+++ b/bridges/KonachanBridge.php
@@ -1,46 +1,11 @@
array(
- 'name'=>'page',
- 'defaultValue'=>1,
- 'type'=>'number'
- ),
- 't'=>array('name'=>'tags')
- ));
+ const MAINTAINER = "mitsukarenai";
+ const NAME = "Konachan";
+ const URI = "http://konachan.com/";
+ const DESCRIPTION = "Returns images from given page";
- public function collectData(){
- $html = $this->getSimpleHTMLDOM(
- $this->uri.'/post?'
- .'&page='.$this->getInput('p')
- .'&tags='.urlencode($this->getInput('t'))
- ) or $this->returnServerError('Could not request Konachan.');
-
- $input_json = explode('Post.register(', $html);
- foreach($input_json as $element)
- $data[] = preg_replace('/}\)(.*)/', '}', $element);
- unset($data[0]);
-
- foreach($data as $datai) {
- $json = json_decode($datai, TRUE);
- $item = array();
- $item['uri'] = $this->uri.'/post/show/'.$json['id'];
- $item['postid'] = $json['id'];
- $item['timestamp'] = $json['created_at'];
- $item['imageUri'] = $json['file_url'];
- $item['title'] = 'Konachan | '.$json['id'];
- $item['content'] = '
Tags: '.$json['tags'];
- $this->items[] = $item;
- }
- }
-
- public function getCacheDuration(){
- return 1800; // 30 minutes
- }
}
diff --git a/bridges/KoreusBridge.php b/bridges/KoreusBridge.php
index 4cb86c81..25d8dbf9 100644
--- a/bridges/KoreusBridge.php
+++ b/bridges/KoreusBridge.php
@@ -1,38 +1,22 @@
', '', $string);
- return $string;
- }
+ protected function parseItem($item) {
+ $item = parent::parseItem($item);
- private function KoreusExtractContent($url) {
- $html2 = $this->getSimpleHTMLDOM($url);
- $text = $html2->find('p[class=itemText]', 0)->innertext;
- $text = utf8_encode(preg_replace('/(Sur le m.+?)+$/i','',$text));
- return $text;
+ $html = getSimpleHTMLDOMCached($item['uri']);
+ $text = $html->find('p.itemText', 0)->innertext;
+ $item['content'] = utf8_encode($text);
+
+ return $item;
}
public function collectData(){
- $html = $this->getSimpleHTMLDOM('http://feeds.feedburner.com/Koreus-articles') or $this->returnServerError('Could not request Koreus.');
- $limit = 0;
-
- foreach($html->find('item') as $element) {
- if($limit < 5) {
- $item = array();
- $item['title'] = $this->KoreusStripCDATA($element->find('title', 0)->innertext);
- $item['uri'] = $this->KoreusStripCDATA($element->find('guid', 0)->plaintext);
- $item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
- $item['content'] = $this->KoreusExtractContent($item['uri']);
- $this->items[] = $item;
- $limit++;
- }
- }
+ $this->collectExpandableDatas('http://feeds.feedburner.com/Koreus-articles');
}
}
diff --git a/bridges/KununuBridge.php b/bridges/KununuBridge.php
index aa63c342..11ebd32c 100644
--- a/bridges/KununuBridge.php
+++ b/bridges/KununuBridge.php
@@ -1,11 +1,12 @@
array(
'site'=>array(
'name'=>'Site',
@@ -55,33 +56,33 @@ class KununuBridge extends HttpCachingBridgeAbstract {
break;
}
- return $this->uri.$site.'/'.$company.'/'.$section;
+ return self::URI.$site.'/'.$company.'/'.$section;
}
function getName(){
$company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($this->getInput('company')))));
- return ($this->companyName?:$company).' - '.$this->name;
+ return ($this->companyName?:$company).' - '.self::NAME;
}
public function collectData(){
$full = $this->getInput('full');
// Load page
- $html = $this->getSimpleHTMLDOM($this->getURI());
+ $html = getSimpleHTMLDOM($this->getURI());
if(!$html)
- $this->returnServerError('Unable to receive data from ' . $this->getURI() . '!');
+ returnServerError('Unable to receive data from ' . $this->getURI() . '!');
// Update name for this request
$this->companyName = $this->extract_company_name($html);
// Find the section with all the panels (reviews)
$section = $html->find('section.kununu-scroll-element', 0);
if($section === false)
- $this->returnServerError('Unable to find panel section!');
+ returnServerError('Unable to find panel section!');
// Find all articles (within the panels)
$articles = $section->find('article');
if($articles === false || empty($articles))
- $this->returnServerError('Unable to find articles!');
+ returnServerError('Unable to find articles!');
// Go through all articles
foreach($articles as $article){
@@ -101,15 +102,11 @@ class KununuBridge extends HttpCachingBridgeAbstract {
}
}
- public function getCacheDuration(){
- return 86400; // 1 day
- }
-
/**
* Fixes relative URLs in the given text
*/
private function fix_url($text){
- return preg_replace('/href=(\'|\")\//i', 'href="'.$this->uri, $text);
+ return preg_replace('/href=(\'|\")\//i', 'href="'.self::URI, $text);
}
/**
@@ -128,11 +125,11 @@ class KununuBridge extends HttpCachingBridgeAbstract {
private function extract_company_name($html){
$panel = $html->find('div.panel', 0);
if($panel === false)
- $this->returnServerError('Cannot find panel for company name!');
+ returnServerError('Cannot find panel for company name!');
$company_name = $panel->find('h1', 0);
if($company_name === false)
- $this->returnServerError('Cannot find company name!');
+ returnServerError('Cannot find company name!');
return $company_name->plaintext;
}
@@ -144,7 +141,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
// They conviniently provide a time attribute for us :)
$date = $article->find('time[itemprop=dtreviewed]', 0);
if($date === false)
- $this->returnServerError('Cannot find article date!');
+ returnServerError('Cannot find article date!');
return strtotime($date->datetime);
}
@@ -155,7 +152,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
private function extract_article_rating($article){
$rating = $article->find('span.rating', 0);
if($rating === false)
- $this->returnServerError('Cannot find article rating!');
+ returnServerError('Cannot find article rating!');
return $rating->getAttribute('aria-label');
}
@@ -166,7 +163,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
private function extract_article_summary($article){
$summary = $article->find('[itemprop=summary]', 0);
if($summary === false)
- $this->returnServerError('Cannot find article summary!');
+ returnServerError('Cannot find article summary!');
return strip_tags($summary->innertext);
}
@@ -178,13 +175,13 @@ class KununuBridge extends HttpCachingBridgeAbstract {
// Notice: This first part is the same as in extract_article_summary!
$summary = $article->find('[itemprop=summary]', 0);
if($summary === false)
- $this->returnServerError('Cannot find article summary!');
+ returnServerError('Cannot find article summary!');
$anchor = $summary->find('a', 0);
if($anchor === false)
- $this->returnServerError('Cannot find article URI!');
+ returnServerError('Cannot find article URI!');
- return $this->uri . $anchor->href;
+ return self::URI . $anchor->href;
}
/**
@@ -194,7 +191,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
// We need to parse the aside manually
$aside = $article->find('aside', 0);
if($aside === false)
- $this->returnServerError('Cannot find article author information!');
+ returnServerError('Cannot find article author information!');
// Go through all h2 elements to find index of required span (I know... it's stupid)
$author_position = 'Unknown';
@@ -214,7 +211,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
private function extract_article_description($article){
$description = $article->find('div[itemprop=description]', 0);
if($description === false)
- $this->returnServerError('Cannot find article description!');
+ returnServerError('Cannot find article description!');
return $this->fix_url($description->innertext);
}
@@ -224,17 +221,14 @@ class KununuBridge extends HttpCachingBridgeAbstract {
*/
private function extract_full_description($uri){
// Load full article
- if($this->get_cached_time($uri) <= strtotime('-24 hours'))
- $this->remove_from_cache($uri);
-
- $html = $this->get_cached($uri);
+ $html = getSimpleHTMLDOMCached($uri);
if($html === false)
- $this->returnServerError('Could not load full description!');
+ returnServerError('Could not load full description!');
// Find the article
$article = $html->find('article', 0);
if($article === false)
- $this->returnServerError('Cannot find article!');
+ returnServerError('Cannot find article!');
// Luckily they use the same layout for the review overview and full article pages :)
return $this->extract_article_description($article);
diff --git a/bridges/LWNprevBridge.php b/bridges/LWNprevBridge.php
index c2673621..8c2c4356 100644
--- a/bridges/LWNprevBridge.php
+++ b/bridges/LWNprevBridge.php
@@ -1,12 +1,13 @@
uri.'free/bigpage';
+ return self::URI.'free/bigpage';
}
private function jumpToNextTag(&$node){
@@ -32,8 +33,8 @@ class LWNprevBridge extends BridgeAbstract{
public function collectData(){
// Because the LWN page is written in loose HTML and not XHTML,
// Simple HTML Dom is not accurate enough for the job
- $content=$this->getContents($this->getURI())
- or $this->returnServerError('No results for LWNprev');
+ $content=getContents($this->getURI())
+ or returnServerError('No results for LWNprev');
libxml_use_internal_errors(true);
$html=new DOMDocument();
@@ -48,7 +49,7 @@ class LWNprevBridge extends BridgeAbstract{
break;
}
}
- $realURI=$this->uri.$a->getAttribute('href');
+ $realURI=self::URI.$a->getAttribute('href');
$URICounter=0;
$edition=$html->getElementsByTagName('h1')->item(0)->textContent;
@@ -82,7 +83,7 @@ class LWNprevBridge extends BridgeAbstract{
$h2FirstChild=$h2->firstChild;
$this->jumpToNextTag($h2FirstChild);
if($h2FirstChild->nodeName==='a'){
- $item['uri']=$this->uri.$h2FirstChild->getAttribute('href');
+ $item['uri']=self::URI.$h2FirstChild->getAttribute('href');
}else{
$item['uri']=$realURI.'#'.$URICounter;
}
@@ -140,8 +141,4 @@ class LWNprevBridge extends BridgeAbstract{
$this->items[]=$item;
}
}
-
- public function getCacheDuration(){
- return 604800; // one week
- }
}
diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php
index fab1a71a..54c0f5ec 100755
--- a/bridges/LeBonCoinBridge.php
+++ b/bridges/LeBonCoinBridge.php
@@ -1,17 +1,18 @@
array('name'=>'Mot Clé'),
'r'=>array(
'name'=>'Région',
'type'=>'list',
'values'=>array(
+ 'Toute la France'=>'ile_de_france/occasions',
'Alsace'=>'alsace',
'Aquitaine'=>'aquitaine',
'Auvergne'=>'auvergne',
@@ -142,11 +143,11 @@ class LeBonCoinBridge extends BridgeAbstract{
$category='annonces';
}
- $html = $this->getSimpleHTMLDOM(
- $this->uri.$category.'/offres/' . $this->getInput('r') . '/?'
+ $html = getSimpleHTMLDOM(
+ self::URI.$category.'/offres/' . $this->getInput('r') . '/?'
.'f=a&th=1&'
.'q=' . urlencode($this->getInput('k'))
- ) or $this->returnServerError('Could not request LeBonCoin.');
+ ) or returnServerError('Could not request LeBonCoin.');
$list = $html->find('.tabsContent', 0);
if($list === NULL) {
diff --git a/bridges/LeJournalDuGeekBridge.php b/bridges/LeJournalDuGeekBridge.php
deleted file mode 100644
index f1b89a1f..00000000
--- a/bridges/LeJournalDuGeekBridge.php
+++ /dev/null
@@ -1,58 +0,0 @@
-', '', $string);
- return $string;
- }
-
- private function LeJournalDuGeekExtractContent($url) {
- $articleHTMLContent = $this->getSimpleHTMLDOM($url);
- $text = $articleHTMLContent->find('div.post-content', 0)->innertext;
-
- foreach($articleHTMLContent->find('a.more') as $element) {
- if ($element->innertext == "Source") {
- $text = $text . 'Source : ' . $element->href . '
';
- break;
- }
- }
-
- foreach($articleHTMLContent->find('iframe') as $element) {
- if (preg_match("/youtube/i", $element->src)) {
- $text = $text . '// An IFRAME to Youtube was included in the article: ' . $element->src . '
';
- }
- }
-
- $text = preg_replace('##is', '', $text);
- $text = strip_tags($text, '![]()
- ');
- return $text;
- }
-
- public function collectData(){
- $rssFeed = $this->getSimpleHTMLDOM($this->uri.'rss')
- or $this->returnServerError('Could not request '.$this->uri.'/rss');
- $limit = 0;
-
- foreach($rssFeed->find('item') as $element) {
- if($limit < 5) {
- $item = array();
- $item['title'] = $this->LeJournalDuGeekStripCDATA($element->find('title', 0)->innertext);
- $item['uri'] = $this->LeJournalDuGeekStripCDATA($element->find('guid', 0)->plaintext);
- $item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
- $item['content'] = $this->LeJournalDuGeekExtractContent($item['uri']);
- $this->items[] = $item;
- $limit++;
- }
- }
- }
-
- public function getCacheDuration(){
- return 1800; // 30min
- }
-}
diff --git a/bridges/LeMondeInformatiqueBridge.php b/bridges/LeMondeInformatiqueBridge.php
index b744e76e..f737ed43 100644
--- a/bridges/LeMondeInformatiqueBridge.php
+++ b/bridges/LeMondeInformatiqueBridge.php
@@ -1,63 +1,42 @@
', '', $string);
- return $string;
- }
-
- function StripWithDelimiters($string, $start, $end) {
- while (strpos($string, $start) !== false) {
- $section_to_remove = substr($string, strpos($string, $start));
- $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
- $string = str_replace($section_to_remove, '', $string);
- } return $string;
- }
-
- function CleanArticle($article_html) {
- $article_html = StripWithDelimiters($article_html, '');
+ $article_html = $this->StripWithDelimiters($article_html, '
');
+ return $article_html;
}
}
diff --git a/bridges/LegifranceJOBridge.php b/bridges/LegifranceJOBridge.php
new file mode 100644
index 00000000..6cc8086b
--- /dev/null
+++ b/bridges/LegifranceJOBridge.php
@@ -0,0 +1,70 @@
+author;
+ $item['timestamp']=$this->timestamp;
+ $item['uri']=$this->uri.'#'.count($this->items);
+ $item['title']=$section->plaintext;
+
+ if(!is_null($origin)){
+ $item['title']='[ '.$item['title'].' / '.$subsection->plaintext.' ] '.$origin->plaintext;
+ $data=$origin;
+ }elseif(!is_null($subsection)){
+ $item['title']='[ '.$item['title'].' ] '.$subsection->plaintext;
+ $data=$subsection;
+ }else{
+ $data=$section;
+ }
+
+ $item['content']='';
+ foreach($data->nextSibling()->find('a') as $content){
+ $text=$content->plaintext;
+ $href=$content->nextSibling()->getAttribute('resource');
+ $item['content'].='
'.$text.'
';
+ }
+ return $item;
+ }
+
+ public function collectData(){
+ $html=getSimpleHTMLDOM(self::URI)
+ or $this->returnServer('Unable to download '.self::URI);
+
+ $this->author=trim($html->find('h2.title',0)->plaintext);
+ $uri=$html->find('h2.titleELI',0)->plaintext;
+ $this->uri=trim(substr($uri,strpos($uri,'https')));
+ $this->timestamp=strtotime(substr($this->uri,strpos($this->uri,'eli/jo/')+strlen('eli/jo/')));
+
+ foreach($html->find('h3') as $section){
+ $subsections=$section->nextSibling()->find('h4');
+ foreach($subsections as $subsection){
+ $origins=$subsection->nextSibling()->find('h5');
+ foreach($origins as $origin){
+ $this->items[]=$this->extractItem($section,$subsection,$origin);
+ }
+ if(!empty($origins)){
+ continue;
+ }
+ $this->items[]=$this->extractItem($section,$subsection);
+ }
+ if(!empty($subsections)){
+ continue;
+ }
+ $this->items[]=$this->extractItem($section);
+ }
+ }
+}
+
+
diff --git a/bridges/Les400CulsBridge.php b/bridges/Les400CulsBridge.php
deleted file mode 100644
index 3fea2fff..00000000
--- a/bridges/Les400CulsBridge.php
+++ /dev/null
@@ -1,36 +0,0 @@
-collectExpandableDatas($this->uri.'feeds/');
- }
-
- protected function parseRSSItem($newsItem) {
- $item = array();
- $item['title'] = trim((string) $newsItem->title);
- $this->debugMessage("browsing item ".var_export($newsItem, true));
- if(empty($newsItem->guid)) {
- $item['uri'] = (string) $newsItem->link;
- } else {
- $item['uri'] = (string) $newsItem->guid;
- }
- // now load that uri from cache
- $this->debugMessage("now loading page ".$item['uri']);
-// $articlePage = $this->get_cached($item['uri']);
-
-// $content = $articlePage->find('.post-container', 0);
- $item['content'] = (string) $newsItem->description;
- $item['author'] = (string) $newsItem->author;
- $item['timestamp'] = $this->RSS_2_0_time_to_timestamp($newsItem);
- return $item;
- }
- public function getCacheDuration(){
- return 7200; // 2h hours
- }
-}
diff --git a/bridges/LesJoiesDuCodeBridge.php b/bridges/LesJoiesDuCodeBridge.php
index 1d835560..cde49776 100644
--- a/bridges/LesJoiesDuCodeBridge.php
+++ b/bridges/LesJoiesDuCodeBridge.php
@@ -1,14 +1,15 @@
getSimpleHTMLDOM($this->uri)
- or $this->returnServerError('Could not request LesJoiesDuCode.');
+ $html = getSimpleHTMLDOM(self::URI)
+ or returnServerError('Could not request LesJoiesDuCode.');
foreach($html->find('div.blog-post') as $element) {
$item = array();
@@ -43,8 +44,4 @@ class LesJoiesDuCodeBridge extends BridgeAbstract{
$this->items[] = $item;
}
}
-
- public function getCacheDuration(){
- return 7200; // 2h hours
- }
}
diff --git a/bridges/LichessBridge.php b/bridges/LichessBridge.php
index 4e81e9ce..e0657b86 100644
--- a/bridges/LichessBridge.php
+++ b/bridges/LichessBridge.php
@@ -1,43 +1,23 @@
getSimpleHTMLDOM($this->uri.'.atom')
- or $this->returnServerError('Could not retrieve Lichess blog feed.');
-
- $posts_loaded = 0;
- foreach($xml_feed->find('entry') as $entry)
- {
- if ($posts_loaded < 5)
- {
- $item = array();
-
- $item['title'] = html_entity_decode($entry->find('title', 0)->innertext);
- $item['author'] = $entry->find('author', 0)->find('name', 0)->innertext;
- $item['uri'] = $entry->find('id', 0)->plaintext;
- $item['timestamp'] = strtotime($entry->find('published', 0)->plaintext);
-
- $item['content'] = $this->retrieve_lichess_post($item['uri']);
-
- $this->items[] = $item;
- $posts_loaded++;
- }
- }
+ public function collectData(){
+ $this->collectExpandableDatas(self::URI . '.atom', 5);
}
- private function retrieve_lichess_post($blog_post_uri)
- {
- if($this->get_cached_time($blog_post_uri) <= strtotime('-24 hours'))
- $this->remove_from_cache($blog_post_uriuri);
+ protected function parseItem($newsItem){
+ $item = parent::parseItem($newsItem);
+ $item['content'] = $this->retrieve_lichess_post($item['uri']);
+ return $item;
+ }
- $blog_post_html = $this->get_cached($blog_post_uri);
+ private function retrieve_lichess_post($blog_post_uri){
+ $blog_post_html = getSimpleHTMLDOMCached($blog_post_uri);
$blog_post_div = $blog_post_html->find('#lichess_blog', 0);
$post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;
diff --git a/bridges/LinkedInCompanyBridge.php b/bridges/LinkedInCompanyBridge.php
index e23f9d48..7e966f61 100644
--- a/bridges/LinkedInCompanyBridge.php
+++ b/bridges/LinkedInCompanyBridge.php
@@ -1,12 +1,13 @@
apple)";
+ const MAINTAINER = "regisenguehard";
+ const NAME = "LinkedIn Company";
+ const URI = "https://www.linkedin.com/";
+ const CACHE_TIMEOUT = 21600; //6
+ const DESCRIPTION = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/apple)";
- public $parameters = array( array(
+ const PARAMETERS = array( array(
'c'=>array(
'name'=>'Company name',
'required'=>true
@@ -15,10 +16,10 @@ class LinkedInCompanyBridge extends BridgeAbstract{
public function collectData(){
$html = '';
- $link = $this->uri.'company/'.$this->getInput('c');
+ $link = self::URI.'company/'.$this->getInput('c');
- $html = $this->getSimpleHTMLDOM($link)
- or $this->returnServerError('Could not request LinkedIn.');
+ $html = getSimpleHTMLDOM($link)
+ or returnServerError('Could not request LinkedIn.');
foreach($html->find('//*[@id="my-feed-post"]/li') as $element) {
$title = $element->find('span.share-body', 0)->innertext;
@@ -32,8 +33,4 @@ class LinkedInCompanyBridge extends BridgeAbstract{
}
}
}
-
- public function getCacheDuration(){
- return 21600; // 6 hours
- }
}
diff --git a/bridges/LolibooruBridge.php b/bridges/LolibooruBridge.php
index 1bcf0376..781bc238 100644
--- a/bridges/LolibooruBridge.php
+++ b/bridges/LolibooruBridge.php
@@ -1,46 +1,11 @@
array(
- 'name'=>'page',
- 'defaultValue'=>1,
- 'type'=>'number'
- ),
- 't'=>array('name'=>'tags')
- ));
+ const MAINTAINER = "mitsukarenai";
+ const NAME = "Lolibooru";
+ const URI = "https://lolibooru.moe/";
+ const DESCRIPTION = "Returns images from given page and tags";
- public function collectData(){
- $html = $this->getSimpleHTMLDOM(
- $this->uri.'post?'
- .'&page='.$this->getInput('p')
- .'&tags='.urlencode($this->getInput('t'))
- ) or $this->returnServerError('Could not request Lolibooru.');
-
- $input_json = explode('Post.register(', $html);
- foreach($input_json as $element)
- $data[] = preg_replace('/}\)(.*)/', '}', $element);
- unset($data[0]);
-
- foreach($data as $datai) {
- $json = json_decode($datai, TRUE);
- $item = array();
- $item['uri'] = $this->uri.'post/show/'.$json['id'];
- $item['postid'] = $json['id'];
- $item['timestamp'] = $json['created_at'];
- $item['imageUri'] = $json['file_url'];
- $item['title'] = 'Lolibooru | '.$json['id'];
- $item['content'] = '
Tags: '.$json['tags'];
- $this->items[] = $item;
- }
- }
-
- public function getCacheDuration(){
- return 1800; // 30 minutes
- }
}
diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php
index cdf5a70e..949e7a48 100644
--- a/bridges/MangareaderBridge.php
+++ b/bridges/MangareaderBridge.php
@@ -1,190 +1,229 @@
array(),
'Get popular mangas' => array(
- 'category'=>array(
- 'name'=>'Category',
- 'type'=>'list',
- 'required'=>true,
- 'values'=>array(
- 'All'=>'all',
- 'Action'=>'action',
- 'Adventure'=>'adventure',
- 'Comedy'=>'comedy',
- 'Demons'=>'demons',
- 'Drama'=>'drama',
- 'Ecchi'=>'ecchi',
- 'Fantasy'=>'fantasy',
- 'Gender Bender'=>'gender-bender',
- 'Harem'=>'harem',
- 'Historical'=>'historical',
- 'Horror'=>'horror',
- 'Josei'=>'josei',
- 'Magic'=>'magic',
- 'Martial Arts'=>'martial-arts',
- 'Mature'=>'mature',
- 'Mecha'=>'mecha',
- 'Military'=>'military',
- 'Mystery'=>'mystery',
- 'One Shot'=>'one-shot',
- 'Psychological'=>'psychological',
- 'Romance'=>'romance',
- 'School Life'=>'school-life',
- 'Sci-Fi'=>'sci-fi',
- 'Seinen'=>'seinen',
- 'Shoujo'=>'shoujo',
- 'Shoujoai'=>'shoujoai',
- 'Shounen'=>'shounen',
- 'Shounenai'=>'shounenai',
- 'Slice of Life'=>'slice-of-life',
- 'Smut'=>'smut',
- 'Sports'=>'sports',
- 'Super Power'=>'super-power',
- 'Supernatural'=>'supernatural',
- 'Tragedy'=>'tragedy',
- 'Vampire'=>'vampire',
- 'Yaoi'=>'yaoi',
- 'Yuri'=>'yuri'
+ 'category' => array(
+ 'name' => 'Category',
+ 'type' => 'list',
+ 'required' => true,
+ 'values' => array(
+ 'All' => 'all',
+ 'Action' => 'action',
+ 'Adventure' => 'adventure',
+ 'Comedy' => 'comedy',
+ 'Demons' => 'demons',
+ 'Drama' => 'drama',
+ 'Ecchi' => 'ecchi',
+ 'Fantasy' => 'fantasy',
+ 'Gender Bender' => 'gender-bender',
+ 'Harem' => 'harem',
+ 'Historical' => 'historical',
+ 'Horror' => 'horror',
+ 'Josei' => 'josei',
+ 'Magic' => 'magic',
+ 'Martial Arts' => 'martial-arts',
+ 'Mature' => 'mature',
+ 'Mecha' => 'mecha',
+ 'Military' => 'military',
+ 'Mystery' => 'mystery',
+ 'One Shot' => 'one-shot',
+ 'Psychological' => 'psychological',
+ 'Romance' => 'romance',
+ 'School Life' => 'school-life',
+ 'Sci-Fi' => 'sci-fi',
+ 'Seinen' => 'seinen',
+ 'Shoujo' => 'shoujo',
+ 'Shoujoai' => 'shoujoai',
+ 'Shounen' => 'shounen',
+ 'Shounenai' => 'shounenai',
+ 'Slice of Life' => 'slice-of-life',
+ 'Smut' => 'smut',
+ 'Sports' => 'sports',
+ 'Super Power' => 'super-power',
+ 'Supernatural' => 'supernatural',
+ 'Tragedy' => 'tragedy',
+ 'Vampire' => 'vampire',
+ 'Yaoi' => 'yaoi',
+ 'Yuri' => 'yuri'
),
- 'exampleValue'=>'All',
- 'title'=>'Select your category'
+ 'exampleValue' => 'All',
+ 'title' => 'Select your category'
)
),
'Get manga updates' => array(
- 'path'=>array(
- 'name'=>'Path',
- 'required'=>true,
- 'pattern'=>'[a-zA-Z0-9-_]*',
- 'exampleValue'=>'bleach, umi-no-kishidan',
- 'title'=>'URL part of desired manga'
+ 'path' => array(
+ 'name' => 'Path',
+ 'required' => true,
+ 'pattern' => '[a-zA-Z0-9-_]*',
+ 'exampleValue' => 'bleach, umi-no-kishidan',
+ 'title' => 'URL part of desired manga'
),
- 'limit'=>array(
- 'name'=>'Limit',
- 'type'=>'number',
- 'exampleValue'=>10,
- 'title'=>'Number of items to return [-1 returns all]'
+ 'limit' => array(
+ 'name' => 'Limit',
+ 'type' => 'number',
+ 'defaultValue' => 10,
+ 'title' => 'Number of items to return [-1 returns all]'
)
)
);
- private $request='';
+ private $request = '';
- public function collectData(){
- // We'll use the DOM parser for this as it makes navigation easier
- $html = $this->getContents($this->getURI());
+ public function collectData(){
+ // We'll use the DOM parser for this as it makes navigation easier
+ $html = getContents($this->getURI());
if(!$html){
- $this->returnClientError('Could not receive data for ' . $path . '!');
+ returnClientError('Could not receive data for ' . $path . '!');
}
libxml_use_internal_errors(true);
$doc = new DomDocument;
- @$doc->loadHTML($html);
+ @$doc->loadHTML($html);
libxml_clear_errors();
- // Navigate via XPath
- $xpath = new DomXPath($doc);
+ // Navigate via XPath
+ $xpath = new DomXPath($doc);
$this->request = '';
switch($this->queriedContext){
case 'Get latest updates':
$this->request = 'Latest updates';
-
- // Query each item (consists of Manga + chapters)
- $nodes = $xpath->query("//*[@id='latestchapters']/table//td");
-
- foreach ($nodes as $node){
- // Query the manga
- $manga = $xpath->query("a[@class='chapter']", $node)->item(0);
-
- // Collect the chapters for each Manga
- $chapters = $xpath->query("a[@class='chaptersrec']", $node);
-
- if (isset($manga) && $chapters->length >= 1){
- $item = array();
- $item['uri'] = $this->uri. htmlspecialchars($manga->getAttribute('href'));
- $item['title'] = htmlspecialchars($manga->nodeValue);
-
- // Add each chapter to the feed
- $item['content'] = "";
-
- foreach ($chapters as $chapter){
- if($item['content'] <> ""){
- $item['content'] .= "
";
- }
- $item['content'] .= "" . htmlspecialchars($chapter->nodeValue) . "";
- }
-
- $this->items[] = $item;
- }
- }
+ $this->get_latest_updates($xpath);
break;
-
case 'Get popular mangas':
+ // Find manga name within "Popular mangas for ..."
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
- $this->request = substr($pagetitle, 0, strrpos($pagetitle, " -")); // "Popular mangas for ..."
-
- // Query all mangas
- $mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
-
- foreach ($mangas as $manga){
-
- // The thumbnail is encrypted in a css-style...
- // format: "background-image:url('')"
- $mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga)->item(0)->getAttribute('style');
- $thumbnail = substr($mangaimgelement, 22, strlen($mangaimgelement) - 24);
-
- $item = array();
- $item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->nodeValue);
- $item['uri'] = $this->uri . $xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->getAttribute('href');
- $item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga)->item(0)->nodeValue);
- $item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga)->item(0)->nodeValue;
- $item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga)->item(0)->nodeValue);
- $item['content'] = '![' . $item['title'] . '](' . $thumbnail . ')
' . $item['genre'] . '
' . $item['chaptercount'] . '
';
- $this->items[] = $item;
- }
+ $this->request = substr($pagetitle, 0, strrpos($pagetitle, " -"));
+ $this->get_popular_mangas($xpath);
break;
-
case 'Get manga updates':
$limit = $this->getInput('limit');
if(empty($limit)){
- $limit = MANGAREADER_LIMIT;
+ $limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue'];
}
- $this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")->item(0)->nodeValue;
+ $this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")
+ ->item(0)
+ ->nodeValue;
- $query = "(.//*[@id='listing']//tr)[position() > 1]";
-
- if($limit !== -1){
- $query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - " . $limit . "]";
- }
-
- $chapters = $xpath->query($query);
-
- foreach ($chapters as $chapter){
- $item = array();
- $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)->item(0)->nodeValue);
- $item['uri'] = $this->uri . $xpath->query("td[1]/a", $chapter)->item(0)->getAttribute('href');
- $item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)->item(0)->nodeValue);
- array_unshift($this->items, $item);
- }
+ $this->get_manga_updates($xpath, $limit);
break;
}
- // Return some dummy-data if no content available
- if(empty($this->items)){
- $item = array();
- $item['content'] = "No updates available
";
+ // Return some dummy-data if no content available
+ if(empty($this->items)){
+ $item = array();
+ $item['content'] = "No updates available
";
- $this->items[] = $item;
- }
- }
+ $this->items[] = $item;
+ }
+ }
+
+ private function get_latest_updates($xpath){
+ // Query each item (consists of Manga + chapters)
+ $nodes = $xpath->query("//*[@id='latestchapters']/table//td");
+
+ foreach ($nodes as $node){
+ // Query the manga
+ $manga = $xpath->query("a[@class='chapter']", $node)->item(0);
+
+ // Collect the chapters for each Manga
+ $chapters = $xpath->query("a[@class='chaptersrec']", $node);
+
+ if (isset($manga) && $chapters->length >= 1){
+ $item = array();
+ $item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href'));
+ $item['title'] = htmlspecialchars($manga->nodeValue);
+
+ // Add each chapter to the feed
+ $item['content'] = "";
+
+ foreach ($chapters as $chapter){
+ if($item['content'] <> ""){
+ $item['content'] .= "
";
+ }
+ $item['content'] .=
+ ""
+ . htmlspecialchars($chapter->nodeValue)
+ . "";
+ }
+
+ $this->items[] = $item;
+ }
+ }
+ }
+
+ private function get_popular_mangas($xpath){
+ // Query all mangas
+ $mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
+
+ foreach ($mangas as $manga){
+
+ // The thumbnail is encrypted in a css-style...
+ // format: "background-image:url('')"
+ $mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga)
+ ->item(0)
+ ->getAttribute('style');
+ $thumbnail = substr($mangaimgelement, 22, strlen($mangaimgelement) - 24);
+
+ $item = array();
+ $item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)
+ ->item(0)
+ ->nodeValue);
+ $item['uri'] = self::URI . $xpath->query(".//*[@class='manga_name']//a", $manga)
+ ->item(0)
+ ->getAttribute('href');
+ $item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga)
+ ->item(0)
+ ->nodeValue);
+ $item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga)
+ ->item(0)
+ ->nodeValue;
+ $item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga)
+ ->item(0)
+ ->nodeValue);
+ $item['content'] = <<![{$item['title']}]({$thumbnail})
+
{$item['genre']}
+{$item['chaptercount']}
+EOD;
+ $this->items[] = $item;
+ }
+ }
+
+ private function get_manga_updates($xpath, $limit){
+ $query = "(.//*[@id='listing']//tr)[position() > 1]";
+
+ if($limit !== -1){
+ $query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]";
+ }
+
+ $chapters = $xpath->query($query);
+
+ foreach ($chapters as $chapter){
+ $item = array();
+ $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)
+ ->item(0)
+ ->nodeValue);
+ $item['uri'] = self::URI . $xpath->query("td[1]/a", $chapter)
+ ->item(0)
+ ->getAttribute('href');
+ $item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)
+ ->item(0)
+ ->nodeValue);
+ array_unshift($this->items, $item);
+ }
+ }
public function getURI(){
switch($this->queriedContext){
@@ -201,16 +240,12 @@ class MangareaderBridge extends BridgeAbstract{
$path = $this->getInput('path');
break;
}
- return $this->uri . $path;
+ return self::URI . $path;
}
- public function getName(){
- return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge';
- }
-
- public function getCacheDuration(){
- return 10800; // 3 hours
- }
+ public function getName(){
+ return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge';
+ }
}
?>
diff --git a/bridges/MilbooruBridge.php b/bridges/MilbooruBridge.php
index 1dc08cfa..bc10c3f9 100644
--- a/bridges/MilbooruBridge.php
+++ b/bridges/MilbooruBridge.php
@@ -1,39 +1,11 @@
array(
- 'name'=>'page',
- 'type'=>'number'
- ),
- 't'=>array('name'=>'tags')
- ));
-
- public function collectData(){
- $html = $this->getSimpleHTMLDOM(
- $this->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'] = $this->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 = $this->uri.$element->find('img', 0)->src;
- $item['tags'] = $element->find('a', 0)->getAttribute('data-tags');
- $item['title'] = 'Milbooru | '.$item['postid'];
- $item['content'] = '
Tags: '.$item['tags'];
- $this->items[] = $item;
- }
- }
-
- public function getCacheDuration(){
- return 1800; // 30 minutes
- }
}
diff --git a/bridges/MoebooruBridge.php b/bridges/MoebooruBridge.php
new file mode 100644
index 00000000..920bc10c
--- /dev/null
+++ b/bridges/MoebooruBridge.php
@@ -0,0 +1,46 @@
+array(
+ 'name'=>'page',
+ 'defaultValue'=>1,
+ 'type'=>'number'
+ ),
+ 't'=>array('name'=>'tags')
+ ));
+
+ protected function getFullURI(){
+ return $this->getURI().'post?'
+ .'page='.$this->getInput('p')
+ .'&tags='.urlencode($this->getInput('t'));
+ }
+
+ public function collectData(){
+ $html = getSimpleHTMLDOM($this->getFullURI())
+ or returnServerError('Could not request '.$this->getName());
+
+
+ $input_json = explode('Post.register(', $html);
+ foreach($input_json as $element)
+ $data[] = preg_replace('/}\)(.*)/', '}', $element);
+ unset($data[0]);
+
+ foreach($data as $datai) {
+ $json = json_decode($datai, TRUE);
+ $item = array();
+ $item['uri'] = $this->getURI().'/post/show/'.$json['id'];
+ $item['postid'] = $json['id'];
+ $item['timestamp'] = $json['created_at'];
+ $item['imageUri'] = $json['file_url'];
+ $item['title'] = $this->getName().' | '.$json['id'];
+ $item['content'] = '
Tags: '.$json['tags'];
+ $this->items[] = $item;
+ }
+ }
+}
diff --git a/bridges/MondeDiploBridge.php b/bridges/MondeDiploBridge.php
index 2a6afc4e..e0cf78c0 100644
--- a/bridges/MondeDiploBridge.php
+++ b/bridges/MondeDiploBridge.php
@@ -1,26 +1,23 @@
getSimpleHTMLDOM($this->uri)
- or $this->returnServerError('Could not request MondeDiplo. for : ' . $this->uri);
+ $html = getSimpleHTMLDOM(self::URI)
+ or returnServerError('Could not request MondeDiplo. for : ' . self::URI);
foreach($html->find('div.unarticle') as $article) {
$element = $article->parent();
$item = array();
- $item['uri'] = $this->uri . $element->href;
+ $item['uri'] = self::URI . $element->href;
$item['title'] = $element->find('h3', 0)->plaintext;
$item['content'] = $element->find('div.dates_auteurs', 0)->plaintext . '
' . strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true);
$this->items[] = $item;
}
}
-
- public function getCacheDuration(){
- return 21600; // 6 hours
- }
}
diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php
index 5e481956..348bdb91 100644
--- a/bridges/MsnMondeBridge.php
+++ b/bridges/MsnMondeBridge.php
@@ -1,29 +1,29 @@
uri.'fr-fr/actualite/monde';
+ return self::URI.'fr-fr/actualite/monde';
}
private function MsnMondeExtractContent($url, &$item) {
- $html2 = $this->getSimpleHTMLDOM($url);
+ $html2 = getSimpleHTMLDOM($url);
$item['content'] = $html2->find('#content', 0)->find('article', 0)->find('section', 0)->plaintext;
$item['timestamp'] = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime);
}
public function collectData(){
- $html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request MsnMonde.');
+ $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request MsnMonde.');
$limit = 0;
foreach($html->find('.smalla') as $article) {
if($limit < 10) {
$item = array();
$item['title'] = utf8_decode($article->find('h4', 0)->innertext);
- $item['uri'] = $this->uri . utf8_decode($article->find('a', 0)->href);
+ $item['uri'] = self::URI . utf8_decode($article->find('a', 0)->href);
$this->MsnMondeExtractContent($item['uri'], $item);
$this->items[] = $item;
$limit++;
diff --git a/bridges/MspabooruBridge.php b/bridges/MspabooruBridge.php
index e255f9ee..96ae52ad 100644
--- a/bridges/MspabooruBridge.php
+++ b/bridges/MspabooruBridge.php
@@ -1,42 +1,12 @@
array(
- 'name'=>'page',
- 'type'=>'number'
- ),
- 't'=>array('name'=>'tags')
- ));
-
- public function collectData(){
- $html = $this->getSimpleHTMLDOM(
- $this->uri.'index.php?page=post&s=list&'
- .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
- .'&tags='.urlencode($this->getInput('t'))
- ) or $this->returnServerError('Could not request Mspabooru.');
-
-
- foreach($html->find('div[class=content] span') as $element) {
- $item = array();
- $item['uri'] = $this->uri.$element->find('a', 0)->href;
- $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
- $item['timestamp'] = time();
- $thumbnailUri = $element->find('img', 0)->src;
- $item['tags'] = $element->find('img', 0)->getAttribute('alt');
- $item['title'] = 'Mspabooru | '.$item['postid'];
- $item['content'] = '
Tags: '.$item['tags'];
- $this->items[] = $item;
- }
- }
-
- public function getCacheDuration(){
- return 1800; // 30 minutes
- }
+ const PIDBYPAGE=50;
}
diff --git a/bridges/NakedSecurityBridge.php b/bridges/NakedSecurityBridge.php
deleted file mode 100644
index 5d0fb36c..00000000
--- a/bridges/NakedSecurityBridge.php
+++ /dev/null
@@ -1,68 +0,0 @@
-';
- $close_tag_length = strlen($close_tag);
- if (strpos($tag_start, $open_tag) === 0) {
- while (strpos($string, $tag_start) !== false) {
- $max_recursion = 100;
- $section_to_remove = null;
- $section_start = strpos($string, $tag_start);
- $search_offset = $section_start;
- do {
- $max_recursion--;
- $section_end = strpos($string, $close_tag, $search_offset);
- $search_offset = $section_end + $close_tag_length;
- $section_to_remove = substr($string, $section_start, $section_end - $section_start + $close_tag_length);
- $open_tag_count = substr_count($section_to_remove, $open_tag);
- $close_tag_count = substr_count($section_to_remove, $close_tag);
- } while ($open_tag_count > $close_tag_count && $max_recursion > 0);
- $string = str_replace($section_to_remove, '', $string);
- }
- }
- return $string;
- }
-
- $feedUrl = 'https://feeds.feedburner.com/nakedsecurity?format=xml';
- $html = $this->getSimpleHTMLDOM($feedUrl) or $this->returnServerError('Could not request '.$this->getName().': '.$feedUrl);
- $limit = 0;
-
- foreach ($html->find('item') as $element) {
- if ($limit < 10) {
-
- //Retrieve article Uri and get that page
- $article_uri = $element->find('guid', 0)->plaintext;
- $article_html = $this->getSimpleHTMLDOM($article_uri) or $this->returnServerError('Could not request '.$this->getName().': '.$article_uri);
-
- //Build article contents from corresponding elements
- $article_title = trim($element->find('title', 0)->plaintext);
- $article_image = $article_html->find('img.wp-post-image', 0)->src;
- $article_summary = strip_tags(html_entity_decode($element->find('description', 0)->plaintext));
- $article_content = $article_html->find('div.entry-content', 0)->innertext;
- $article_content = StripRecursiveHTMLSection($article_content , 'div', '
'.$article_summary.'
'.$article_content;
-
- //Build and add final item
- $item = array();
- $item['uri'] = $article_uri;
- $item['title'] = $article_title;
- $item['author'] = $article_html->find('a[rel=author]', 0)->plaintext;
- $item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
- $item['content'] = $article_content;
- $this->items[] = $item;
- $limit++;
- }
- }
- }
-}
diff --git a/bridges/NasaApodBridge.php b/bridges/NasaApodBridge.php
index 9b333c8e..bc284cf0 100644
--- a/bridges/NasaApodBridge.php
+++ b/bridges/NasaApodBridge.php
@@ -1,14 +1,15 @@
getSimpleHTMLDOM($this->uri.'archivepix.html') or $this->returnServerError('Error while downloading the website content');
+ $html = getSimpleHTMLDOM(self::URI.'archivepix.html') or returnServerError('Error while downloading the website content');
$list = explode("
", $html->find('b', 0)->innertext);
for($i = 0; $i < 3;$i++)
@@ -17,10 +18,10 @@ class NasaApodBridge extends BridgeAbstract{
$item = array();
$uri_page = $html->find('a',$i + 3)->href;
- $uri = $this->uri.$uri_page;
+ $uri = self::URI.$uri_page;
$item['uri'] = $uri;
- $picture_html = $this->getSimpleHTMLDOM($uri);
+ $picture_html = getSimpleHTMLDOM($uri);
$picture_html_string = $picture_html->innertext;
//Extract image and explanation
@@ -39,8 +40,4 @@ class NasaApodBridge extends BridgeAbstract{
$this->items[] = $item;
}
}
-
- public function getCacheDuration(){
- return 3600*12; // 12 hours
- }
}
diff --git a/bridges/NeuviemeArtBridge.php b/bridges/NeuviemeArtBridge.php
index 54261c28..0bf3ce38 100644
--- a/bridges/NeuviemeArtBridge.php
+++ b/bridges/NeuviemeArtBridge.php
@@ -1,54 +1,55 @@
uri.'9emeart.rss';
- $html = $this->getSimpleHTMLDOM($feedUrl) or $this->returnServerError('Could not request 9eme Art: '.$feedUrl);
- $limit = 0;
+ $article_html = getSimpleHTMLDOMCached($item['uri']);
+ if(!$article_html){
+ $item['content'] = 'Could not request 9eme Art: '.$item['uri'];
+ return $item;
+ }
- foreach ($html->find('item') as $element) {
- if ($limit < 5) {
+ $article_image = '';
+ foreach ($article_html->find('img.img_full') as $img){
+ if ($img->alt == $item['title']){
+ $article_image = self::URI.$img->src;
+ break;
+ }
+ }
- //Retrieve article Uri and get that page
- $article_uri = $element->find('guid', 0)->plaintext;
- $article_html = $this->getSimpleHTMLDOM($article_uri) or $this->returnServerError('Could not request 9eme Art: '.$article_uri);
+ $article_content='';
+ if($article_image){
+ $article_content = '

';
+ }
+ $article_content .= str_replace(
+ 'src="/', 'src="'.self::URI,
+ $article_html->find('div.newsGenerique_con', 0)->innertext
+ );
+ $article_content = $this->StripWithDelimiters($article_content, '');
- $article_content = StripWithDelimiters($article_content, '