Merge master.

This commit is contained in:
Teromene 2016-11-27 22:50:25 +00:00
commit 38c4f43a3e
166 changed files with 4627 additions and 5382 deletions

View File

@ -1,7 +1,5 @@
language: php language: php
php: php:
- '5.4'
- '5.5'
- '5.6' - '5.6'
- '7.0' - '7.0'
- hhvm - hhvm
@ -14,3 +12,10 @@ script:
- phpenv rehash - phpenv rehash
- phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p - phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
- phpunit -c tests/phpunit.xml - phpunit -c tests/phpunit.xml
matrix:
fast_finish: true
allow_failures:
- php: hhvm
- php: nightly

View File

@ -7,13 +7,14 @@ Alpha 0.1
* Includes refactoring. * Includes refactoring.
* Unstable. * Unstable.
Alpha 0.2 (current development version) Alpha 0.2
=== ===
## Important changes ## Important changes
* RSS-Bridge has been [UNLICENSED](UNLICENSE) * RSS-Bridge has been [UNLICENSED](UNLICENSE)
* RSS-Bridge is now a community-managed project on [GitHub](https://github.com/rss-bridge/rss-bridge) * RSS-Bridge is now a community-managed project on [GitHub](https://github.com/rss-bridge/rss-bridge)
* RSS-Bridge now has a [Wiki](https://github.com/rss-bridge/rss-bridge/wiki) * RSS-Bridge now has a [Wiki](https://github.com/rss-bridge/rss-bridge/wiki)
* RSS-Bridge now supports [Travis-CI](https://travis-ci.org)
## General changes ## General changes
* Added [CHANGELOG](CHANGELOG.md) (this file) * Added [CHANGELOG](CHANGELOG.md) (this file)
@ -21,19 +22,20 @@ Alpha 0.2 (current development version)
* Added cache purging function (cache will be force-purged after 24 hours or as defined by bridge) * Added cache purging function (cache will be force-purged after 24 hours or as defined by bridge)
* Added new format [MrssFormat](formats/MrssFormat.php) * Added new format [MrssFormat](formats/MrssFormat.php)
* Added parameter `author` - for display of the feed author name - to all formats * Added parameter `author` - for display of the feed author name - to all formats
* Added new abstractions of the BridgeInterface: * Added new abstraction of the BridgeInterface:
- [HttpCachingBridgeAbstract](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API) - [FeedExpander](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API)
- [RssExpander](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API)
* Added optional support for proxy usage on each individual bridge * Added optional support for proxy usage on each individual bridge
* Added support for [custom bridge parameter](https://github.com/RSS-Bridge/rss-bridge/wiki/BridgeAbstract#format-specifications) (text, number, list, checkbox) * Added support for [custom bridge parameter](https://github.com/RSS-Bridge/rss-bridge/wiki/BridgeAbstract#format-specifications) (text, number, list, checkbox)
* Changed design of the welcome screen * Changed design of the welcome screen
* Changed design of HtmlFormat * Changed design of HtmlFormat
* Changed behavior of debug mode: * Changed behavior of debug mode:
- Enable debug mode by placing a file called "DEBUG" in the root folder - Enable debug mode by placing a file called "DEBUG" in the root folder
- Debug mode automatically disables caching - Debug mode automatically disables cache file loading
* Changed implementation of bridges - see [Wiki](https://github.com/rss-bridge/rss-bridge/wiki) * Changed implementation of bridges - see [Wiki](https://github.com/rss-bridge/rss-bridge/wiki)
- Changed comment-style metadata to public function [`loadMetadatas`](https://github.com/RSS-Bridge/rss-bridge/wiki/BridgeAbstract#the-loadmetadatas-function) - Changed comment-style metadata to constants
- Added support for multiple utilizations per bridge - Added support for multiple utilizations per bridge
- Changed the parameter loading algorithm to be loaded by RSS-Bridge core
* Improved checks for PHP version, configuration and extensions
* Many bug fixes * Many bug fixes
## Modified Bridges ## Modified Bridges
@ -46,7 +48,6 @@ Alpha 0.2 (current development version)
* AcrimedBridge * AcrimedBridge
* AllocineFRBridge * AllocineFRBridge
* AnimeUltimeBridge * AnimeUltimeBridge
* ArstechnicaBridge
* Arte7Bridge * Arte7Bridge
* AskfmBridge * AskfmBridge
* BandcampBridge * BandcampBridge
@ -80,17 +81,13 @@ Alpha 0.2 (current development version)
* FlickrTagBridge * FlickrTagBridge
* FootitoBridge * FootitoBridge
* FourchanBridge * FourchanBridge
* Freenews
* FuturaSciencesBridge * FuturaSciencesBridge
* GBAtempBridge * GBAtempBridge
* Gawker
* GelbooruBridge * GelbooruBridge
* GiphyBridge * GiphyBridge
* GithubIssueBridge * GithubIssueBridge
* GitlabCommitsBridge * GizmodoBridge
* GizmodoFRBridge
* GooglePlusPostBridge * GooglePlusPostBridge
* GuruMedBridge
* HDWallpapersBridge * HDWallpapersBridge
* HentaiHavenBridge * HentaiHavenBridge
* IdenticaBridge * IdenticaBridge
@ -102,33 +99,31 @@ Alpha 0.2 (current development version)
* KununuBridge * KununuBridge
* LWNprevBridge * LWNprevBridge
* LeBonCoinBridge * LeBonCoinBridge
* LeJournalDuGeekBridge * LegifranceJOBridge
* LeMondeInformatiqueBridge * LeMondeInformatiqueBridge
* Les400Culs
* LesJoiesDuCodeBridge * LesJoiesDuCodeBridge
* LichessBridge * LichessBridge
* LinkedInCompany * LinkedInCompanyBridge
* LolibooruBridge * LolibooruBridge
* MangareaderBridge * MangareaderBridge
* MilbooruBridge * MilbooruBridge
* MoebooruBridge
* MondeDiploBridge * MondeDiploBridge
* MsnMondeBridge * MsnMondeBridge
* MspabooruBridge * MspabooruBridge
* NakedSecurityBridge
* NasaApodBridge * NasaApodBridge
* NeuviemeArtBridge * NeuviemeArtBridge
* NextInpactBridge * NextInpactBridge
* NextgovBridge * NextgovBridge
* NiceMatinBridge * NiceMatinBridge
* NovelUpdatesBridge * NovelUpdatesBridge
* NumeramaBridge
* OpenClassroomsBridge * OpenClassroomsBridge
* ParuVenduImmoBridge * ParuVenduImmoBridge
* PickyWallpapersBridge * PickyWallpapersBridge
* PinterestBridge * PinterestBridge
* PlanetLibreBridge * PlanetLibreBridge
* ProjectMGameBridge
* RTBFBridge * RTBFBridge
* ReadComicsBridge
* Releases3DSBridge * Releases3DSBridge
* ReporterreBridge * ReporterreBridge
* Rue89Bridge * Rue89Bridge
@ -139,9 +134,9 @@ Alpha 0.2 (current development version)
* ScmbBridge * ScmbBridge
* ScoopItBridge * ScoopItBridge
* SensCritiqueBridge * SensCritiqueBridge
* Sexactu * SexactuBridge
* ShanaprojectBridge * ShanaprojectBridge
* SiliconBridge * Shimmie2Bridge
* SoundcloudBridge * SoundcloudBridge
* StripeAPIChangeLogBridge * StripeAPIChangeLogBridge
* SuperbWallpapersBridge * SuperbWallpapersBridge
@ -150,22 +145,19 @@ Alpha 0.2 (current development version)
* TbibBridge * TbibBridge
* TheCodingLoveBridge * TheCodingLoveBridge
* TheHackerNewsBridge * TheHackerNewsBridge
* TheOatMealBridge
* ThePirateBayBridge * ThePirateBayBridge
* TwitchApiBridge
* UnsplashBridge * UnsplashBridge
* ViadeoCompany * ViadeoCompanyBridge
* VineBridge * VineBridge
* VkBridge * VkBridge
* WallpaperStopBridge * WallpaperStopBridge
* WebfailBridge
* WeLiveSecurityBridge * WeLiveSecurityBridge
* WhydBridge * WhydBridge
* WikipediaBridge * WikipediaBridge
* WordPressBridge * WordPressBridge
* WorldOfTanks * WorldOfTanksBridge
* XbooruBridge * XbooruBridge
* YandereBridge * YandereBridge
* YoutubeBridge * YoutubeBridge
* ZDNetBridge * ZDNetBridge
* ZatazBridge
* ZoneTelechargementBridge

View File

@ -51,8 +51,9 @@ RSS-Bridge hashtag (#rss-bridge) search on Twitter, in ATOM format (as displayed
Requirements Requirements
=== ===
* PHP 5.4 * PHP 5.6, e.g. `AddHandler application/x-httpd-php56 .php` in `.htaccess`
* `openssl` extension enabled in PHP config (`php.ini`) * `openssl` extension enabled in PHP config (`php.ini`)
* `allow_url_fopen=1` in `php.ini`
Enabling/Disabling bridges Enabling/Disabling bridges
=== ===
@ -107,6 +108,9 @@ Patch/contributors :
* [kraoc](https://github.com/kraoc) * [kraoc](https://github.com/kraoc)
* [lagaisse](https://github.com/lagaisse) * [lagaisse](https://github.com/lagaisse)
* [az5he6ch](https://github.com/az5he6ch) * [az5he6ch](https://github.com/az5he6ch)
* [niawag](https://github.com/niawag)
* [JeremyRand](https://github.com/JeremyRand)
* [mro](https://github.com/mro)
Licenses Licenses
=== ===

View File

@ -1,14 +1,14 @@
<?php <?php
class ABCTabsBridge extends BridgeAbstract{ class ABCTabsBridge extends BridgeAbstract{
public $maintainer = "kranack"; const MAINTAINER = "kranack";
public $name = "ABC Tabs Bridge"; const NAME = "ABC Tabs Bridge";
public $uri = "http://www.abc-tabs.com/"; const URI = "http://www.abc-tabs.com/";
public $description = "Returns 22 newest tabs"; const DESCRIPTION = "Returns 22 newest tabs";
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$html = $this->getSimpleHTMLDOM('http://www.abc-tabs.com/tablatures/nouveautes.html') or $this->returnClientError('No results for this query.'); $html = getSimpleHTMLDOM(static::URI.'tablatures/nouveautes.html') or returnClientError('No results for this query.');
$table = $html->find('table#myTable', 0)->children(1); $table = $html->find('table#myTable', 0)->children(1);
foreach ($table->find('tr') as $tab) foreach ($table->find('tr') as $tab)
@ -17,8 +17,8 @@ class ABCTabsBridge extends BridgeAbstract{
$item['author'] = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext; $item['author'] = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext;
$item['title'] = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext; $item['title'] = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext;
$item['content'] = 'Le ' . $tab->find('td', 0)->plaintext . '<br> Par: ' . $tab->find('td', 5)->plaintext . '<br> Type: ' . $tab->find('td', 3)->plaintext; $item['content'] = 'Le ' . $tab->find('td', 0)->plaintext . '<br> Par: ' . $tab->find('td', 5)->plaintext . '<br> Type: ' . $tab->find('td', 3)->plaintext;
$item['id'] = 'http://www.abc-tabs.com' . $tab->find('td', 2)->find('a', 0)->getAttribute('href'); $item['id'] = static::URI . $tab->find('td', 2)->find('a', 0)->getAttribute('href');
$item['uri'] = 'http://www.abc-tabs.com' . $tab->find('td', 2)->find('a', 0)->getAttribute('href'); $item['uri'] = static::URI . $tab->find('td', 2)->find('a', 0)->getAttribute('href');
$this->items[] = $item; $this->items[] = $item;
} }
} }

View File

@ -1,42 +1,25 @@
<?php <?php
class AcrimedBridge extends RssExpander{ class AcrimedBridge extends FeedExpander {
const MAINTAINER = "qwertygc";
public $maintainer = "qwertygc"; const NAME = "Acrimed Bridge";
public $name = "Acrimed Bridge"; const URI = "http://www.acrimed.org/";
public $uri = "http://www.acrimed.org/"; const CACHE_TIMEOUT = 4800; //2hours
public $description = "Returns the newest articles."; const DESCRIPTION = "Returns the newest articles.";
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(static::URI.'spip.php?page=backend');
$this->collectExpandableDatas("http://www.acrimed.org/spip.php?page=backend");
} }
protected function parseRSSItem($newsItem) { protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$hs = new HTMLSanitizer();
$namespaces = $newsItem->getNameSpaces(true);
$dc = $newsItem->children($namespaces['dc']);
$item = array();
$item['uri'] = trim($newsItem->link);
$item['title'] = trim($newsItem->title);
$item['timestamp'] = strtotime($dc->date);
$articlePage = $this->getSimpleHTMLDOM($newsItem->link);
$article = $hs->sanitize($articlePage->find('article.article1', 0)->innertext);
$article = HTMLSanitizer::defaultImageSrcTo($article, "http://www.acrimed.org/");
$articlePage = getSimpleHTMLDOM($newsItem->link);
$article = sanitize($articlePage->find('article.article1', 0)->innertext);
$article = defaultImageSrcTo($article, static::URI);
$item['content'] = $article; $item['content'] = $article;
return $item; return $item;
} }
public function getCacheDuration(){
return 4800; // 2 hours
}
} }

View File

@ -2,11 +2,12 @@
class AllocineFRBridge extends BridgeAbstract{ class AllocineFRBridge extends BridgeAbstract{
public $maintainer = "superbaillot.net"; const MAINTAINER = "superbaillot.net";
public $name = "Allo Cine Bridge"; const NAME = "Allo Cine Bridge";
public $uri = "http://www.allocine.fr"; const CACHE_TIMEOUT = 25200; // 7h
public $description = "Bridge for allocine.fr"; const URI = "http://www.allocine.fr/";
public $parameters = array( array( const DESCRIPTION = "Bridge for allocine.fr";
const PARAMETERS = array( array(
'category'=>array( 'category'=>array(
'name'=>'category', 'name'=>'category',
'type'=>'list', 'type'=>'list',
@ -24,13 +25,13 @@ class AllocineFRBridge extends BridgeAbstract{
public function getURI(){ public function getURI(){
switch($this->getInput('category')){ switch($this->getInput('category')){
case 'faux-raccord': case 'faux-raccord':
$uri = 'http://www.allocine.fr/video/programme-12284/saison-24580/'; $uri = static::URI.'video/programme-12284/saison-27129/';
break; break;
case 'top-5': case 'top-5':
$uri = 'http://www.allocine.fr/video/programme-12299/saison-22542/'; $uri = static::URI.'video/programme-12299/saison-29561/';
break; break;
case 'tueurs-en-serie': case 'tueurs-en-serie':
$uri = 'http://www.allocine.fr/video/programme-12286/saison-22938/'; $uri = static::URI.'video/programme-12286/saison-22938/';
break; break;
} }
@ -38,21 +39,21 @@ class AllocineFRBridge extends BridgeAbstract{
} }
public function getName(){ public function getName(){
return $this->name.' : ' return self::NAME.' : '
.array_search( .array_search(
$this->getInput('category'), $this->getInput('category'),
$this->parameters[$this->queriedContext]['category']['values'] self::PARAMETERS[$this->queriedContext]['category']['values']
); );
} }
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or $this->returnServerError("Could not request ".$this->getURI()." !"); or returnServerError("Could not request ".$this->getURI()." !");
$category=array_search( $category=array_search(
$this->getInput('category'), $this->getInput('category'),
$this->parameters[$this->queriedContext]['category']['values'] self::PARAMETERS[$this->queriedContext]['category']['values']
); );
@ -66,19 +67,16 @@ class AllocineFRBridge extends BridgeAbstract{
if($figCaption !== false) if($figCaption !== false)
{ {
$content = str_replace('src="/', 'src="http://www.allocine.fr/', $content); $content = str_replace('src="/', 'src="'.static::URI, $content);
$content = str_replace('href="/', 'href="http://www.allocine.fr/', $content); $content = str_replace('href="/', 'href="'.static::URI, $content);
$content = str_replace('src=\'/', 'src=\'http://www.allocine.fr/', $content); $content = str_replace('src=\'/', 'src=\''.static::URI, $content);
$content = str_replace('href=\'/', 'href=\'http://www.allocine.fr/', $content); $content = str_replace('href=\'/', 'href=\''.static::URI, $content);
$item['content'] = $content; $item['content'] = $content;
$item['title'] = trim($title->innertext); $item['title'] = trim($title->innertext);
$item['uri'] = "http://www.allocine.fr" . $title->href; $item['uri'] = static::URI . $title->href;
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }
public function getCacheDuration(){
return 25200; // 7 hours
}
} }

View File

@ -1,11 +1,12 @@
<?php <?php
class AnimeUltimeBridge extends BridgeAbstract { class AnimeUltimeBridge extends BridgeAbstract {
public $maintainer = 'ORelio'; const MAINTAINER = 'ORelio';
public $name = 'Anime-Ultime'; const NAME = 'Anime-Ultime';
public $uri = 'http://www.anime-ultime.net/'; const URI = 'http://www.anime-ultime.net/';
public $description = 'Returns the 10 newest releases posted on Anime-Ultime'; const CACHE_TIMEOUT = 10800; // 3h
public $parameters = array( array( const DESCRIPTION = 'Returns the 10 newest releases posted on Anime-Ultime';
const PARAMETERS = array( array(
'type'=>array( 'type'=>array(
'name'=>'Type', 'name'=>'Type',
'type'=>'list', 'type'=>'list',
@ -25,7 +26,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
//Add type filter if provided //Add type filter if provided
$typeFilter = array_search( $typeFilter = array_search(
$this->getInput('type'), $this->getInput('type'),
$this->parameters[$this->queriedContext]['type']['values'] self::PARAMETERS[$this->queriedContext]['type']['values']
); );
//Build date and filters for making requests //Build date and filters for making requests
@ -37,9 +38,9 @@ class AnimeUltimeBridge extends BridgeAbstract {
foreach (array($thismonth, $lastmonth) as $requestFilter) { foreach (array($thismonth, $lastmonth) as $requestFilter) {
//Retrive page contents //Retrive page contents
$url = $this->uri.'history-0-1/'.$requestFilter; $url = self::URI.'history-0-1/'.$requestFilter;
$html = $this->getSimpleHTMLDOM($url) $html = getSimpleHTMLDOM($url)
or $this->returnServerError('Could not request Anime-Ultime: '.$url); or returnServerError('Could not request Anime-Ultime: '.$url);
//Relases are sorted by day : process each day individually //Relases are sorted by day : process each day individually
foreach ($html->find('div.history', 0)->find('h3') as $daySection) { foreach ($html->find('div.history', 0)->find('h3') as $daySection) {
@ -58,7 +59,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
//Retrieve metadata from table columns //Retrieve metadata from table columns
$item_link_element = $release->find('td', 0)->find('a', 0); $item_link_element = $release->find('td', 0)->find('a', 0);
$item_uri = $this->uri.$item_link_element->href; $item_uri = self::URI.$item_link_element->href;
$item_name = html_entity_decode($item_link_element->plaintext); $item_name = html_entity_decode($item_link_element->plaintext);
$item_episode = html_entity_decode(str_pad($release->find('td', 1)->plaintext, 2, '0', STR_PAD_LEFT)); $item_episode = html_entity_decode(str_pad($release->find('td', 1)->plaintext, 2, '0', STR_PAD_LEFT));
$item_fansub = $release->find('td', 2)->plaintext; $item_fansub = $release->find('td', 2)->plaintext;
@ -67,8 +68,8 @@ class AnimeUltimeBridge extends BridgeAbstract {
if (!empty($item_uri)) { if (!empty($item_uri)) {
//Retrieve description from description page and convert relative image src info absolute image src //Retrieve description from description page and convert relative image src info absolute image src
$html_item = $this->getContents($item_uri) $html_item = getContents($item_uri)
or $this->returnServerError('Could not request Anime-Ultime: '.$item_uri); or returnServerError('Could not request Anime-Ultime: '.$item_uri);
$item_description = substr( $item_description = substr(
$html_item, $html_item,
strpos($html_item, 'class="principal_contain" align="center">') strpos($html_item, 'class="principal_contain" align="center">')
@ -79,7 +80,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
strpos($item_description, '<div id="table">') strpos($item_description, '<div id="table">')
); );
$item_description = str_replace( $item_description = str_replace(
'src="images', 'src="'.$this->uri.'images', 'src="images', 'src="'.self::URI.'images',
$item_description $item_description
); );
$item_description = str_replace("\r", '', $item_description); $item_description = str_replace("\r", '', $item_description);
@ -109,14 +110,10 @@ class AnimeUltimeBridge extends BridgeAbstract {
public function getName() { public function getName() {
$typeFilter = array_search( $typeFilter = array_search(
$this->getInput('type'), $this->getInput('type'),
$this->parameters[$this->queriedContext]['type']['values'] self::PARAMETERS[$this->queriedContext]['type']['values']
); );
return 'Latest '.$typeFilter.' - Anime-Ultime Bridge'; return 'Latest '.$typeFilter.' - Anime-Ultime Bridge';
} }
public function getCacheDuration() {
return 3600*3; // 3 hours
}
} }

View File

@ -1,66 +0,0 @@
<?php
#ini_set('display_errors', 'On');
#error_reporting(E_ALL);
class ArstechnicaBridge extends BridgeAbstract {
public $maintainer = "prysme";
public $name = "ArstechnicaBridge";
public $uri = "http://arstechnica.com";
public $description = "The PC enthusiast's resource. Power users and the tools they love, without computing religion";
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 StripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
return $string;
}
function ExtractContent($url) {
#echo $url;
$html2 = $this->getSimpleHTMLDOM($url);
$text = $html2->find("section[id='article-guts']", 0);
/*foreach ($text->find('<aside id="social-left">') as $node)
{ $node = NULL; }*/
$text = $this->StripWithDelimiters($text->innertext,'<aside id="social-left">','</aside>');
$text = $this->StripWithDelimiters($text,'<figcaption class="caption">','</figcaption>');
$text = $this->StripWithDelimiters($text,'<div class="gallery shortcode-gallery">','</div>');
//error_log("ICI", 0);
//error_log($text, 0);
return $text;
}
public function collectData(){
$html = $this->getSimpleHTMLDOM('http://feeds.arstechnica.com/arstechnica/index') or $this->returnServerError('Could not request NextInpact.');
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 5) {
$item = array();
$item['title'] = $this->StripCDATA($element->find('title', 0)->innertext);
$item['uri'] = $this->StripCDATA($element->find('guid', 0)->plaintext);
$item['author'] = $this->StripCDATA($element->find('author', 0)->innertext);
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$item['content'] = $this->ExtractContent($item['uri']);
//$item['content'] = $item['uri'];
$this->items[] = $item;
$limit++;
}
}
}
public function getCacheDuration() {
return 7200; // 2h
}
}

View File

@ -1,11 +1,12 @@
<?php <?php
class Arte7Bridge extends BridgeAbstract{ class Arte7Bridge extends BridgeAbstract{
public $maintainer = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
public $name = "Arte +7"; const NAME = "Arte +7";
public $uri = "http://www.arte.tv/"; const URI = "http://www.arte.tv/";
public $description = "Returns newest videos from ARTE +7"; const CACHE_TIMEOUT = 1800; // 30min
public $parameters = array( const DESCRIPTION = "Returns newest videos from ARTE +7";
const PARAMETERS = array(
'Catégorie (Français)' => array( 'Catégorie (Français)' => array(
'catfr'=>array( 'catfr'=>array(
'type'=>'list', 'type'=>'list',
@ -56,18 +57,19 @@
break; break;
} }
$url = $this->uri.'guide/'.$lang.'/plus7/'.$category; $url = self::URI.'guide/'.$lang.'/plus7/'.$category;
$input = $this->getContents($url) or die('Could not request ARTE.'); $input = getContents($url) or die('Could not request ARTE.');
if(strpos($input, 'categoryVideoSet') !== FALSE){ if(strpos($input, 'categoryVideoSet') !== FALSE){
$input = explode('categoryVideoSet: ', $input); $input = explode('categoryVideoSet="', $input);
$input = explode('}},', $input[1]); $input = explode('}}', $input[1]);
$input = $input[0].'}}'; $input = $input[0].'}}';
}else{ }else{
$input = explode('videoSet: ', $input); $input = explode('videoSet="', $input);
$input = explode('}]},', $input[1]); $input = explode('}]}', $input[1]);
$input = $input[0].'}]}'; $input = $input[0].'}]}';
} }
$input_json = json_decode($input, TRUE);
$input_json = json_decode(html_entity_decode($input, ENT_QUOTES), TRUE);
foreach($input_json['videos'] as $element) { foreach($input_json['videos'] as $element) {
$item = array(); $item = array();
@ -86,7 +88,4 @@
} }
} }
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View File

@ -1,11 +1,12 @@
<?php <?php
class AskfmBridge extends BridgeAbstract{ class AskfmBridge extends BridgeAbstract{
public $maintainer = "az5he6ch"; const MAINTAINER = "az5he6ch";
public $name = "Ask.fm Answers"; const NAME = "Ask.fm Answers";
public $uri = "http://ask.fm/"; const URI = "http://ask.fm/";
public $description = "Returns answers from an Ask.fm user"; const CACHE_TIMEOUT = 300; //5 min
public $parameters = array( const DESCRIPTION = "Returns answers from an Ask.fm user";
const PARAMETERS = array(
'Ask.fm username'=>array( 'Ask.fm username'=>array(
'u'=>array( 'u'=>array(
'name'=>'Username', 'name'=>'Username',
@ -15,12 +16,12 @@ class AskfmBridge extends BridgeAbstract{
); );
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
foreach($html->find('div.streamItem-answer') as $element) { foreach($html->find('div.streamItem-answer') as $element) {
$item = array(); $item = array();
$item['uri'] = $this->uri.$element->find('a.streamItemsAge',0)->href; $item['uri'] = self::URI.$element->find('a.streamItemsAge',0)->href;
$question = trim($element->find('h1.streamItemContent-question',0)->innertext); $question = trim($element->find('h1.streamItemContent-question',0)->innertext);
$item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES)); $item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES));
$answer = trim($element->find('p.streamItemContent-answer',0)->innertext); $answer = trim($element->find('p.streamItemContent-answer',0)->innertext);
@ -35,22 +36,17 @@ class AskfmBridge extends BridgeAbstract{
} }
$content = '<p>' . $question . '</p><p>' . $answer . '</p><p>' . $visual . '</p>'; $content = '<p>' . $question . '</p><p>' . $answer . '</p><p>' . $visual . '</p>';
// Fix relative links without breaking // scheme used by YouTube stuff // Fix relative links without breaking // scheme used by YouTube stuff
$content = preg_replace('#href="\/(?!\/)#', 'href="'.$this->uri,$content); $content = preg_replace('#href="\/(?!\/)#', 'href="'.self::URI,$content);
$item['content'] = $content; $item['content'] = $content;
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getName(){ public function getName(){
return $this->name.' : '.$this->getInput('u'); return self::NAME.' : '.$this->getInput('u');
} }
public function getURI(){ public function getURI(){
return $this->uri.urlencode($this->getInput('u')).'/answers/more?page=0'; return self::URI.urlencode($this->getInput('u')).'/answers/more?page=0';
} }
public function getCacheDuration(){
return 300; // 5 minutes
}
} }

View File

@ -1,11 +1,12 @@
<?php <?php
class BandcampBridge extends BridgeAbstract{ class BandcampBridge extends BridgeAbstract{
public $maintainer = "sebsauvage"; const MAINTAINER = "sebsauvage";
public $name = "Bandcamp Tag"; const NAME = "Bandcamp Tag";
public $uri = "http://bandcamp.com/"; const URI = "http://bandcamp.com/";
public $description = "New bandcamp release by tag"; const CACHE_TIMEOUT = 600; // 10min
public $parameters = array( array( const DESCRIPTION = "New bandcamp release by tag";
const PARAMETERS = array( array(
'tag'=>array( 'tag'=>array(
'name'=>'tag', 'name'=>'tag',
'type'=>'text', 'type'=>'text',
@ -14,8 +15,8 @@ class BandcampBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach($html->find('li.item') as $release) { foreach($html->find('li.item') as $release) {
$script = $release->find('div.art', 0)->getAttribute('onclick'); $script = $release->find('div.art', 0)->getAttribute('onclick');
@ -33,14 +34,10 @@ class BandcampBridge extends BridgeAbstract{
} }
public function getURI(){ public function getURI(){
return $this->uri.'tag/'.urlencode($this->getInput('tag')).'?sort_field=date'; return self::URI.'tag/'.urlencode($this->getInput('tag')).'?sort_field=date';
} }
public function getName(){ public function getName(){
return $this->getInput('tag') .' - '.'Bandcamp Tag'; return $this->getInput('tag') .' - '.'Bandcamp Tag';
} }
public function getCacheDuration(){
return 600; // 10 minutes
}
} }

View File

@ -1,18 +1,19 @@
<?php <?php
class BastaBridge extends BridgeAbstract{ class BastaBridge extends BridgeAbstract{
public $maintainer = "qwertygc"; const MAINTAINER = "qwertygc";
public $name = "Bastamag Bridge"; const NAME = "Bastamag Bridge";
public $uri = "http://www.bastamag.net/"; const URI = "http://www.bastamag.net/";
public $description = "Returns the newest articles."; const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "Returns the newest articles.";
public function collectData(){ public function collectData(){
// Replaces all relative image URLs by absolute URLs. Relative URLs always start with 'local/'! // Replaces all relative image URLs by absolute URLs. Relative URLs always start with 'local/'!
function ReplaceImageUrl($content){ function ReplaceImageUrl($content){
return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\''.$this->uri.'$1\'', $content); return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\''.self::URI.'$1\'', $content);
} }
$html = $this->getSimpleHTMLDOM($this->uri.'spip.php?page=backend') $html = getSimpleHTMLDOM(self::URI.'spip.php?page=backend')
or $this->returnServerError('Could not request Bastamag.'); or returnServerError('Could not request Bastamag.');
$limit = 0; $limit = 0;
foreach($html->find('item') as $element) { foreach($html->find('item') as $element) {
@ -21,15 +22,11 @@ class BastaBridge extends BridgeAbstract{
$item['title'] = $element->find('title', 0)->innertext; $item['title'] = $element->find('title', 0)->innertext;
$item['uri'] = $element->find('guid', 0)->plaintext; $item['uri'] = $element->find('guid', 0)->plaintext;
$item['timestamp'] = strtotime($element->find('dc:date', 0)->plaintext); $item['timestamp'] = strtotime($element->find('dc:date', 0)->plaintext);
$item['content'] = ReplaceImageUrl($this->getSimpleHTMLDOM($item['uri'])->find('div.texte', 0)->innertext); $item['content'] = ReplaceImageUrl(getSimpleHTMLDOM($item['uri'])->find('div.texte', 0)->innertext);
$this->items[] = $item; $this->items[] = $item;
$limit++; $limit++;
} }
} }
} }
public function getCacheDuration(){
return 3600*2; // 2 hours
}
} }
?> ?>

View File

@ -1,15 +1,16 @@
<?php <?php
class BlaguesDeMerdeBridge extends BridgeAbstract{ class BlaguesDeMerdeBridge extends BridgeAbstract{
public $maintainer = "superbaillot.net"; const MAINTAINER = "superbaillot.net";
public $name = "Blagues De Merde"; const NAME = "Blagues De Merde";
public $uri = "http://www.blaguesdemerde.fr/"; const URI = "http://www.blaguesdemerde.fr/";
public $description = "Blagues De Merde"; const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "Blagues De Merde";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request BDM.'); or returnServerError('Could not request BDM.');
foreach($html->find('article.joke_contener') as $element) { foreach($html->find('article.joke_contener') as $element) {
$item = array(); $item = array();
@ -28,9 +29,5 @@ class BlaguesDeMerdeBridge extends BridgeAbstract{
} }
} }
} }
public function getCacheDuration(){
return 7200; // 2h hours
}
} }
?> ?>

View File

@ -1,48 +1,36 @@
<?php <?php
class BooruprojectBridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
public $maintainer = "mitsukarenai"; class BooruprojectBridge extends GelbooruBridge{
public $name = "Booruproject";
public $uri = "http://booru.org/";
public $description = "Returns images from given page and booruproject instance (****.booru.org)";
public $parameters = array( array( const MAINTAINER = "mitsukarenai";
'i'=>array( const NAME = "Booruproject";
'name'=>'instance (required)', const URI = "http://booru.org/";
'required'=>true const DESCRIPTION = "Returns images from given page of booruproject";
),
const PARAMETERS = array(
'global'=>array(
'p'=>array( 'p'=>array(
'name'=>'page', 'name'=>'page',
'type'=>'number' 'type'=>'number'
), ),
't'=>array('name'=>'tags') 't'=>array('name'=>'tags')
)); ),
'Booru subdomain (subdomain.booru.org)'=>array(
'i'=>array(
'name'=>'Subdomain',
'required'=>true
)
)
);
function getURI(){ const PIDBYPAGE=20;
public function getURI(){
return 'http://'.$this->getInput('i').'.booru.org/'; return 'http://'.$this->getInput('i').'.booru.org/';
} }
public function collectData(){ public function getName(){
$html = $this->getSimpleHTMLDOM( return static::NAME . ' ' . $this->getInput('i');
$this->getURI().'index.php?page=post&s=list'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*20:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Booruprojec.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = $this->getURI().$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('a', 0)->getAttribute('id'));
$item['timestamp'] = time();
$item['tags'] = $element->find('img', 0)->getAttribute('title');
$item['title'] = 'Booruproject '.$this->getInput('i').' | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $element->find('img', 0)->src . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
} }
} }

View File

@ -1,12 +1,23 @@
<?php <?php
class CADBridge extends BridgeAbstract{ class CADBridge extends FeedExpander {
public $maintainer = "nyutag"; const MAINTAINER = "nyutag";
public $name = "CAD Bridge"; const NAME = "CAD Bridge";
public $uri = "http://www.cad-comic.com/"; const URI = "http://www.cad-comic.com/";
public $description = "Returns the newest articles."; const CACHE_TIMEOUT = 7200; //2h
const DESCRIPTION = "Returns the newest articles.";
public function collectData(){
$this->collectExpandableDatas('http://cdn2.cad-comic.com/rss.xml', 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->CADExtractContent($item['uri']);
return $item;
}
private function CADExtractContent($url) { private function CADExtractContent($url) {
$html3 = $this->getSimpleHTMLDOM($url); $html3 = getSimpleHTMLDOMCached($url);
// The request might fail due to missing https support or wrong URL // The request might fail due to missing https support or wrong URL
if($html3 == false) if($html3 == false)
@ -31,36 +42,5 @@ class CADBridge extends BridgeAbstract{
return 'Daily comic not released yet'; return 'Daily comic not released yet';
return '<img src="'.$img.'"/>'; return '<img src="'.$img.'"/>';
} }
public function collectData(){
function CADUrl($string) {
$html2 = explode("\"", $string);
$string = $html2[1];
if (substr($string,0,4) != 'http')
return 'notanurl';
return $string;
}
$html = $this->getSimpleHTMLDOM('http://cdn2.cad-comic.com/rss.xml') or $this->returnServerError('Could not request CAD.');
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 5) {
$item = array();
$item['title'] = $element->find('title', 0)->innertext;
$item['uri'] = CADUrl($element->find('description', 0)->innertext);
if ($item['uri'] != 'notanurl') {
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$item['content'] = $this->CADExtractContent($item['uri']);
$this->items[] = $item;
$limit++;
}
}
}
}
public function getCacheDuration(){
return 3600*2; // 2 hours
}
} }
?> ?>

View File

@ -1,12 +1,13 @@
<?php <?php
class CNETBridge extends BridgeAbstract { class CNETBridge extends BridgeAbstract {
public $maintainer = 'ORelio'; const MAINTAINER = 'ORelio';
public $name = 'CNET News'; const NAME = 'CNET News';
public $uri = 'http://www.cnet.com/'; const URI = 'http://www.cnet.com/';
public $description = 'Returns the newest articles. <br /> You may specify a topic found in some section URLs, else all topics are selected.'; const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = 'Returns the newest articles. <br /> You may specify a topic found in some section URLs, else all topics are selected.';
public $parameters = array( array( const PARAMETERS = array( array(
'topic'=>array('name'=>'Topic name') 'topic'=>array('name'=>'Topic name')
)); ));
@ -37,21 +38,21 @@ class CNETBridge extends BridgeAbstract {
return $article_html; return $article_html;
} }
$pageUrl = $this->uri.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/'); $pageUrl = self::URI.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/');
$html = $this->getSimpleHTMLDOM($pageUrl) or $this->returnServerError('Could not request CNET: '.$pageUrl); $html = getSimpleHTMLDOM($pageUrl) or returnServerError('Could not request CNET: '.$pageUrl);
$limit = 0; $limit = 0;
foreach($html->find('div.assetBody') as $element) { foreach($html->find('div.assetBody') as $element) {
if ($limit < 8) { if ($limit < 8) {
$article_title = trim($element->find('h2', 0)->plaintext); $article_title = trim($element->find('h2', 0)->plaintext);
$article_uri = $this->uri.($element->find('a', 0)->href); $article_uri = self::URI.($element->find('a', 0)->href);
$article_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext); $article_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext);
$article_author = trim($element->find('a[rel=author]', 0)->plaintext); $article_author = trim($element->find('a[rel=author]', 0)->plaintext);
if (!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false) { if (!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false) {
$article_html = $this->getSimpleHTMLDOM($article_uri) or $this->returnServerError('Could not request CNET: '.$article_uri); $article_html = getSimpleHTMLDOM($article_uri) or returnServerError('Could not request CNET: '.$article_uri);
$article_content = trim(CleanArticle(ExtractFromDelimiters($article_html, '<div class="articleContent', '<footer>'))); $article_content = trim(CleanArticle(ExtractFromDelimiters($article_html, '<div class="articleContent', '<footer>')));
@ -69,10 +70,7 @@ class CNETBridge extends BridgeAbstract {
} }
public function getName() { public function getName() {
return 'CNET News Bridge'.(empty($this->getInput('topic')) ? '' : ' - '.$this->getInput('topic')); $topic=$this->getInput('topic');
} return 'CNET News Bridge'.(empty($topic) ? '' : ' - '.$topic);
public function getCacheDuration() {
return 1800; // 30 minutes
} }
} }

View File

@ -1,11 +1,12 @@
<?php <?php
class CastorusBridge extends BridgeAbstract { class CastorusBridge extends BridgeAbstract {
public $maintainer = "logmanoriginal"; const MAINTAINER = "logmanoriginal";
public $name = "Castorus Bridge"; const NAME = "Castorus Bridge";
public $uri = 'http://www.castorus.com'; const URI = 'http://www.castorus.com';
public $description = "Returns the latest changes"; const CACHE_TIMEOUT = 600; // 10min
const DESCRIPTION = "Returns the latest changes";
public $parameters = array( const PARAMETERS = array(
'Get latest changes' => array(), 'Get latest changes' => array(),
'Get latest changes via ZIP code' => array( 'Get latest changes via ZIP code' => array(
'zip'=>array( 'zip'=>array(
@ -32,7 +33,7 @@ class CastorusBridge extends BridgeAbstract {
$title = $activity->find('a', 0); $title = $activity->find('a', 0);
if(!$title) if(!$title)
$this->returnServerError('Cannot find title!'); returnServerError('Cannot find title!');
return htmlspecialchars(trim($title->plaintext)); return htmlspecialchars(trim($title->plaintext));
} }
@ -42,9 +43,9 @@ class CastorusBridge extends BridgeAbstract {
$url = $activity->find('a', 0); $url = $activity->find('a', 0);
if(!$url) if(!$url)
$this->returnServerError('Cannot find url!'); returnServerError('Cannot find url!');
return $this->uri . $url->href; return self::URI . $url->href;
} }
// Extracts the time from an activity // Extracts the time from an activity
@ -54,7 +55,7 @@ class CastorusBridge extends BridgeAbstract {
$nodes = $activity->find('*'); $nodes = $activity->find('*');
if(!$nodes) if(!$nodes)
$this->returnServerError('Cannot find nodes!'); returnServerError('Cannot find nodes!');
foreach($nodes as $node){ foreach($nodes as $node){
$node->outertext = ''; $node->outertext = '';
@ -68,7 +69,7 @@ class CastorusBridge extends BridgeAbstract {
$price = $activity->find('span', 1); $price = $activity->find('span', 1);
if(!$price) if(!$price)
$this->returnServerError('Cannot find price!'); returnServerError('Cannot find price!');
return $price->innertext; return $price->innertext;
} }
@ -77,15 +78,15 @@ class CastorusBridge extends BridgeAbstract {
$zip_filter = trim($this->getInput('zip')); $zip_filter = trim($this->getInput('zip'));
$city_filter = trim($this->getInput('city')); $city_filter = trim($this->getInput('city'));
$html = $this->getSimpleHTMLDOM($this->uri); $html = getSimpleHTMLDOM(self::URI);
if(!$html) if(!$html)
$this->returnServerError('Could not load data from ' . $this->uri . '!'); returnServerError('Could not load data from ' . self::URI . '!');
$activities = $html->find('div#activite/li'); $activities = $html->find('div#activite/li');
if(!$activities) if(!$activities)
$this->returnServerError('Failed to find activities!'); returnServerError('Failed to find activities!');
foreach($activities as $activity){ foreach($activities as $activity){
$item = array(); $item = array();
@ -107,8 +108,4 @@ class CastorusBridge extends BridgeAbstract {
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 600; // 10 minutes
}
} }

View File

@ -1,10 +1,11 @@
<?php <?php
class CollegeDeFranceBridge extends BridgeAbstract{ class CollegeDeFranceBridge extends BridgeAbstract{
public $maintainer = "pit-fgfjiudghdf"; const MAINTAINER = "pit-fgfjiudghdf";
public $name = "CollegeDeFrance"; const NAME = "CollegeDeFrance";
public $uri = "http://www.college-de-france.fr/"; const URI = "http://www.college-de-france.fr/";
public $description = "Returns the latest audio and video from CollegeDeFrance"; const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the latest audio and video from CollegeDeFrance";
public function collectData(){ public function collectData(){
$months = array( $months = array(
@ -30,8 +31,8 @@ class CollegeDeFranceBridge extends BridgeAbstract{
* </a> * </a>
* </li> * </li>
*/ */
$html = $this->getSimpleHTMLDOM($this->uri.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') $html = getSimpleHTMLDOM(self::URI.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
or $this->returnServerError('Could not request CollegeDeFrance.'); or returnServerError('Could not request CollegeDeFrance.');
foreach($html->find('a[data-target]') as $element) { foreach($html->find('a[data-target]') as $element) {
$item = array(); $item = array();
$item['title'] = $element->find('.title', 0)->plaintext; $item['title'] = $element->find('.title', 0)->plaintext;
@ -62,12 +63,8 @@ class CollegeDeFranceBridge extends BridgeAbstract{
} }
$item['timestamp'] = $d->format('U'); $item['timestamp'] = $d->format('U');
$item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext; $item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext;
$item['uri'] = $this->uri . $element->href; $item['uri'] = self::URI . $element->href;
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 3600*3; // 3 hours
}
} }

View File

@ -1,39 +1,26 @@
<?php <?php
class CommonDreamsBridge extends BridgeAbstract{ class CommonDreamsBridge extends FeedExpander {
public $maintainer = "nyutag"; const MAINTAINER = "nyutag";
public $name = "CommonDreams Bridge"; const NAME = "CommonDreams Bridge";
public $uri = "http://www.commondreams.org/"; const URI = "http://www.commondreams.org/";
public $description = "Returns the newest articles."; const DESCRIPTION = "Returns the newest articles.";
public function collectData(){
$this->collectExpandableDatas('http://www.commondreams.org/rss.xml', 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->CommonDreamsExtractContent($item['uri']);
return $item;
}
private function CommonDreamsExtractContent($url) { private function CommonDreamsExtractContent($url) {
$html3 = $this->getSimpleHTMLDOM($url); $html3 = getSimpleHTMLDOMCached($url);
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext; $text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
$html3->clear(); $html3->clear();
unset ($html3); unset ($html3);
return $text; return $text;
} }
public function collectData(){
function CommonDreamsUrl($string) {
$html2 = explode(" ", $string);
$string = $html2[2] . "/node/" . $html2[0];
return $string;
}
$html = $this->getSimpleHTMLDOM('http://www.commondreams.org/rss.xml') or $this->returnServerError('Could not request CommonDreams.');
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 4) {
$item = array();
$item['title'] = $element->find('title', 0)->innertext;
$item['uri'] = CommonDreamsUrl($element->find('guid', 0)->innertext);
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$item['content'] = $this->CommonDreamsExtractContent($item['uri']);
$this->items[] = $item;
$limit++;
}
}
}
} }

View File

@ -1,14 +1,15 @@
<?php <?php
class CopieDoubleBridge extends BridgeAbstract{ class CopieDoubleBridge extends BridgeAbstract{
public $maintainer = "superbaillot.net"; const MAINTAINER = "superbaillot.net";
public $name = "CopieDouble"; const NAME = "CopieDouble";
public $uri = "http://www.copie-double.com/"; const URI = "http://www.copie-double.com/";
public $description = "CopieDouble"; const CACHE_TIMEOUT = 14400; // 4h
const DESCRIPTION = "CopieDouble";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request CopieDouble.'); or returnServerError('Could not request CopieDouble.');
$table = $html->find('table table', 2); $table = $html->find('table table', 2);
foreach($table->find('tr') as $element) foreach($table->find('tr') as $element)
@ -26,17 +27,13 @@ class CopieDoubleBridge extends BridgeAbstract{
elseif(strpos($element->innertext, "/images/suivant.gif") === false) elseif(strpos($element->innertext, "/images/suivant.gif") === false)
{ {
$a=$element->find("a", 0); $a=$element->find("a", 0);
$item['uri'] = $this->uri . $a->href; $item['uri'] = self::URI . $a->href;
$content = str_replace('src="/', 'src="/'.$this->uri,$element->find("td", 0)->innertext); $content = str_replace('src="/', 'src="/'.self::URI,$element->find("td", 0)->innertext);
$content = str_replace('href="/', 'href="'.$this->uri,$content); $content = str_replace('href="/', 'href="'.self::URI,$content);
$item['content'] = $content; $item['content'] = $content;
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }
public function getCacheDuration(){
return 14400; // 4 hours
}
} }

View File

@ -1,15 +1,16 @@
<?php <?php
class CourrierInternationalBridge extends BridgeAbstract{ class CourrierInternationalBridge extends BridgeAbstract{
public $maintainer = "teromene"; const MAINTAINER = "teromene";
public $name = "Courrier International Bridge"; const NAME = "Courrier International Bridge";
public $uri = "http://CourrierInternational.com/"; const URI = "http://CourrierInternational.com/";
public $description = "Courrier International bridge"; const CACHE_TIMEOUT = 300; // 5 min
const DESCRIPTION = "Courrier International bridge";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Error.'); or returnServerError('Error.');
$element = $html->find("article"); $element = $html->find("article");
@ -22,17 +23,20 @@ class CourrierInternationalBridge extends BridgeAbstract{
$item['uri'] = $article->parent->getAttribute("href"); $item['uri'] = $article->parent->getAttribute("href");
if(strpos($item['uri'], "http") === FALSE) { if(strpos($item['uri'], "http") === FALSE) {
$item['uri'] = $this->uri.$item['uri']; $item['uri'] = self::URI.$item['uri'];
} }
$page = $this->getSimpleHTMLDOM($item['uri']); $page = getSimpleHTMLDOMCached($item['uri']);
$cleaner = new HTMLSanitizer(); $content = $page->find('.article-text',0);
if(!$content){
$content = $page->find('.depeche-text',0);
}
$item['content'] = $cleaner->sanitize($page->find("div.article-text")[0]); $item['content'] = sanitize($content);
$item['title'] = strip_tags($article->find(".title")[0]); $item['title'] = strip_tags($article->find(".title",0));
$dateTime = date_parse($page->find("time")[0]); $dateTime = date_parse($page->find("time",0));
$item['timestamp'] = mktime( $item['timestamp'] = mktime(
$dateTime['hour'], $dateTime['hour'],
@ -52,10 +56,6 @@ class CourrierInternationalBridge extends BridgeAbstract{
} }
public function getCacheDuration(){
return 300; // 5 minutes
}
} }
?> ?>

View File

@ -1,12 +1,13 @@
<?php <?php
class CpasbienBridge extends HttpCachingBridgeAbstract{ class CpasbienBridge extends BridgeAbstract {
public $maintainer = "lagaisse"; const MAINTAINER = "lagaisse";
public $name = "Cpasbien Bridge"; const NAME = "Cpasbien Bridge";
public $uri = "http://www.cpasbien.io"; const URI = "http://www.cpasbien.io";
public $description = "Returns latest torrents from a request query"; const CACHE_TIMEOUT = 86400; // 24h
const DESCRIPTION = "Returns latest torrents from a request query";
public $parameters = array( array( const PARAMETERS = array( array(
'q'=>array( 'q'=>array(
'name'=>'Search', 'name'=>'Search',
'required'=>true, 'required'=>true,
@ -16,19 +17,18 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{
public function collectData(){ public function collectData(){
$request = str_replace(" ","-",trim($this->getInput('q'))); $request = str_replace(" ","-",trim($this->getInput('q')));
$html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($request).'.html') $html = getSimpleHTMLDOM(self::URI.'/recherche/'.urlencode($request).'.html')
or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach ($html->find('#gauche',0)->find('div') as $episode) { foreach ($html->find('#gauche',0)->find('div') as $episode) {
if ($episode->getAttribute('class')=='ligne0' || if ($episode->getAttribute('class')=='ligne0' ||
$episode->getAttribute('class')=='ligne1') $episode->getAttribute('class')=='ligne1')
{ {
$htmlepisode=$this->get_cached($episode->find('a', 0)->getAttribute('href')); $htmlepisode=getSimpleHTMLDOMCached($episode->find('a', 0)->getAttribute('href'));
$item = array(); $item = array();
$item['author'] = $episode->find('a', 0)->text(); $item['author'] = $episode->find('a', 0)->text();
$item['title'] = $episode->find('a', 0)->text(); $item['title'] = $episode->find('a', 0)->text();
$item['timestamp'] = $this->get_cached_time($episode->find('a', 0)->getAttribute('href'));
$textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1); $textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1);
if (isset($textefiche)) { if (isset($textefiche)) {
$item['content'] = $textefiche->text(); $item['content'] = $textefiche->text();
@ -40,7 +40,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{
} }
$item['id'] = $episode->find('a', 0)->getAttribute('href'); $item['id'] = $episode->find('a', 0)->getAttribute('href');
$item['uri'] = $this->uri . $htmlepisode->find('#telecharger',0)->getAttribute('href'); $item['uri'] = self::URI . $htmlepisode->find('#telecharger',0)->getAttribute('href');
$this->items[] = $item; $this->items[] = $item;
} }
} }
@ -48,10 +48,6 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{
public function getName(){ public function getName(){
return $this->getInput('q').' : '.$this->name; return $this->getInput('q').' : '.self::NAME;
}
public function getCacheDuration(){
return 60*60*24; // 24 hours
} }
} }

View File

@ -1,12 +1,13 @@
<?php <?php
class CryptomeBridge extends BridgeAbstract{ class CryptomeBridge extends BridgeAbstract{
public $maintainer = "BoboTiG"; const MAINTAINER = "BoboTiG";
public $name = "Cryptome"; const NAME = "Cryptome";
public $uri = "https://cryptome.org/"; const URI = "https://cryptome.org/";
public $description = "Returns the N most recent documents."; const CACHE_TIMEOUT = 21600; //6h
const DESCRIPTION = "Returns the N most recent documents.";
public $parameters = array( array( const PARAMETERS = array( array(
'n'=>array( 'n'=>array(
'name'=>'number of elements', 'name'=>'number of elements',
'type'=>'number', 'type'=>'number',
@ -16,26 +17,23 @@ class CryptomeBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request Cryptome.'); or returnServerError('Could not request Cryptome.');
if (!empty($this->getInput('n'))) { /* number of documents */ $number=$this->getInput('n');
$num = min($this->getInput('n'), 20); if (!empty($number)) { /* number of documents */
$num = min($number, 20);
} }
foreach($html->find('pre') as $element) { foreach($html->find('pre') as $element) {
for ( $i = 0; $i < $num; ++$i ) { for ( $i = 0; $i < $num; ++$i ) {
$item = array(); $item = array();
$item['uri'] = $this->uri.substr($element->find('a', $i)->href, 20); $item['uri'] = self::URI.substr($element->find('a', $i)->href, 20);
$item['title'] = substr($element->find('b', $i)->plaintext, 22); $item['title'] = substr($element->find('b', $i)->plaintext, 22);
$item['content'] = preg_replace('#http://cryptome.org/#', $this->uri, $element->find('b', $i)->innertext); $item['content'] = preg_replace('#http://cryptome.org/#', self::URI, $element->find('b', $i)->innertext);
$this->items[] = $item; $this->items[] = $item;
} }
break; break;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,12 +1,13 @@
<?php <?php
class DailymotionBridge extends BridgeAbstract{ class DailymotionBridge extends BridgeAbstract{
public $maintainer = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
public $name = "Dailymotion Bridge"; const NAME = "Dailymotion Bridge";
public $uri = "https://www.dailymotion.com/"; const URI = "https://www.dailymotion.com/";
public $description = "Returns the 5 newest videos by username/playlist or search"; const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the 5 newest videos by username/playlist or search";
public $parameters = array ( const PARAMETERS = array (
'By username' => array( 'By username' => array(
'u'=>array( 'u'=>array(
'name'=>'username', 'name'=>'username',
@ -35,7 +36,7 @@ class DailymotionBridge extends BridgeAbstract{
function getMetadata($id) { function getMetadata($id) {
$metadata=array(); $metadata=array();
$html2 = $this->getSimpleHTMLDOM($this->uri.'video/'.$id); $html2 = getSimpleHTMLDOM(self::URI.'video/'.$id);
if(!$html2){ if(!$html2){
return $metadata; return $metadata;
} }
@ -52,8 +53,8 @@ class DailymotionBridge extends BridgeAbstract{
$limit = 5; $limit = 5;
$count = 0; $count = 0;
$html = $this->getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Could not request Dailymotion.'); or returnServerError('Could not request Dailymotion.');
foreach($html->find('div.media a.preview_link') as $element) { foreach($html->find('div.media a.preview_link') as $element) {
if($count < $limit) { if($count < $limit) {
@ -90,7 +91,7 @@ class DailymotionBridge extends BridgeAbstract{
} }
public function getURI(){ public function getURI(){
$uri=$this->uri; $uri=self::URI;
switch($this->queriedContext){ switch($this->queriedContext){
case 'By username': case 'By username':
$uri.='user/' $uri.='user/'
@ -110,8 +111,4 @@ class DailymotionBridge extends BridgeAbstract{
} }
return $uri; return $uri;
} }
public function getCacheDuration(){
return 3600*3; // 3 hours
}
} }

View File

@ -1,39 +1,51 @@
<?php <?php
class DanbooruBridge extends BridgeAbstract{ class DanbooruBridge extends BridgeAbstract{
public $maintainer = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
public $name = "Danbooru"; const NAME = "Danbooru";
public $uri = "http://donmai.us/"; const URI = "http://donmai.us/";
public $description = "Returns images from given page"; const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns images from given page";
public $parameters = array( array( const PARAMETERS = array(
'global'=>array(
'p'=>array( 'p'=>array(
'name'=>'page', 'name'=>'page',
'defaultValue'=>1,
'type'=>'number' 'type'=>'number'
), ),
't'=>array('name'=>'tags') 't'=>array('name'=>'tags')
)); ),
0=>array()
);
const PATHTODATA='article';
const IDATTRIBUTE='data-id';
protected function getFullURI(){
return $this->getURI().'posts?'
.'&page='.$this->getInput('p')
.'&tags='.urlencode($this->getInput('t'));
}
protected function getItemFromElement($element){
$item = array();
$item['uri'] = $this->getURI().$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute(static::IDATTRIBUTE));
$item['timestamp'] = time();
$thumbnailUri = $this->getURI().$element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = $this->getName().' | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
return $item;
}
public function collectData(){ public function collectData(){
$page = $this->getInput('p')?$this->getInput('p'):1; $html = getSimpleHTMLDOM($this->getFullURI())
$tags = urlencode($this->getInput('t')); or returnServerError('Could not request '.$this->getName());
$html = $this->getSimpleHTMLDOM($this->uri."posts?&page=$page&tags=$tags") foreach($html->find(static::PATHTODATA) as $element) {
or $this->returnServerError('Could not request Danbooru.'); $this->items[] = $this->getItemFromElement($element);
foreach($html->find('div[id=posts] article') as $element) {
$item = array();
$item['uri'] = $this->uri.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-id'));
$item['timestamp'] = time();
$thumbnailUri = $this->uri.$element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = 'Danbooru | '.$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,15 +1,16 @@
<?php <?php
class DansTonChatBridge extends BridgeAbstract{ class DansTonChatBridge extends BridgeAbstract{
public $maintainer = "Astalaseven"; const MAINTAINER = "Astalaseven";
public $name = "DansTonChat Bridge"; const NAME = "DansTonChat Bridge";
public $uri = "http://danstonchat.com/"; const URI = "http://danstonchat.com/";
public $description = "Returns latest quotes from DansTonChat."; const CACHE_TIMEOUT = 21600; //6h
const DESCRIPTION = "Returns latest quotes from DansTonChat.";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri.'latest.html') $html = getSimpleHTMLDOM(self::URI.'latest.html')
or $this->returnServerError('Could not request DansTonChat.'); or returnServerError('Could not request DansTonChat.');
foreach($html->find('div.item') as $element) { foreach($html->find('div.item') as $element) {
$item = array(); $item = array();
@ -19,8 +20,4 @@ class DansTonChatBridge extends BridgeAbstract{
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,12 +1,13 @@
<?php <?php
class DauphineLibereBridge extends BridgeAbstract { class DauphineLibereBridge extends FeedExpander {
public $maintainer = "qwertygc"; const MAINTAINER = "qwertygc";
public $name = "Dauphine Bridge"; const NAME = "Dauphine Bridge";
public $uri = "http://www.ledauphine.com/"; const URI = "http://www.ledauphine.com/";
public $description = "Returns the newest articles."; const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "Returns the newest articles.";
public $parameters = array( array( const PARAMETERS = array( array(
'u'=>array( 'u'=>array(
'name'=>'Catégorie de l\'article', 'name'=>'Catégorie de l\'article',
'type'=>'list', 'type'=>'list',
@ -30,41 +31,27 @@ class DauphineLibereBridge extends BridgeAbstract {
) )
)); ));
private function ExtractContent($url, $context) { public function collectData(){
$html2 = $this->getSimpleHTMLDOM($url); $url = self::URI . 'rss';
if (empty($this->getInput('u'))) {
$url = self::URI . $this->getInput('u') . '/rss';
}
$this->collectExpandableDatas($url, 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->ExtractContent($item['uri']);
return $item;
}
private function ExtractContent($url) {
$html2 = getSimpleHTMLDOMCached($url);
$text = $html2->find('div.column', 0)->innertext; $text = $html2->find('div.column', 0)->innertext;
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text); $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
return $text; return $text;
} }
public function collectData(){
$context = stream_context_create($opts);
if (empty($this->getInput('u'))) {
$html = $this->getSimpleHTMLDOM($this->uri.$this->getInput('u').'/rss')
or $this->returnServerError('Could not request DauphineLibere.');
} else {
$html = $this->getSimpleHTMLDOM($this->uri.'rss')
or $this->returnServerError('Could not request DauphineLibere.');
}
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 10) {
$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'] = $this->ExtractContent($item['uri'], $context);
$this->items[] = $item;
$limit++;
}
}
}
public function getCacheDuration(){
return 3600*2; // 2 hours
}
} }
?> ?>

View File

@ -1,12 +1,12 @@
<?php <?php
class DemoBridge extends BridgeAbstract{ class DemoBridge extends BridgeAbstract{
public $maintainer = "teromene"; const MAINTAINER = "teromene";
public $name = "DemoBridge"; const NAME = "DemoBridge";
public $uri = "http://github.com/rss-bridge/rss-bridge"; const URI = "http://github.com/rss-bridge/rss-bridge";
public $description = "Bridge used for demos"; const DESCRIPTION = "Bridge used for demos";
public $parameters = array( const PARAMETERS = array(
'testCheckbox' => array( 'testCheckbox' => array(
'testCheckbox'=>array( 'testCheckbox'=>array(
'type'=>'checkbox', 'type'=>'checkbox',
@ -46,8 +46,4 @@ class DemoBridge extends BridgeAbstract{
$this->items[] = $item; $this->items[] = $item;
} }
public function getCacheDuration(){
return 00; // 1 hour
}
} }

View File

@ -1,10 +1,21 @@
<?php <?php
class DeveloppezDotComBridge extends BridgeAbstract{ class DeveloppezDotComBridge extends FeedExpander {
public $maintainer = "polopollo"; const MAINTAINER = "polopollo";
public $name = "Developpez.com Actus (FR)"; const NAME = "Developpez.com Actus (FR)";
public $uri = "http://www.developpez.com/"; const URI = "http://www.developpez.com/";
public $description = "Returns the 15 newest posts from DeveloppezDotCom (full text)."; const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns the 15 newest posts from DeveloppezDotCom (full text).";
public function collectData(){
$this->collectExpandableDatas(self::URI . 'index/rss', 15);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->DeveloppezDotComExtractContent($item['uri']);
return $item;
}
private function DeveloppezDotComStripCDATA($string) { private function DeveloppezDotComStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string); $string = str_replace('<![CDATA[', '', $string);
@ -32,32 +43,9 @@ class DeveloppezDotComBridge extends BridgeAbstract{
} }
private function DeveloppezDotComExtractContent($url) { private function DeveloppezDotComExtractContent($url) {
$articleHTMLContent = $this->getSimpleHTMLDOM($url); $articleHTMLContent = getSimpleHTMLDOMCached($url);
$text = $this->convert_smart_quotes($articleHTMLContent->find('div.content', 0)->innertext); $text = $this->convert_smart_quotes($articleHTMLContent->find('div.content', 0)->innertext);
$text = utf8_encode($text); $text = utf8_encode($text);
return trim($text); return trim($text);
} }
public function collectData(){
$rssFeed = $this->getSimpleHTMLDOM($this->uri.'index/rss')
or $this->returnServerError('Could not request '.$this->uri.'index/rss');
$limit = 0;
foreach($rssFeed->find('item') as $element) {
if($limit < 10) {
$item = array();
$item['title'] = $this->DeveloppezDotComStripCDATA($element->find('title', 0)->innertext);
$item['uri'] = $this->DeveloppezDotComStripCDATA($element->find('guid', 0)->plaintext);
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$content = $this->DeveloppezDotComExtractContent($item['uri']);
$item['content'] = strlen($content) ? $content : $element->description; //In case of it is a tutorial, we just keep the original description
$this->items[] = $item;
$limit++;
}
}
}
public function getCacheDuration(){
return 1800; // 30min
}
} }

View File

@ -1,14 +1,15 @@
<?php <?php
class DilbertBridge extends BridgeAbstract { class DilbertBridge extends BridgeAbstract {
public $maintainer = 'kranack'; const MAINTAINER = 'kranack';
public $name = 'Dilbert Daily Strip'; const NAME = 'Dilbert Daily Strip';
public $uri = 'http://dilbert.com'; const URI = 'http://dilbert.com';
public $description = 'The Unofficial Dilbert Daily Comic Strip'; const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = 'The Unofficial Dilbert Daily Comic Strip';
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request Dilbert: '.$this->getURI()); $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request Dilbert: '.$this->getURI());
foreach ($html->find('section.comic-item') as $element) { foreach ($html->find('section.comic-item') as $element) {
@ -31,9 +32,5 @@ class DilbertBridge extends BridgeAbstract {
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration() {
return 21600; // 6 hours
}
} }
?> ?>

View File

@ -1,41 +1,11 @@
<?php <?php
class DollbooruBridge extends BridgeAbstract{ require_once('Shimmie2Bridge.php');
public $maintainer = "mitsukarenai"; class DollbooruBridge extends Shimmie2Bridge{
public $name = "Dollbooru";
public $uri = "http://dollbooru.org/";
public $description = "Returns images from given page";
const MAINTAINER = "mitsukarenai";
const NAME = "Dollbooru";
const URI = "http://dollbooru.org/";
const DESCRIPTION = "Returns images from given page";
public $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($this->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'] = $this->uri.$element->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-post-id'));
$item['timestamp'] = time();
$thumbnailUri = $this->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,20 +1,34 @@
<?php <?php
class DuckDuckGoBridge extends BridgeAbstract{ class DuckDuckGoBridge extends BridgeAbstract{
public $maintainer = "Astalaseven"; const MAINTAINER = "Astalaseven";
public $name = "DuckDuckGo"; const NAME = "DuckDuckGo";
public $uri = "https://duckduckgo.com/"; const URI = "https://duckduckgo.com/";
public $description = "Returns most recent results from DuckDuckGo."; const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns results from DuckDuckGo.";
public $parameters = array( array( const SORT_DATE = '+sort:date';
const SORT_RELEVANCE = '';
const PARAMETERS = array( array(
'u'=>array( 'u'=>array(
'name'=>'keyword', 'name'=>'keyword',
'required'=>true) 'required'=>true),
'sort'=>array(
'name'=>'sort by',
'type'=>'list',
'required'=>false,
'values'=>array(
'date'=>self::SORT_DATE,
'relevance'=>self::SORT_RELEVANCE
),
'defaultValue'=>self::SORT_DATE
)
)); ));
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri.'html/?q='.$this->getInput('u').'+sort:date') $html = getSimpleHTMLDOM(self::URI.'html/?q='.$this->getInput('u').$this->getInput('sort'))
or $this->returnServerError('Could not request DuckDuckGo.'); or returnServerError('Could not request DuckDuckGo.');
foreach($html->find('div.results_links') as $element) { foreach($html->find('div.results_links') as $element) {
$item = array(); $item = array();
@ -24,8 +38,4 @@ class DuckDuckGoBridge extends BridgeAbstract{
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,12 +1,12 @@
<?php <?php
class EZTVBridge extends BridgeAbstract{ class EZTVBridge extends BridgeAbstract{
public $maintainer = "alexAubin"; const MAINTAINER = "alexAubin";
public $name = "EZTV"; const NAME = "EZTV";
public $uri = "https://eztv.ch/"; const URI = "https://eztv.ch/";
public $description = "Returns list of *recent* torrents for a specific show on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name."; const DESCRIPTION = "Returns list of *recent* torrents for a specific show on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.";
public $parameters = array( array( const PARAMETERS = array( array(
'i'=>array( 'i'=>array(
'name'=>'Show ids', 'name'=>'Show ids',
'exampleValue'=>'showID1,showID2,…', 'exampleValue'=>'showID1,showID2,…',
@ -34,8 +34,8 @@ class EZTVBridge extends BridgeAbstract{
foreach($showList as $showID){ foreach($showList as $showID){
// Get show page // Get show page
$html = $this->getSimpleHTMLDOM($this->uri.'shows/'.rawurlencode($showID).'/') $html = getSimpleHTMLDOM(self::URI.'shows/'.rawurlencode($showID).'/')
or $this->returnServerError('Could not request EZTV for id "'.$showID.'"'); or returnServerError('Could not request EZTV for id "'.$showID.'"');
// Loop on each element that look like an episode entry... // Loop on each element that look like an episode entry...
foreach($html->find('.forum_header_border') as $element) { foreach($html->find('.forum_header_border') as $element) {
@ -53,7 +53,7 @@ class EZTVBridge extends BridgeAbstract{
// Fill item // Fill item
$item = array(); $item = array();
$item['uri'] = $this->uri.$epinfo->href; $item['uri'] = self::URI.$epinfo->href;
$item['id'] = $item['uri']; $item['id'] = $item['uri'];
$item['timestamp'] = makeTimestamp($released->plaintext); $item['timestamp'] = makeTimestamp($released->plaintext);
$item['title'] = $epinfo->plaintext; $item['title'] = $epinfo->plaintext;

View File

@ -1,20 +1,21 @@
<?php <?php
class EliteDangerousGalnetBridge extends BridgeAbstract class EliteDangerousGalnetBridge extends BridgeAbstract
{ {
public $maintainer = "corenting"; const MAINTAINER = "corenting";
public $name = "Elite: Dangerous Galnet"; const NAME = "Elite: Dangerous Galnet";
public $uri = "https://community.elitedangerous.com/galnet/"; const URI = "https://community.elitedangerous.com/galnet/";
public $description = "Returns the latest page of news from Galnet"; const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "Returns the latest page of news from Galnet";
public function collectData() public function collectData()
{ {
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Error while downloading the website content'); or returnServerError('Error while downloading the website content');
foreach($html->find('div.article') as $element) { foreach($html->find('div.article') as $element) {
$item = array(); $item = array();
$uri = $element->find('h3 a', 0)->href; $uri = $element->find('h3 a', 0)->href;
$uri = $this->uri . substr($uri,strlen('/galnet/')); $uri = self::URI . substr($uri,strlen('/galnet/'));
$item['uri'] = $uri; $item['uri'] = $uri;
$title = $element->find('h3 a', 0)->plaintext; $title = $element->find('h3 a', 0)->plaintext;
@ -31,9 +32,4 @@ class EliteDangerousGalnetBridge extends BridgeAbstract
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration()
{
return 3600 * 2; // 2 hours
}
} }

View File

@ -1,11 +1,12 @@
<?php <?php
class ElsevierBridge extends BridgeAbstract{ class ElsevierBridge extends BridgeAbstract{
public $maintainer = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
public $name = 'Elsevier journals recent articles'; const NAME = 'Elsevier journals recent articles';
public $uri = 'http://www.journals.elsevier.com/'; const URI = 'http://www.journals.elsevier.com/';
public $description = 'Returns the recent articles published in Elsevier journals'; const CACHE_TIMEOUT = 43200; //12h
const DESCRIPTION = 'Returns the recent articles published in Elsevier journals';
public $parameters = array( array( const PARAMETERS = array( array(
'j'=>array( 'j'=>array(
'name'=>'Journal name', 'name'=>'Journal name',
'required'=>true, 'required'=>true,
@ -56,8 +57,8 @@ class ElsevierBridge extends BridgeAbstract{
} }
public function collectData(){ public function collectData(){
$uri = $this->uri . $this->getInput('j') . '/recent-articles/'; $uri = self::URI . $this->getInput('j') . '/recent-articles/';
$html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Elsevier journal '.$this->getInput('j')); $html = getSimpleHTMLDOM($uri) or returnServerError('No results for Elsevier journal '.$this->getInput('j'));
foreach($html->find('.pod-listing') as $article){ foreach($html->find('.pod-listing') as $article){
$item = array(); $item = array();
@ -69,9 +70,5 @@ class ElsevierBridge extends BridgeAbstract{
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 43200; // 12h
}
} }
?> ?>

View File

@ -1,10 +1,11 @@
<?php <?php
class EstCeQuonMetEnProdBridge extends BridgeAbstract { class EstCeQuonMetEnProdBridge extends BridgeAbstract {
public $maintainer = 'ORelio'; const MAINTAINER = 'ORelio';
public $name = 'Est-ce qu\'on met en prod aujourd\'hui ?'; const NAME = 'Est-ce qu\'on met en prod aujourd\'hui ?';
public $uri = 'https://www.estcequonmetenprodaujourdhui.info/'; const URI = 'https://www.estcequonmetenprodaujourdhui.info/';
public $description = 'Should we put a website in production today? (French)'; const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = 'Should we put a website in production today? (French)';
public function collectData(){ public function collectData(){
function ExtractFromDelimiters($string, $start, $end) { function ExtractFromDelimiters($string, $start, $end) {
@ -15,7 +16,7 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract {
} return false; } return false;
} }
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request EstCeQuonMetEnProd: '.$this->getURI()); $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request EstCeQuonMetEnProd: '.$this->getURI());
$item = array(); $item = array();
$item['uri'] = $this->getURI().'#'.date('Y-m-d'); $item['uri'] = $this->getURI().'#'.date('Y-m-d');
@ -25,9 +26,5 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract {
$item['content'] = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />'))); $item['content'] = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />')));
$this->items[] = $item; $this->items[] = $item;
} }
public function getCacheDuration() {
return 21600; // 6 hours
}
} }
?> ?>

View File

@ -1,12 +1,13 @@
<?php <?php
class FacebookBridge extends BridgeAbstract{ class FacebookBridge extends BridgeAbstract{
public $maintainer = "teromene"; const MAINTAINER = "teromene";
public $name = "Facebook"; const NAME = "Facebook";
public $uri = "https://www.facebook.com/"; const URI = "https://www.facebook.com/";
public $description = "Input a page title or a profile log. For a profile log, please insert the parameter as follow : myExamplePage/132621766841117"; const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = "Input a page title or a profile log. For a profile log, please insert the parameter as follow : myExamplePage/132621766841117";
public $parameters =array( array( const PARAMETERS =array( array(
'u'=>array( 'u'=>array(
'name'=>'Username', 'name'=>'Username',
'required'=>true 'required'=>true
@ -31,7 +32,7 @@ class FacebookBridge extends BridgeAbstract{
if (is_array($matches) && count($matches) > 1) { if (is_array($matches) && count($matches) > 1) {
$link = $matches[1]; $link = $matches[1];
if (strpos($link, '/') === 0) if (strpos($link, '/') === 0)
$link = $this->uri.$link.'"'; $link = self::URI.$link.'"';
if (strpos($link, 'facebook.com/l.php?u=') !== false) if (strpos($link, 'facebook.com/l.php?u=') !== false)
$link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&')); $link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
return ' href="'.$link.'"'; return ' href="'.$link.'"';
@ -92,8 +93,8 @@ class FacebookBridge extends BridgeAbstract{
), ),
); );
$context = stream_context_create($http_options); $context = stream_context_create($http_options);
$html = $this->getContents($captcha_action, false, $context); $html = getContents($captcha_action, false, $context);
if ($html === FALSE) { $this->returnServerError('Failed to submit captcha response back to Facebook'); } if ($html === FALSE) { returnServerError('Failed to submit captcha response back to Facebook'); }
unset($_SESSION['captcha_fields']); unset($_SESSION['captcha_fields']);
$html = str_get_html($html); $html = str_get_html($html);
} }
@ -104,11 +105,11 @@ class FacebookBridge extends BridgeAbstract{
//Retrieve page contents //Retrieve page contents
if (is_null($html)) { if (is_null($html)) {
if (!strpos($this->getInput('u'), "/")) { if (!strpos($this->getInput('u'), "/")) {
$html = $this->getSimpleHTMLDOM($this->uri.urlencode($this->getInput('u')).'?_fb_noscript=1') $html = getSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1')
or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
} else { } else {
$html = $this->getSimpleHTMLDOM($this->uri.'pages/'.$this->getInput('u').'?_fb_noscript=1') $html = getSimpleHTMLDOM(self::URI.'pages/'.$this->getInput('u').'?_fb_noscript=1')
or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
} }
} }
@ -123,10 +124,10 @@ class FacebookBridge extends BridgeAbstract{
foreach ($captcha->find('input, button') as $input) foreach ($captcha->find('input, button') as $input)
$captcha_fields[$input->name] = $input->value; $captcha_fields[$input->name] = $input->value;
$_SESSION['captcha_fields'] = $captcha_fields; $_SESSION['captcha_fields'] = $captcha_fields;
$_SESSION['captcha_action'] = $this->uri.$captcha->find('form', 0)->action; $_SESSION['captcha_action'] = self::URI.$captcha->find('form', 0)->action;
//Show captcha filling form to the viewer, proxying the captcha image //Show captcha filling form to the viewer, proxying the captcha image
$img = base64_encode($this->getContents($captcha->find('img', 0)->src)); $img = base64_encode(getContents($captcha->find('img', 0)->src));
header('HTTP/1.1 500 '.Http::getMessageForCode(500)); header('HTTP/1.1 500 '.Http::getMessageForCode(500));
header('Content-Type: text/html'); header('Content-Type: text/html');
die('<form method="post" action="?'.$_SERVER['QUERY_STRING'].'">' die('<form method="post" action="?'.$_SERVER['QUERY_STRING'].'">'
@ -192,7 +193,7 @@ class FacebookBridge extends BridgeAbstract{
$title = substr($title, 0, strpos(wordwrap($title, 64), "\n")).'...'; $title = substr($title, 0, strpos(wordwrap($title, 64), "\n")).'...';
//Build and add final item //Build and add final item
$item['uri'] = $this->uri.$post->find('abbr')[0]->parent()->getAttribute('href'); $item['uri'] = self::URI.$post->find('abbr')[0]->parent()->getAttribute('href');
$item['content'] = $content; $item['content'] = $content;
$item['title'] = $title; $item['title'] = $title;
$item['author'] = $author; $item['author'] = $author;
@ -206,8 +207,4 @@ class FacebookBridge extends BridgeAbstract{
public function getName() { public function getName() {
return (isset($this->authorName) ? $this->authorName.' - ' : '').'Facebook Bridge'; return (isset($this->authorName) ? $this->authorName.' - ' : '').'Facebook Bridge';
} }
public function getCacheDuration() {
return 300; // 5 minutes
}
} }

View File

@ -0,0 +1,62 @@
<?php
class FeedExpanderExampleBridge extends FeedExpander {
const MAINTAINER = 'logmanoriginal';
const NAME = 'FeedExpander Example';
const URI = '#';
const DESCRIPTION = 'Example bridge to test FeedExpander';
const PARAMETERS = array(
'Feed' => array(
'version' => array(
'name' => 'Version',
'type' => 'list',
'required' => true,
'title' => 'Select your feed format/version',
'defaultValue' => 'RSS 2.0',
'values' => array(
'RSS 0.91' => 'rss_0_9_1',
'RSS 1.0' => 'rss_1_0',
'RSS 2.0' => 'rss_2_0',
'ATOM 1.0' => 'atom_1_0'
)
)
)
);
public function collectData(){
switch($this->getInput('version')){
case 'rss_0_9_1':
parent::collectExpandableDatas('http://static.userland.com/gems/backend/sampleRss.xml');
break;
case 'rss_1_0':
parent::collectExpandableDatas('http://feeds.nature.com/nature/rss/current?format=xml');
break;
case 'rss_2_0':
parent::collectExpandableDatas('http://feeds.rssboard.org/rssboard?format=xml');
break;
case 'atom_1_0':
parent::collectExpandableDatas('http://segfault.linuxmint.com/feed/atom/');
break;
default: returnClientError('Unknown version ' . $this->getInput('version') . '!');
}
}
protected function parseItem($newsItem) {
switch($this->getInput('version')){
case 'rss_0_9_1':
return $this->parseRSS_0_9_1_Item($newsItem);
break;
case 'rss_1_0':
return $this->parseRSS_1_0_Item($newsItem);
break;
case 'rss_2_0':
return $this->parseRSS_2_0_Item($newsItem);
break;
case 'atom_1_0':
return $this->parseATOMItem($newsItem);
break;
default: returnClientError('Unknown version ' . $this->getInput('version') . '!');
}
}
}

View File

@ -1,26 +1,23 @@
<?php <?php
class FierPandaBridge extends BridgeAbstract { class FierPandaBridge extends BridgeAbstract {
public $maintainer = "snroki"; const MAINTAINER = "snroki";
public $name = "Fier Panda Bridge"; const NAME = "Fier Panda Bridge";
public $uri = "http://www.fier-panda.fr/"; const URI = "http://www.fier-panda.fr/";
public $description = "Returns latest articles from Fier Panda."; const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns latest articles from Fier Panda.";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request Fier Panda.'); $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request Fier Panda.');
foreach($html->find('div.container-content article') as $element) { foreach($html->find('div.container-content article') as $element) {
$item = array(); $item = array();
$item['uri'] = $this->getURI().$element->find('a', 0)->href; $item['uri'] = $this->getURI().$element->find('a', 0)->href;
$item['title'] = trim($element->find('h2 a', 0)->innertext); $item['title'] = trim($element->find('h1 a', 0)->innertext);
// Remove the link at the end of the article // Remove the link at the end of the article
$element->find('p a', 0)->outertext = ''; $element->find('p a', 0)->outertext = '';
$item['content'] = $element->find('p', 0)->innertext; $item['content'] = $element->find('p', 0)->innertext;
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,14 +1,15 @@
<?php <?php
class FlickrExploreBridge extends BridgeAbstract{ class FlickrExploreBridge extends BridgeAbstract{
public $maintainer = "sebsauvage"; const MAINTAINER = "sebsauvage";
public $name = "Flickr Explore"; const NAME = "Flickr Explore";
public $uri = "https://www.flickr.com/"; const URI = "https://www.flickr.com/";
public $description = "Returns the latest interesting images from Flickr"; const CACHE_TIMEOUT = 21600; // 6
const DESCRIPTION = "Returns the latest interesting images from Flickr";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri.'explore') $html = getSimpleHTMLDOM(self::URI.'explore')
or $this->returnServerError('Could not request Flickr.'); or returnServerError('Could not request Flickr.');
foreach($html->find('.photo-list-photo-view') as $element) { foreach($html->find('.photo-list-photo-view') as $element) {
// Get the styles // Get the styles
@ -22,24 +23,20 @@ class FlickrExploreBridge extends BridgeAbstract{
$imageID = reset($imageURIs); $imageID = reset($imageURIs);
// Get the image JSON via Flickr API // Get the image JSON via Flickr API
$imageJSON = json_decode($this->getContents( $imageJSON = json_decode(getContents(
'https://api.flickr.com/services/rest/?' 'https://api.flickr.com/services/rest/?'
.'method=flickr.photos.getInfo&' .'method=flickr.photos.getInfo&'
.'api_key=103b574d49bd51f0e18bfe907da44a0f&' .'api_key=103b574d49bd51f0e18bfe907da44a0f&'
.'photo_id='.$imageID.'&' .'photo_id='.$imageID.'&'
.'format=json&' .'format=json&'
.'nojsoncallback=1' .'nojsoncallback=1'
)) or $this->returnServerError('Could not request Flickr.'); // FIXME: Request time too long... )) or returnServerError('Could not request Flickr.'); // FIXME: Request time too long...
$item = array(); $item = array();
$item['uri'] = $this->uri.'photo.gne?id='.$imageID; $item['uri'] = self::URI.'photo.gne?id='.$imageID;
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $imageURI . '" /></a>'; // FIXME: Filter javascript ? $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $imageURI . '" /></a>'; // FIXME: Filter javascript ?
$item['title'] = $imageJSON->photo->title->_content; $item['title'] = $imageJSON->photo->title->_content;
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,12 +1,13 @@
<?php <?php
class FlickrTagBridge extends BridgeAbstract{ class FlickrTagBridge extends BridgeAbstract{
public $maintainer = "erwang"; const MAINTAINER = "erwang";
public $name = "Flickr TagUser"; const NAME = "Flickr TagUser";
public $uri = "http://www.flickr.com/"; const URI = "http://www.flickr.com/";
public $description = "Returns the tagged or user images from Flickr"; const CACHE_TIMEOUT = 21600; //6h
const DESCRIPTION = "Returns the tagged or user images from Flickr";
public $parameters = array( const PARAMETERS = array(
'By keyword' => array( 'By keyword' => array(
'q'=>array( 'q'=>array(
'name'=>'keyword', 'name'=>'keyword',
@ -25,27 +26,23 @@ class FlickrTagBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
switch($this->queriedContext){ switch($this->queriedContext){
case 'By keyword': case 'By keyword':
$html = $this->getSimpleHTMLDOM($this->uri.'search/?q='.urlencode($this->getInput('q')).'&s=rec') $html = getSimpleHTMLDOM(self::URI.'search/?q='.urlencode($this->getInput('q')).'&s=rec')
or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
break; break;
case 'by username': case 'by username':
$html = $this->getSimpleHTMLDOM($this->uri.'photos/'.urlencode($this->getInput('u')).'/') $html = getSimpleHTMLDOM(self::URI.'photos/'.urlencode($this->getInput('u')).'/')
or $this->returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
break; break;
} }
foreach($html->find('span.photo_container') as $element) { foreach($html->find('span.photo_container') as $element) {
$item = array(); $item = array();
$item['uri'] = $this->uri.$element->find('a',0)->href; $item['uri'] = self::URI.$element->find('a',0)->href;
$thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src'); $thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src');
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; // FIXME: Filter javascript ? $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; // FIXME: Filter javascript ?
$item['title'] = $element->find('a',0)->title; $item['title'] = $element->find('a',0)->title;
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,14 +1,14 @@
<?php <?php
class FootitoBridge extends BridgeAbstract{ class FootitoBridge extends BridgeAbstract{
public $maintainer = "superbaillot.net"; const MAINTAINER = "superbaillot.net";
public $name = "Footito"; const NAME = "Footito";
public $uri = "http://www.footito.fr/"; const URI = "http://www.footito.fr/";
public $description = "Footito"; const DESCRIPTION = "Footito";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request Footito.'); or returnServerError('Could not request Footito.');
foreach($html->find('div.post') as $element) { foreach($html->find('div.post') as $element) {
$item = array(); $item = array();

View File

@ -1,42 +1,43 @@
<?php <?php
class FourchanBridge extends BridgeAbstract{ class FourchanBridge extends BridgeAbstract{
public $maintainer = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
public $name = "4chan"; const NAME = "4chan";
public $uri = "https://www.4chan.org/"; const URI = "https://boards.4chan.org/";
public $description = "Returns posts from the specified thread"; const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = "Returns posts from the specified thread";
public $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 = getSimpleHTMLDOM($this->getURI())
or $this->returnClientError('This URL seems malformed, please check it.'); or returnServerError("Could not request 4chan, thread not found");
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");
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;
$file=$element->find('.file', 0);
if(!empty($element->find('.file', 0) ) ) { if(!empty($file) ) {
$item['image'] = $element->find('.file a', 0)->href; $item['image'] = $element->find('.file a', 0)->href;
$item['imageThumb'] = $element->find('.file img', 0)->src; $item['imageThumb'] = $element->find('.file img', 0)->src;
if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== FALSE) if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== FALSE)
@ -45,16 +46,23 @@ 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);
} }
public function getCacheDuration(){
return 300; // 5min
}
} }

View File

@ -1,34 +0,0 @@
<?php
define("FREENEWS_RSS", 'http://feeds.feedburner.com/Freenews-Freebox?format=xml');
class FreenewsBridge extends RssExpander {
public $maintainer = "mitsukarenai";
public $name = "Freenews";
public $uri = "http://freenews.fr";
public $description = "Un site d'actualité pour les freenautes (mais ne parlant pas que de la freebox). Ne rentrez pas d'id si vous voulez accéder aux actualités générales.";
public function collectData(){
parent::collectExpandableDatas(FREENEWS_RSS);
}
protected function parseRSSItem($newsItem) {
$item = array();
$item['title'] = trim($newsItem->title);
$this->debugMessage("item has for title \"".$item['title']."\"");
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'] = $content->innertext;
$item['author'] = $articlePage->find('a[rel=author]', 0)->innertext;
// format should parse 2014-03-25T16:21:20Z. But, according to http://stackoverflow.com/a/10478469, it is not that simple
$item['timestamp'] = $this->RSS_2_0_time_to_timestamp($newsItem);
return $item;
}
}

View File

@ -1,12 +1,12 @@
<?php <?php
class FuturaSciencesBridge extends BridgeAbstract { class FuturaSciencesBridge extends FeedExpander {
public $maintainer = 'ORelio'; const MAINTAINER = 'ORelio';
public $name = 'Futura-Sciences Bridge'; const NAME = 'Futura-Sciences Bridge';
public $uri = 'http://www.futura-sciences.com/'; const URI = 'http://www.futura-sciences.com/';
public $description = 'Returns the newest articles.'; const DESCRIPTION = 'Returns the newest articles.';
public $parameters = array( array( const PARAMETERS = array( array(
'feed'=> array( 'feed'=> array(
'name'=>'Feed', 'name'=>'Feed',
'type'=>'list', 'type'=>'list',
@ -79,11 +79,18 @@ class FuturaSciencesBridge extends BridgeAbstract {
)); ));
public function collectData(){ public function collectData(){
$url = self::URI . 'rss/' . $this->getInput('feed') . '.xml';
$this->collectExpandableDatas($url, 10);
}
function StripCDATA($string) { protected function parseItem($newsItem){
$string = str_replace('<![CDATA[', '', $string); $item = parent::parseItem($newsItem);
$string = str_replace(']]>', '', $string); $item['uri'] = str_replace('#xtor=RSS-8', '', $item['uri']);
return $string; $article = getSimpleHTMLDOMCached($item['uri'])
or returnServerError('Could not request Futura-Sciences: ' . $item['uri']);
$item['content'] = $this->ExtractArticleContent($article);
$item['author'] = empty($this->ExtractAuthor($article)) ? $item['author'] : $this->ExtractAuthor($article);
return $item;
} }
function StripWithDelimiters($string, $start, $end) { function StripWithDelimiters($string, $start, $end) {
@ -118,33 +125,7 @@ class FuturaSciencesBridge extends BridgeAbstract {
return $string; return $string;
} }
// Extracts the author from an article or element function ExtractArticleContent($article){
function ExtractAuthor($article, $element){
$article_author = $article->find('span.author', 0);
if($article_author){
$authorname = trim(str_replace(', Futura-Sciences', '', $article_author->plaintext));
if(empty($authorname)){
$element_author = $element->find('author', 0);
if($element_author)
$authorname = StripCDATA($element_author->plaintext);
else
return '';
}
return $authorname;
}
return '';
}
$url = $this->getURI().'rss/'.$this->getInput('feed').'.xml';
$html = $this->getSimpleHTMLDOM($url)
or $this->returnServerError('Could not request Futura-Sciences: '.$url);
$limit = 0;
foreach($html->find('item') as $element) {
if ($limit < 10) {
$article_url = str_replace('#xtor=RSS-8', '', StripCDATA($element->find('guid', 0)->plaintext));
$article = $this->getSimpleHTMLDOM($article_url) or $this->returnServerError('Could not request Futura-Sciences: '.$article_url);
$contents = $article->find('div.content', 0)->innertext; $contents = $article->find('div.content', 0)->innertext;
foreach (array( foreach (array(
@ -161,26 +142,25 @@ class FuturaSciencesBridge extends BridgeAbstract {
'<div class="httplogbar-wrapper noprint', '<div class="httplogbar-wrapper noprint',
'<div id="forumcomments' '<div id="forumcomments'
) as $div_start) { ) as $div_start) {
$contents = StripRecursiveHTMLSection($contents , 'div', $div_start); $contents = $this->StripRecursiveHTMLSection($contents , 'div', $div_start);
} }
$contents = StripWithDelimiters($contents, '<hr ', '/>'); $contents = $this->StripWithDelimiters($contents, '<hr ', '/>');
$contents = StripWithDelimiters($contents, '<p class="content-date', '</p>'); $contents = $this->StripWithDelimiters($contents, '<p class="content-date', '</p>');
$contents = StripWithDelimiters($contents, '<h1 class="content-title', '</h1>'); $contents = $this->StripWithDelimiters($contents, '<h1 class="content-title', '</h1>');
$contents = StripWithDelimiters($contents, 'fs:definition="', '"'); $contents = $this->StripWithDelimiters($contents, 'fs:definition="', '"');
$contents = StripWithDelimiters($contents, 'fs:xt:clicktype="', '"'); $contents = $this->StripWithDelimiters($contents, 'fs:xt:clicktype="', '"');
$contents = StripWithDelimiters($contents, 'fs:xt:clickname="', '"'); $contents = $this->StripWithDelimiters($contents, 'fs:xt:clickname="', '"');
$item = array(); return $contents;
$item['author'] = ExtractAuthor($article, $element);
$item['uri'] = $article_url;
$item['title'] = StripCDATA($element->find('title', 0)->innertext);
$item['timestamp'] = strtotime(StripCDATA($element->find('pubDate', 0)->plaintext));
$item['content'] = trim($contents);
$this->items[] = $item;
$limit++;
}
} }
// Extracts the author from an article or element
function ExtractAuthor($article){
$article_author = $article->find('span.author', 0);
if($article_author){
return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext));
}
return '';
} }
} }

View File

@ -1,12 +1,12 @@
<?php <?php
class GBAtempBridge extends BridgeAbstract { class GBAtempBridge extends BridgeAbstract {
public $maintainer = 'ORelio'; const MAINTAINER = 'ORelio';
public $name = 'GBAtemp'; const NAME = 'GBAtemp';
public $uri = 'http://gbatemp.net/'; const URI = 'http://gbatemp.net/';
public $description = 'GBAtemp is a user friendly underground video game community.'; const DESCRIPTION = 'GBAtemp is a user friendly underground video game community.';
public $parameters = array( array( const PARAMETERS = array( array(
'type'=>array( 'type'=>array(
'name'=>'Type', 'name'=>'Type',
'type'=>'list', 'type'=>'list',
@ -54,7 +54,7 @@ class GBAtempBridge extends BridgeAbstract {
} }
private function fetch_post_content($uri, $site_url) { private function fetch_post_content($uri, $site_url) {
$html = $this->getSimpleHTMLDOM($uri); $html = getSimpleHTMLDOM($uri);
if(!$html){ if(!$html){
return 'Could not request GBAtemp '.$uri; return 'Could not request GBAtemp '.$uri;
} }
@ -65,24 +65,24 @@ class GBAtempBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request GBAtemp.'); or returnServerError('Could not request GBAtemp.');
switch($this->getInput('type')){ switch($this->getInput('type')){
case 'N': case 'N':
foreach ($html->find('li[class=news_item full]') as $newsItem) { foreach ($html->find('li[class=news_item full]') as $newsItem) {
$url = $this->uri.$newsItem->find('a', 0)->href; $url = self::URI.$newsItem->find('a', 0)->href;
$time = intval($this->ExtractFromDelimiters($newsItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); $time = intval($this->ExtractFromDelimiters($newsItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
$author = $newsItem->find('a.username', 0)->plaintext; $author = $newsItem->find('a.username', 0)->plaintext;
$title = $newsItem->find('a', 1)->plaintext; $title = $newsItem->find('a', 1)->plaintext;
$content = $this->fetch_post_content($url, $this->uri); $content = $this->fetch_post_content($url, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content); $this->items[] = $this->build_item($url, $title, $author, $time, $content);
} }
case 'R': case 'R':
foreach ($html->find('li.portal_review') as $reviewItem) { foreach ($html->find('li.portal_review') as $reviewItem) {
$url = $this->uri.$reviewItem->find('a', 0)->href; $url = self::URI.$reviewItem->find('a', 0)->href;
$title = $reviewItem->find('span.review_title', 0)->plaintext; $title = $reviewItem->find('span.review_title', 0)->plaintext;
$content = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request GBAtemp: '.$uri); $content = getSimpleHTMLDOM($url) or returnServerError('Could not request GBAtemp: '.$uri);
$author = $content->find('a.username', 0)->plaintext; $author = $content->find('a.username', 0)->plaintext;
$time = intval($this->ExtractFromDelimiters($content->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); $time = intval($this->ExtractFromDelimiters($content->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
$intro = '<p><b>'.($content->find('div#review_intro', 0)->plaintext).'</b></p>'; $intro = '<p><b>'.($content->find('div#review_intro', 0)->plaintext).'</b></p>';
@ -90,25 +90,25 @@ class GBAtempBridge extends BridgeAbstract {
$subheader = '<p><b>'.$content->find('div.review_subheader', 0)->plaintext.'</b></p>'; $subheader = '<p><b>'.$content->find('div.review_subheader', 0)->plaintext.'</b></p>';
$procons = $content->find('table.review_procons', 0)->outertext; $procons = $content->find('table.review_procons', 0)->outertext;
$scores = $content->find('table.reviewscores', 0)->outertext; $scores = $content->find('table.reviewscores', 0)->outertext;
$content = $this->cleanup_post_content($intro.$review.$subheader.$procons.$scores, $this->uri); $content = $this->cleanup_post_content($intro.$review.$subheader.$procons.$scores, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content); $this->items[] = $this->build_item($url, $title, $author, $time, $content);
} }
case 'T': case 'T':
foreach ($html->find('li.portal-tutorial') as $tutorialItem) { foreach ($html->find('li.portal-tutorial') as $tutorialItem) {
$url = $this->uri.$tutorialItem->find('a', 0)->href; $url = self::URI.$tutorialItem->find('a', 0)->href;
$title = $tutorialItem->find('a', 0)->plaintext; $title = $tutorialItem->find('a', 0)->plaintext;
$time = intval($this->ExtractFromDelimiters($tutorialItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); $time = intval($this->ExtractFromDelimiters($tutorialItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
$author = $tutorialItem->find('a.username', 0)->plaintext; $author = $tutorialItem->find('a.username', 0)->plaintext;
$content = $this->fetch_post_content($url, $this->uri); $content = $this->fetch_post_content($url, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content); $this->items[] = $this->build_item($url, $title, $author, $time, $content);
} }
case 'F': case 'F':
foreach ($html->find('li.rc_item') as $postItem) { foreach ($html->find('li.rc_item') as $postItem) {
$url = $this->uri.$postItem->find('a', 1)->href; $url = self::URI.$postItem->find('a', 1)->href;
$title = $postItem->find('a', 1)->plaintext; $title = $postItem->find('a', 1)->plaintext;
$time = intval($this->ExtractFromDelimiters($postItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); $time = intval($this->ExtractFromDelimiters($postItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
$author = $postItem->find('a.username', 0)->plaintext; $author = $postItem->find('a.username', 0)->plaintext;
$content = $this->fetch_post_content($url, $this->uri); $content = $this->fetch_post_content($url, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content); $this->items[] = $this->build_item($url, $title, $author, $time, $content);
} }
} }
@ -117,13 +117,8 @@ class GBAtempBridge extends BridgeAbstract {
public function getName() { public function getName() {
$type=array_search( $type=array_search(
$this->getInput('type'), $this->getInput('type'),
$this->parameters[$this->queriedContext]['type']['values'] self::PARAMETERS[$this->queriedContext]['type']['values']
); );
return 'GBAtemp '.$type.' Bridge'; return 'GBAtemp '.$type.' Bridge';
} }
public function getCacheDuration() {
return ($this->filter === 'Forum') ? 300 : 3600; // 5 minutes / 1 hour
}
} }

View File

@ -1,40 +1,21 @@
<?php <?php
class GelbooruBridge extends BridgeAbstract{ require_once('DanbooruBridge.php');
public $maintainer = "mitsukarenai"; class GelbooruBridge extends DanbooruBridge{
public $name = "Gelbooru";
public $uri = "http://gelbooru.com/";
public $description = "Returns images from given page";
public $parameters = array( array( const MAINTAINER = "mitsukarenai";
'p'=>array( const NAME = "Gelbooru";
'name'=>'page', const URI = "http://gelbooru.com/";
'type'=>'number' const DESCRIPTION = "Returns images from given page";
),
't'=>array('name'=>'tags')
));
public function collectData(){ const PATHTODATA='.thumb';
$html = $this->getSimpleHTMLDOM( const IDATTRIBUTE='id';
$this->uri.'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*63:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Gelbooru.');
foreach($html->find('div[class=content] span') as $element) { const PIDBYPAGE=63;
$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'] = 'Gelbooru | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){ protected function getFullURI(){
return 1800; // 30 minutes return $this->getURI().'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*static::PIDBYPAGE:'')
.'&tags='.urlencode($this->getInput('t'));
} }
} }

View File

@ -3,12 +3,13 @@ define('GIPHY_LIMIT', 10);
class GiphyBridge extends BridgeAbstract{ class GiphyBridge extends BridgeAbstract{
public $maintainer = "kraoc"; const MAINTAINER = "kraoc";
public $name = "Giphy Bridge"; const NAME = "Giphy Bridge";
public $uri = "http://giphy.com/"; const URI = "http://giphy.com/";
public $description = "Bridge for giphy.com"; const CACHE_TIMEOUT = 300; //5min
const DESCRIPTION = "Bridge for giphy.com";
public $parameters = array( array( const PARAMETERS = array( array(
's'=>array( 's'=>array(
'name'=>'search tag', 'name'=>'search tag',
'required'=>true 'required'=>true
@ -22,8 +23,8 @@ class GiphyBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$base_url = 'http://giphy.com'; $base_url = 'http://giphy.com';
$html = $this->getSimpleHTMLDOM($this->uri.'/search/'.urlencode($this->getInput('s').'/')) $html = getSimpleHTMLDOM(self::URI.'/search/'.urlencode($this->getInput('s').'/'))
or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
$max = GIPHY_LIMIT; $max = GIPHY_LIMIT;
if ($this->getInput('n')) { if ($this->getInput('n')) {
@ -37,8 +38,8 @@ class GiphyBridge extends BridgeAbstract{
$node = $entry->first_child(); $node = $entry->first_child();
$href = $node->getAttribute('href'); $href = $node->getAttribute('href');
$html2 = $this->getSimpleHTMLDOM($this->uri . $href) $html2 = getSimpleHTMLDOM(self::URI . $href)
or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
$figure = $html2->getElementByTagName('figure'); $figure = $html2->getElementByTagName('figure');
$img = $figure->firstChild(); $img = $figure->firstChild();
$caption = $figure->lastChild(); $caption = $figure->lastChild();
@ -67,8 +68,4 @@ class GiphyBridge extends BridgeAbstract{
} }
} }
} }
public function getCacheDuration(){
return 300; // 5 minutes
}
} }

View File

@ -1,12 +1,13 @@
<?php <?php
class GithubIssueBridge extends BridgeAbstract{ class GithubIssueBridge extends BridgeAbstract{
public $maintainer = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
public $name = 'Github Issue'; const NAME = 'Github Issue';
public $uri = 'https://github.com/'; const URI = 'https://github.com/';
public $description = 'Returns the issues or comments of an issue of a github project'; const CACHE_TIMEOUT = 600; // 10min
const DESCRIPTION = 'Returns the issues or comments of an issue of a github project';
public $parameters=array( const PARAMETERS=array(
'global'=>array ( 'global'=>array (
'u'=>array( 'u'=>array(
'name'=>'User name', 'name'=>'User name',
@ -18,7 +19,12 @@ class GithubIssueBridge extends BridgeAbstract{
) )
), ),
'Project Issues'=>array(), 'Project Issues'=>array(
'c'=>array(
'name'=>'Show Issues Comments',
'type'=>'checkbox'
)
),
'Issue comments'=>array( 'Issue comments'=>array(
'i'=>array( 'i'=>array(
'name'=>'Issue number', 'name'=>'Issue number',
@ -28,46 +34,157 @@ class GithubIssueBridge extends BridgeAbstract{
) )
); );
public function collectData(){ public function getName(){
$uri = $this->uri.$this->getInput('u').'/'.$this->getInput('p') $name=$this->getInput('u').'/'.$this->getInput('p');
.'/issues/'.$this->getInput('i');
$html = $this->getSimpleHTMLDOM($uri)
or $this->returnServerError('No results for Github Issue '.$this->getInput('i').' in project '.$this->getInput('u').'/'.$this->getInput('p'));
switch($this->queriedContext){ switch($this->queriedContext){
case 'Issue Comments': case 'Project Issues':
foreach($html->find('.js-comment-container') as $comment){ if($this->getInput('c')){
$prefix=static::NAME.'s comments for ';
}else{
$prefix=static::NAME.'s for ';
}
$name=$prefix.$name;
break;
case 'Issue comments':
$name=static::NAME.' '.$name.' #'.$this->getInput('i');
break;
}
return $name;
}
public function getURI(){
$uri = static::URI.$this->getInput('u').'/'.$this->getInput('p').'/issues';
if($this->queriedContext==='Issue comments'){
$uri.='/'.$this->getInput('i');
}else if($this->getInput('c')){
$uri.='?q=is%3Aissue+sort%3Aupdated-desc';
}
return $uri;
}
protected function extractIssueComment($issueNbr,$title,$comment){
$class=$comment->getAttribute('class');
$classes=explode(' ',$class);
$event=false;
if(in_array('discussion-item',$classes)){
$event=true;
}
$author='unknown';
if($comment->find('.author',0)){
$author=$comment->find('.author',0)->plaintext;
}
$uri=static::URI.$this->getInput('u').'/'.$this->getInput('p').'/issues/'
.$issueNbr;
$comment=$comment->firstChild();
if(!$event){
$comment=$comment->nextSibling();
}
if($event){
$title.=' / '.substr($class,strpos($class,'discussion-item-')+strlen('discussion-item-'));
if(!$comment->hasAttribute('id')){
$items=array();
$timestamp=strtotime($comment->find('relative-time',0)->getAttribute('datetime'));
$content=$comment->innertext;
while($comment=$comment->nextSibling()){
$item=array();
$item['author']=$author;
$item['title']=html_entity_decode($title,ENT_QUOTES,'UTF-8');
$item['timestamp']=$timestamp;
$item['content']=$content.'<p>'.$comment->children(1)->innertext.'</p>';
$item['uri']=$uri.'#'.$comment->children(1)->getAttribute('id');
$items[]=$item;
}
return $items;
}
$content=$comment->parent()->innertext;
}else{
$title.=' / '.trim($comment->firstChild()->plaintext);
$content="<pre>".$comment->find('.comment-body',0)->innertext."</pre>";
}
$item = array(); $item = array();
$item['author']=$comment->find('img',0)->getAttribute('alt'); $item['author']=$author;
$item['uri']= $uri.'#'.$comment->getAttribute('id');
$comment=$comment->firstChild()->nextSibling(); $item['title']=html_entity_decode($title,ENT_QUOTES,'UTF-8');
$item['uri']=$uri.'#'.$comment->getAttribute('id');
$item['title']=trim($comment->firstChild()->plaintext);
$item['timestamp']=strtotime($comment->find('relative-time',0)->getAttribute('datetime')); $item['timestamp']=strtotime($comment->find('relative-time',0)->getAttribute('datetime'));
$item['content']=$comment->find('.comment-body',0)->innertext; $item['content']=$content;
return $item;
$this->items[]=$item;
} }
protected function extractIssueComments($issue){
$items=array();
$title=$issue->find('.gh-header-title',0)->plaintext;
$issueNbr=trim(substr($issue->find('.gh-header-number',0)->plaintext,1));
$comments=$issue->find('.js-discussion',0);
foreach($comments->children() as $comment){
$classes=explode(' ',$comment->getAttribute('class'));
if(in_array('discussion-item',$classes) ||
in_array('timeline-comment-wrapper',$classes)
){
$item=$this->extractIssueComment($issueNbr,$title,$comment);
if(array_keys($item)!==range(0,count($item)-1)){
$item=array($item);
}
$items=array_merge($items,$item);
}
}
return $items;
}
public function collectData(){
$html = getSimpleHTMLDOM($this->getURI())
or returnServerError('No results for Github Issue '.$this->getURI());
switch($this->queriedContext){
case 'Issue comments':
$this->items=$this->extractIssueComments($html);
break; break;
case 'Project Issues': case 'Project Issues':
foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue){ foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue){
$item=array();
$info=$issue->find('.opened-by',0); $info=$issue->find('.opened-by',0);
$issueNbr=substr(trim($info->plaintext),1,strpos(trim($info->plaintext),' '));
$item=array();
$item['content']='';
if($this->getInput('c')){
$uri=static::URI.$this->getInput('u').'/'.$this->getInput('p').'/issues/'.$issueNbr;
$issue=getSimpleHTMLDOMCached($uri,static::CACHE_TIMEOUT);
if($issue){
$this->items=array_merge($this->items,$this->extractIssueComments($issue));
continue;
}
$item['content']='Can not extract comments from '.$uri;
}
$item['author']=$info->find('a',0)->plaintext; $item['author']=$info->find('a',0)->plaintext;
$item['timestamp']=strtotime($info->find('relative-time',0)->getAttribute('datetime')); $item['timestamp']=strtotime($info->find('relative-time',0)->getAttribute('datetime'));
$item['title']=$issue->find('.js-navigation-open',0)->plaintext; $item['title']=html_entity_decode(
$issue->find('.js-navigation-open',0)->plaintext,
ENT_QUOTES,
'UTF-8'
);
$comments=$issue->find('.col-5',0)->plaintext; $comments=$issue->find('.col-5',0)->plaintext;
$item['content']='Comments: '.($comments?$comments:'0'); $item['content'].="\n".'Comments: '.($comments?$comments:'0');
$item['uri']=$this->uri.$issue->find('.js-navigation-open',0)->getAttribute('href'); $item['uri']=self::URI.$issue->find('.js-navigation-open',0)->getAttribute('href');
$this->items[]=$item; $this->items[]=$item;
} }
break; break;
} }
}
public function getCacheDuration(){ array_walk($this->items, function(&$item){
return 600; // ten minutes $item['content']=preg_replace('/\s+/',' ',$item['content']);
$item['content']=str_replace('href="/','href="'.static::URI,$item['content']);
$item['content']=str_replace(
'href="#',
'href="'.substr($item['uri'],0,strpos($item['uri'],'#')+1),
$item['content']
);
$item['title']=preg_replace('/\s+/',' ',$item['title']);
});
} }
} }

View File

@ -1,66 +0,0 @@
<?php
class GitlabCommitsBridge extends BridgeAbstract{
public $maintainer = 'Pierre Mazière';
public $name = 'Gitlab Commits';
public $uri = '';
public $description = 'Returns the commits of a project hosted on a gitlab instance';
public $parameters = array( array(
'uri'=>array(
'name'=>'Base URI',
'defaultValue'=>'https://gitlab.com'
),
'u'=>array(
'name'=>'User name',
'required'=>true
),
'p'=>array(
'name'=>'Project name',
'required'=>true
),
'b'=>array(
'name'=>'Project branch',
'defaultValue'=>'master'
)
));
public function collectData(){
$uri = $this->getInput('uri').'/'.$this->getInput('u').'/'
.$this->getInput('p').'/commits/'.$this->getInput('b');
$html = $this->getSimpleHTMLDOM($uri)
or $this->returnServerError('No results for Gitlab Commits of project '.$uri);
foreach($html->find('li.commit') as $commit){
$item = array();
$item['uri']=$this->getInput('uri');
foreach($commit->getElementsByTagName('a') as $a){
$classes=explode(' ',$a->getAttribute("class"));
if(in_array('commit-short-id',$classes) ||
in_array('commit_short_id',$classes)){
$href=$a->getAttribute('href');
$item['uri'].=substr($href,strpos($href,'/'.$this->getInput('u').'/'.$this->getInput('p')));
}
if(in_array('commit-row-message',$classes)){
$item['title']=$a->plaintext;
}
if(in_array('commit-author-link',$classes)){
$item['author']=trim($a->plaintext);
}
}
$pre=$commit->find('pre',0);
if($pre){
$item['content']=$pre->outertext;
}else{
$item['content']='';
}
$item['timestamp']=strtotime($commit->find('time',0)->getAttribute('datetime'));
$this->items[]=$item;
}
}
}

32
bridges/GizmodoBridge.php Normal file
View File

@ -0,0 +1,32 @@
<?php
class GizmodoBridge extends FeedExpander {
const MAINTAINER = "polopollo";
const NAME = "Gizmodo";
const URI = "http://gizmodo.com/";
const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns the newest posts from Gizmodo (full text).";
protected function parseItem($item){
$item = parent::parseItem($item);
$articleHTMLContent = getSimpleHTMLDOMCached($item['uri']);
if(!$articleHTMLContent){
$text = 'Could not load '.$item['uri'];
}else{
$text = $articleHTMLContent->find('div.entry-content', 0)->innertext;
foreach($articleHTMLContent->find('pagespeed_iframe') as $element) {
$text .= '<p>link to a iframe (could be a video): <a href="'.$element->src.'">'.$element->src.'</a></p><br>';
}
$text = strip_tags($text, '<p><b><a><blockquote><img><em>');
}
$item['content'] = $text;
return $item;
}
public function collectData(){
$this->collectExpandableDatas('http://feeds.gawker.com/gizmodo/full');
}
}

View File

@ -1,48 +0,0 @@
<?php
class GizmodoFRBridge extends BridgeAbstract{
public $maintainer = "polopollo";
public $name = "GizmodoFR";
public $uri = "http://www.gizmodo.fr/";
public $description = "Returns the 15 newest posts from GizmodoFR (full text).";
public function collectData(){
function GizmodoFRExtractContent($url) {
$articleHTMLContent = $this->getSimpleHTMLDOM($url);
if(!$articleHTMLContent){
return 'Could not load '.$url;
}
$text = $articleHTMLContent->find('div.entry-thumbnail', 0)->innertext;
$text = $text.$articleHTMLContent->find('div.entry-excerpt', 0)->innertext;
$text = $text.$articleHTMLContent->find('div.entry-content', 0)->innertext;
foreach($articleHTMLContent->find('pagespeed_iframe') as $element) {
$text = $text.'<p>link to a iframe (could be a video): <a href="'.$element->src.'">'.$element->src.'</a></p><br>';
}
$text = strip_tags($text, '<p><b><a><blockquote><img><em>');
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
}
}

View File

@ -4,12 +4,13 @@ class GooglePlusPostBridge extends BridgeAbstract
protected $_title; protected $_title;
protected $_url; protected $_url;
public $maintainer = "Grummfy"; const MAINTAINER = "Grummfy";
public $name = "Google Plus Post Bridge"; const NAME = "Google Plus Post Bridge";
public $uri = "https://plus.google.com/"; const URI = "https://plus.google.com/";
public $description = "Returns user public post (without API)."; const CACHE_TIMEOUT = 600; //10min
const DESCRIPTION = "Returns user public post (without API).";
public $parameters = array( array( const PARAMETERS = array( array(
'username'=>array( 'username'=>array(
'name'=>'username or Id', 'name'=>'username or Id',
'required'=>true 'required'=>true
@ -19,13 +20,13 @@ class GooglePlusPostBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
// get content parsed // get content parsed
// $html = $this->getSimpleHTMLDOM(__DIR__ . '/../posts2.html' // $html = getSimpleHTMLDOM(__DIR__ . '/../posts2.html'
$html = $this->getSimpleHTMLDOM($this->uri . urlencode($this->getInput('username')) . '/posts' $html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('username')) . '/posts'
// force language // force language
, false, stream_context_create(array('http'=> array( , 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" '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 // get title, url, ... there is a lot of intresting stuff in meta
$this->_title = $html->find('meta[property]', 0)->getAttribute('content'); $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['title'] = $item['fullname'] = $post->find('header.lea', 0)->plaintext;
$item['avatar'] = $post->find('div.ys img', 0)->src; $item['avatar'] = $post->find('div.ys img', 0)->src;
// var_dump((($post->find('a.o-U-s', 0)->getAllAttributes()))); // 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); $item['timestamp'] = strtotime($post->find('a.o-U-s', 0)->plaintext);
$this->items[] = $item; $this->items[] = $item;
@ -56,21 +57,21 @@ class GooglePlusPostBridge extends BridgeAbstract
$hashtags = array(); $hashtags = array();
foreach($post->find('a.d-s') as $hashtag) 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'] = ''; $item['content'] = '';
// avatar display // avatar display
$item['content'] .= '<div style="float:left; margin: 0 0.5em 0.5em 0;"><a href="' . $this->uri . urlencode($this->getInput('username')); $item['content'] .= '<div style="float:left; margin: 0 0.5em 0.5em 0;"><a href="' . self::URI . urlencode($this->getInput('username'));
$item['content'] .= '"><img align="top" alt="avatar" src="' . $item['avatar'].'" />' . $item['username'] . '</a></div>'; $item['content'] .= '"><img align="top" alt="avatar" src="' . $item['avatar'].'" />' . $item['username'] . '</a></div>';
$content = $post->find('div.Al', 0); $content = $post->find('div.Al', 0);
// alter link // alter link
// $content = $content->innertext; // $content = $content->innertext;
// $content = str_replace('href="./', 'href="' . $this->uri, $content); // $content = str_replace('href="./', 'href="' . self::URI, $content);
// $content = str_replace('href="photos', 'href="' . $this->uri . 'photos', $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 // 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) foreach($content->find('a') as $link)
{ {
@ -86,7 +87,7 @@ class GooglePlusPostBridge extends BridgeAbstract
{ {
$link->href = substr($link->href, 1); $link->href = substr($link->href, 1);
} }
$link->href = $this->uri . $link->href; $link->href = self::URI . $link->href;
} }
} }
$content = $content->innertext; $content = $content->innertext;
@ -107,11 +108,6 @@ class GooglePlusPostBridge extends BridgeAbstract
public function getURI() public function getURI()
{ {
return $this->_url ?: $this->uri; return $this->_url ?: self::URI;
}
public function getCacheDuration()
{
return 1; // 600; // 10 minutes
} }
} }

View File

@ -9,12 +9,13 @@
*/ */
class GoogleSearchBridge extends BridgeAbstract{ class GoogleSearchBridge extends BridgeAbstract{
public $maintainer = "sebsauvage"; const MAINTAINER = "sebsauvage";
public $name = "Google search"; const NAME = "Google search";
public $uri = "https://www.google.com/"; const URI = "https://www.google.com/";
public $description = "Returns most recent results from Google search."; const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns most recent results from Google search.";
public $parameters = array( array( const PARAMETERS = array( array(
'q'=>array( 'q'=>array(
'name'=>"keyword", 'name'=>"keyword",
'required'=>true 'required'=>true
@ -25,10 +26,10 @@ class GoogleSearchBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$html = $this->getSimpleHTMLDOM($this->uri $html = getSimpleHTMLDOM(self::URI
.'search?q=' . urlencode($this->getInput('q')) .'search?q=' . urlencode($this->getInput('q'))
.'&num=100&complete=0&tbs=qdr:y,sbd:1') .'&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); $emIsRes = $html->find('div[id=ires]',0);
if( !is_null($emIsRes) ){ if( !is_null($emIsRes) ){
@ -50,8 +51,4 @@ class GoogleSearchBridge extends BridgeAbstract{
public function getName(){ public function getName(){
return $this->getInput('q') .' - Google search'; return $this->getInput('q') .' - Google search';
} }
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View File

@ -1,32 +0,0 @@
<?php
class GuruMedBridge extends BridgeAbstract{
public $maintainer = "qwertygc";
public $name = "GuruMed";
public $uri = "http://www.gurumed.org";
public $description = "Returns the 5 newest posts from Gurumed (full text)";
private function GurumedStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $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), '<p><a><br>'));
$this->items[] = $item;
$limit++;
}
}
}
}

View File

@ -1,11 +1,12 @@
<?php <?php
class HDWallpapersBridge extends BridgeAbstract { class HDWallpapersBridge extends BridgeAbstract {
public $maintainer = "nel50n"; const MAINTAINER = "nel50n";
public $name = "HD Wallpapers Bridge"; const NAME = "HD Wallpapers Bridge";
public $uri = "http://www.hdwallpapers.in/"; const URI = "http://www.hdwallpapers.in/";
public $description = "Returns the latests wallpapers from HDWallpapers"; const CACHE_TIMEOUT = 43200; //12h
const DESCRIPTION = "Returns the latests wallpapers from HDWallpapers";
public $parameters = array( array( const PARAMETERS = array( array(
'c'=>array( 'c'=>array(
'name'=>'category', 'name'=>'category',
'defaultValue'=>'latest_wallpapers' 'defaultValue'=>'latest_wallpapers'
@ -29,8 +30,8 @@ class HDWallpapersBridge extends BridgeAbstract {
$lastpage = 1; $lastpage = 1;
for ($page = 1; $page <= $lastpage; $page++) { for ($page = 1; $page <= $lastpage; $page++) {
$link = $this->uri.'/'.$category.'/page/'.$page; $link = self::URI.'/'.$category.'/page/'.$page;
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.'); $html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.');
if ($page === 1) { if ($page === 1) {
preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches); preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches);
@ -42,10 +43,10 @@ class HDWallpapersBridge extends BridgeAbstract {
$item = array(); $item = array();
// http://www.hdwallpapers.in/download/yosemite_reflections-1680x1050.jpg // 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['timestamp'] = time();
$item['title'] = $element->find('p', 0)->text(); $item['title'] = $element->find('p', 0)->text();
$item['content'] = $item['title'].'<br><a href="'.$item['uri'].'"><img src="'.$this->uri.$thumbnail->src.'" /></a>'; $item['content'] = $item['title'].'<br><a href="'.$item['uri'].'"><img src="'.self::URI.$thumbnail->src.'" /></a>';
$this->items[] = $item; $this->items[] = $item;
$num++; $num++;
@ -58,8 +59,4 @@ class HDWallpapersBridge extends BridgeAbstract {
public function getName(){ public function getName(){
return 'HDWallpapers - '.str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')).' ['.$this->getInput('r').']'; return 'HDWallpapers - '.str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')).' ['.$this->getInput('r').']';
} }
public function getCacheDuration(){
return 43200; // 12 hours
}
} }

View File

@ -1,14 +1,15 @@
<?php <?php
class HentaiHavenBridge extends BridgeAbstract{ class HentaiHavenBridge extends BridgeAbstract{
public $maintainer = "albirew"; const MAINTAINER = "albirew";
public $name = "Hentai Haven"; const NAME = "Hentai Haven";
public $uri = "http://hentaihaven.org/"; const URI = "http://hentaihaven.org/";
public $description = "Returns releases from Hentai Haven"; const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns releases from Hentai Haven";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request Hentai Haven.'); or returnServerError('Could not request Hentai Haven.');
foreach($html->find('div.zoe-grid') as $element) { foreach($html->find('div.zoe-grid') as $element) {
$item = array(); $item = array();
$item['uri'] = $element->find('div.brick-content h3 a', 0)->href; $item['uri'] = $element->find('div.brick-content h3 a', 0)->href;
@ -19,8 +20,4 @@ class HentaiHavenBridge extends BridgeAbstract{
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,12 +1,13 @@
<?php <?php
class IdenticaBridge extends BridgeAbstract{ class IdenticaBridge extends BridgeAbstract{
public $maintainer = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
public $name = "Identica Bridge"; const NAME = "Identica Bridge";
public $uri = "https://identi.ca/"; const URI = "https://identi.ca/";
public $description = "Returns user timelines"; const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = "Returns user timelines";
public $parameters = array( array( const PARAMETERS = array( array(
'u'=>array( 'u'=>array(
'name'=>'username', 'name'=>'username',
'required'=>true 'required'=>true
@ -14,8 +15,8 @@ class IdenticaBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
foreach($html->find('li.major') as $dent) { foreach($html->find('li.major') as $dent) {
$item = array(); $item = array();
@ -32,10 +33,6 @@ class IdenticaBridge extends BridgeAbstract{
} }
public function getURI(){ public function getURI(){
return $this->uri.urlencode($this->getInput('u')); return self::URI.urlencode($this->getInput('u'));
}
public function getCacheDuration(){
return 300; // 5 minutes
} }
} }

View File

@ -1,12 +1,12 @@
<?php <?php
class InstagramBridge extends BridgeAbstract{ class InstagramBridge extends BridgeAbstract{
public $maintainer = "pauder"; const MAINTAINER = "pauder";
public $name = "Instagram Bridge"; const NAME = "Instagram Bridge";
public $uri = "http://instagram.com/"; const URI = "http://instagram.com/";
public $description = "Returns the newest images"; const DESCRIPTION = "Returns the newest images";
public $parameters = array( array( const PARAMETERS = array( array(
'u'=>array( 'u'=>array(
'name'=>'username', 'name'=>'username',
'required'=>true 'required'=>true
@ -14,8 +14,8 @@ class InstagramBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Could not request Instagram.'); or returnServerError('Could not request Instagram.');
$innertext = null; $innertext = null;
@ -46,7 +46,7 @@ class InstagramBridge extends BridgeAbstract{
{ {
$item = array(); $item = array();
$item['uri'] = $this->uri.'/p/'.$media->code.'/'; $item['uri'] = self::URI.'p/'.$media->code.'/';
$item['content'] = '<img src="' . htmlentities($media->display_src) . '" />'; $item['content'] = '<img src="' . htmlentities($media->display_src) . '" />';
if (isset($media->caption)) if (isset($media->caption))
{ {
@ -65,7 +65,7 @@ class InstagramBridge extends BridgeAbstract{
} }
public function getURI(){ public function getURI(){
return $this->uri.urlencode($this->getInput('u')); return self::URI.urlencode($this->getInput('u'));
} }
} }

View File

@ -1,11 +1,12 @@
<?php <?php
class IsoHuntBridge extends BridgeAbstract{ class IsoHuntBridge extends BridgeAbstract{
public $maintainer = 'logmanoriginal'; const MAINTAINER = 'logmanoriginal';
public $name = 'isoHunt Bridge'; const NAME = 'isoHunt Bridge';
public $uri = 'https://isohunt.to/'; const URI = 'https://isohunt.to/';
public $description = 'Returns the latest results by category or search result'; const CACHE_TIMEOUT = 300; //5min
const DESCRIPTION = 'Returns the latest results by category or search result';
public $parameters = array( const PARAMETERS = array(
/* /*
* Get feeds for one of the "latest" categories * Get feeds for one of the "latest" categories
* Notice: The categories "News" and "Top Searches" are received from the main page * Notice: The categories "News" and "Top Searches" are received from the main page
@ -90,7 +91,7 @@ class IsoHuntBridge extends BridgeAbstract{
); );
public function getURI(){ public function getURI(){
$uri=$this->uri; $uri=self::URI;
switch($this->queriedContext){ switch($this->queriedContext){
case 'By "Latest" category': case 'By "Latest" category':
switch($this->getInput('latest_category')){ switch($this->getInput('latest_category')){
@ -132,27 +133,27 @@ class IsoHuntBridge extends BridgeAbstract{
$categoryName = $categoryName =
array_search( array_search(
$this->getInput('latest_category'), $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; break;
case 'By "Torrent" category': case 'By "Torrent" category':
$categoryName = $categoryName =
array_search( array_search(
$this->getInput('torrent_category'), $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; break;
case 'Search torrent by name': case 'Search torrent by name':
$categoryName = $categoryName =
array_search( array_search(
$this->getInput('search_category'), $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; break;
} }
@ -199,30 +200,26 @@ class IsoHuntBridge extends BridgeAbstract{
} }
} }
public function getCacheDuration(){
return 300; // 5 minutes
}
#region Helper functions for "Movie Torrents" #region Helper functions for "Movie Torrents"
private function get_movie_torrents($html){ private function get_movie_torrents($html){
$container = $html->find('div#w0', 0); $container = $html->find('div#w0', 0);
if(!$container) if(!$container)
$this->returnServerError('Unable to find torrent container!'); returnServerError('Unable to find torrent container!');
$torrents = $container->find('article'); $torrents = $container->find('article');
if(!$torrents) if(!$torrents)
$this->returnServerError('Unable to find torrents!'); returnServerError('Unable to find torrents!');
foreach($torrents as $torrent){ foreach($torrents as $torrent){
$anchor = $torrent->find('a', 0); $anchor = $torrent->find('a', 0);
if(!$anchor) if(!$anchor)
$this->returnServerError('Unable to find anchor!'); returnServerError('Unable to find anchor!');
$date = $torrent->find('small', 0); $date = $torrent->find('small', 0);
if(!$date) if(!$date)
$this->returnServerError('Unable to find date!'); returnServerError('Unable to find date!');
$item = array(); $item = array();
@ -243,11 +240,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function get_latest_hot_torrents($html){ private function get_latest_hot_torrents($html){
$container = $html->find('div#serps', 0); $container = $html->find('div#serps', 0);
if(!$container) if(!$container)
$this->returnServerError('Unable to find torrent container!'); returnServerError('Unable to find torrent container!');
$torrents = $container->find('tr'); $torrents = $container->find('tr');
if(!$torrents) if(!$torrents)
$this->returnServerError('Unable to find torrents!'); returnServerError('Unable to find torrents!');
// Remove first element (header row) // Remove first element (header row)
$torrents = array_slice($torrents, 1); $torrents = array_slice($torrents, 1);
@ -256,11 +253,11 @@ class IsoHuntBridge extends BridgeAbstract{
$cell = $torrent->find('td', 0); $cell = $torrent->find('td', 0);
if(!$cell) if(!$cell)
$this->returnServerError('Unable to find cell!'); returnServerError('Unable to find cell!');
$element = $cell->find('a', 0); $element = $cell->find('a', 0);
if(!$element) if(!$element)
$this->returnServerError('Unable to find element!'); returnServerError('Unable to find element!');
$item = array(); $item = array();
@ -281,11 +278,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function get_latest_news($html){ private function get_latest_news($html){
$container = $html->find('div#postcontainer', 0); $container = $html->find('div#postcontainer', 0);
if(!$container) if(!$container)
$this->returnServerError('Unable to find post container!'); returnServerError('Unable to find post container!');
$posts = $container->find('div.index-post'); $posts = $container->find('div.index-post');
if(!$posts) if(!$posts)
$this->returnServerError('Unable to find posts!'); returnServerError('Unable to find posts!');
foreach($posts as $post){ foreach($posts as $post){
$item = array(); $item = array();
@ -303,7 +300,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_author($post){ private function latest_news_extract_author($post){
$author = $post->find('small', 0); $author = $post->find('small', 0);
if(!$author) 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}' // The author is hidden within a string like: 'Posted by {author} on {date}'
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches); 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){ private function latest_news_extract_timestamp($post){
$date = $post->find('small', 0); $date = $post->find('small', 0);
if(!$date) 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}' // The date is hidden within a string like: 'Posted by {author} on {date}'
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches); 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){ private function latest_news_extract_title($post){
$title = $post->find('a', 0); $title = $post->find('a', 0);
if(!$title) if(!$title)
$this->returnServerError('Unable to find title!'); returnServerError('Unable to find title!');
return $title->plaintext; return $title->plaintext;
} }
@ -340,7 +337,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_uri($post){ private function latest_news_extract_uri($post){
$uri = $post->find('a', 0); $uri = $post->find('a', 0);
if(!$uri) if(!$uri)
$this->returnServerError('Unable to find uri!'); returnServerError('Unable to find uri!');
return $uri->href; return $uri->href;
} }
@ -348,7 +345,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_news_extract_content($post){ private function latest_news_extract_content($post){
$content = $post->find('div', 0); $content = $post->find('div', 0);
if(!$content) if(!$content)
$this->returnServerError('Unable to find content!'); returnServerError('Unable to find content!');
// Remove <h2>...</h2> (title) // Remove <h2>...</h2> (title)
foreach($content->find('h2') as $element){ foreach($content->find('h2') as $element){
@ -370,11 +367,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function get_latest_torrents($html){ private function get_latest_torrents($html){
$container = $html->find('div#serps', 0); $container = $html->find('div#serps', 0);
if(!$container) if(!$container)
$this->returnServerError('Unable to find torrent container!'); returnServerError('Unable to find torrent container!');
$torrents = $container->find('tr[data-key]'); $torrents = $container->find('tr[data-key]');
if(!$torrents) if(!$torrents)
$this->returnServerError('Unable to find torrents!'); returnServerError('Unable to find torrents!');
foreach($torrents as $torrent){ foreach($torrents as $torrent){
$item = array(); $item = array();
@ -392,11 +389,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_torrents_extract_title($torrent){ private function latest_torrents_extract_title($torrent){
$cell = $torrent->find('td.title-row', 0); $cell = $torrent->find('td.title-row', 0);
if(!$cell) if(!$cell)
$this->returnServerError('Unable to find title cell!'); returnServerError('Unable to find title cell!');
$title = $cell->find('span', 0); $title = $cell->find('span', 0);
if(!$title) if(!$title)
$this->returnServerError('Unable to find title!'); returnServerError('Unable to find title!');
return $title->plaintext; return $title->plaintext;
} }
@ -404,11 +401,11 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_torrents_extract_uri($torrent){ private function latest_torrents_extract_uri($torrent){
$cell = $torrent->find('td.title-row', 0); $cell = $torrent->find('td.title-row', 0);
if(!$cell) if(!$cell)
$this->returnServerError('Unable to find title cell!'); returnServerError('Unable to find title cell!');
$uri = $cell->find('a', 0); $uri = $cell->find('a', 0);
if(!$uri) if(!$uri)
$this->returnServerError('Unable to find uri!'); returnServerError('Unable to find uri!');
return $this->fix_relative_uri($uri->href); return $this->fix_relative_uri($uri->href);
} }
@ -420,7 +417,7 @@ class IsoHuntBridge extends BridgeAbstract{
$user = $cell->find('a', 0); $user = $cell->find('a', 0);
if(!$user) if(!$user)
$this->returnServerError('Unable to find user!'); returnServerError('Unable to find user!');
return $user->plaintext; return $user->plaintext;
} }
@ -428,7 +425,7 @@ class IsoHuntBridge extends BridgeAbstract{
private function latest_torrents_extract_timestamp($torrent){ private function latest_torrents_extract_timestamp($torrent){
$cell = $torrent->find('td.date-row', 0); $cell = $torrent->find('td.date-row', 0);
if(!$cell) if(!$cell)
$this->returnServerError('Unable to find date cell!'); returnServerError('Unable to find date cell!');
return strtotime('-' . $cell->plaintext, time()); return strtotime('-' . $cell->plaintext, time());
} }
@ -438,15 +435,15 @@ class IsoHuntBridge extends BridgeAbstract{
#region Generic helper functions #region Generic helper functions
private function load_html($uri){ private function load_html($uri){
$html = $this->getSimpleHTMLDOM($uri); $html = getSimpleHTMLDOM($uri);
if(!$html) if(!$html)
$this->returnServerError('Unable to load ' . $uri . '!'); returnServerError('Unable to load ' . $uri . '!');
return $html; return $html;
} }
private function fix_relative_uri($uri){ 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){ private function build_category_uri($category, $order_popularity = false){

View File

@ -1,11 +1,12 @@
<?php <?php
class JapanExpoBridge extends HttpCachingBridgeAbstract { class JapanExpoBridge extends BridgeAbstract {
public $maintainer = 'Ginko'; const MAINTAINER = 'Ginko';
public $name = 'Japan Expo Actualités'; const NAME = 'Japan Expo Actualités';
public $uri = 'http://www.japan-expo-paris.com/fr/actualites'; const URI = 'http://www.japan-expo-paris.com/fr/actualites';
public $description = 'Returns most recent entries from Japan Expo actualités.'; const CACHE_TIMEOUT = 14400; // 4h
public $parameters = array( array( const DESCRIPTION = 'Returns most recent entries from Japan Expo actualités.';
const PARAMETERS = array( array(
'mode'=>array( 'mode'=>array(
'name'=>'Show full contents', 'name'=>'Show full contents',
'type'=>'checkbox', 'type'=>'checkbox',
@ -42,8 +43,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
} }
}; };
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request JapanExpo: '.$this->uri); or returnServerError('Could not request JapanExpo: '.self::URI);
$fullcontent = $this->getInput('mode'); $fullcontent = $this->getInput('mode');
$count = 0; $count = 0;
@ -59,10 +60,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
if ($count >= 5) { if ($count >= 5) {
break; 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); $header = $article_html->find('header.pageHeadBox', 0);
$timestamp = strtotime($header->find('time', 0)->datetime); $timestamp = strtotime($header->find('time', 0)->datetime);
$title_html = $header->find('div.section', 0)->next_sibling(); $title_html = $header->find('div.section', 0)->next_sibling();
@ -87,8 +86,4 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
$count++; $count++;
} }
} }
public function getCacheDuration(){
return 14400; // 4 hours
}
} }

View File

@ -1,46 +1,11 @@
<?php <?php
class KonachanBridge extends BridgeAbstract{ require_once('MoebooruBridge.php');
public $maintainer = "mitsukarenai"; class KonachanBridge extends MoebooruBridge {
public $name = "Konachan";
public $uri = "http://konachan.com/";
public $description = "Returns images from given page";
public $parameters = array( array( const MAINTAINER = "mitsukarenai";
'p'=>array( const NAME = "Konachan";
'name'=>'page', const URI = "http://konachan.com/";
'defaultValue'=>1, const DESCRIPTION = "Returns images from given page";
'type'=>'number'
),
't'=>array('name'=>'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 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'] = '<a href="' . $item['imageUri'] . '"><img src="' . $json['preview_url'] . '" /></a><br>Tags: '.$json['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View File

@ -1,38 +1,22 @@
<?php <?php
class KoreusBridge extends BridgeAbstract{ class KoreusBridge extends FeedExpander {
public $maintainer = "pit-fgfjiudghdf"; const MAINTAINER = "pit-fgfjiudghdf";
public $name = "Koreus"; const NAME = "Koreus";
public $uri = "http://www.koreus.com/"; const URI = "http://www.koreus.com/";
public $description = "Returns the 5 newest posts from Koreus (full text)"; const DESCRIPTION = "Returns the newest posts from Koreus (full text)";
private function KoreusStripCDATA($string) { protected function parseItem($item) {
$string = str_replace('<![CDATA[', '', $string); $item = parent::parseItem($item);
$string = str_replace(']]>', '', $string);
return $string;
}
private function KoreusExtractContent($url) { $html = getSimpleHTMLDOMCached($item['uri']);
$html2 = $this->getSimpleHTMLDOM($url); $text = $html->find('p.itemText', 0)->innertext;
$text = $html2->find('p[class=itemText]', 0)->innertext; $item['content'] = utf8_encode($text);
$text = utf8_encode(preg_replace('/(Sur le m.+?)+$/i','',$text));
return $text; return $item;
} }
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM('http://feeds.feedburner.com/Koreus-articles') or $this->returnServerError('Could not request Koreus.'); $this->collectExpandableDatas('http://feeds.feedburner.com/Koreus-articles');
$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++;
}
}
} }
} }

View File

@ -1,11 +1,12 @@
<?php <?php
class KununuBridge extends HttpCachingBridgeAbstract { class KununuBridge extends BridgeAbstract {
public $maintainer = "logmanoriginal"; const MAINTAINER = "logmanoriginal";
public $name = "Kununu Bridge"; const NAME = "Kununu Bridge";
public $uri = "https://www.kununu.com/"; const URI = "https://www.kununu.com/";
public $description = "Returns the latest reviews for a company and site of your choice."; const CACHE_TIMEOUT = 86400; // 24h
const DESCRIPTION = "Returns the latest reviews for a company and site of your choice.";
public $parameters = array( const PARAMETERS = array(
'global' => array( 'global' => array(
'site'=>array( 'site'=>array(
'name'=>'Site', 'name'=>'Site',
@ -55,33 +56,33 @@ class KununuBridge extends HttpCachingBridgeAbstract {
break; break;
} }
return $this->uri.$site.'/'.$company.'/'.$section; return self::URI.$site.'/'.$company.'/'.$section;
} }
function getName(){ function getName(){
$company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($this->getInput('company'))))); $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(){ public function collectData(){
$full = $this->getInput('full'); $full = $this->getInput('full');
// Load page // Load page
$html = $this->getSimpleHTMLDOM($this->getURI()); $html = getSimpleHTMLDOM($this->getURI());
if(!$html) if(!$html)
$this->returnServerError('Unable to receive data from ' . $this->getURI() . '!'); returnServerError('Unable to receive data from ' . $this->getURI() . '!');
// Update name for this request // Update name for this request
$this->companyName = $this->extract_company_name($html); $this->companyName = $this->extract_company_name($html);
// Find the section with all the panels (reviews) // Find the section with all the panels (reviews)
$section = $html->find('section.kununu-scroll-element', 0); $section = $html->find('section.kununu-scroll-element', 0);
if($section === false) if($section === false)
$this->returnServerError('Unable to find panel section!'); returnServerError('Unable to find panel section!');
// Find all articles (within the panels) // Find all articles (within the panels)
$articles = $section->find('article'); $articles = $section->find('article');
if($articles === false || empty($articles)) if($articles === false || empty($articles))
$this->returnServerError('Unable to find articles!'); returnServerError('Unable to find articles!');
// Go through all articles // Go through all articles
foreach($articles as $article){ 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 * Fixes relative URLs in the given text
*/ */
private function fix_url($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){ private function extract_company_name($html){
$panel = $html->find('div.panel', 0); $panel = $html->find('div.panel', 0);
if($panel === false) if($panel === false)
$this->returnServerError('Cannot find panel for company name!'); returnServerError('Cannot find panel for company name!');
$company_name = $panel->find('h1', 0); $company_name = $panel->find('h1', 0);
if($company_name === false) if($company_name === false)
$this->returnServerError('Cannot find company name!'); returnServerError('Cannot find company name!');
return $company_name->plaintext; return $company_name->plaintext;
} }
@ -144,7 +141,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
// They conviniently provide a time attribute for us :) // They conviniently provide a time attribute for us :)
$date = $article->find('time[itemprop=dtreviewed]', 0); $date = $article->find('time[itemprop=dtreviewed]', 0);
if($date === false) if($date === false)
$this->returnServerError('Cannot find article date!'); returnServerError('Cannot find article date!');
return strtotime($date->datetime); return strtotime($date->datetime);
} }
@ -155,7 +152,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
private function extract_article_rating($article){ private function extract_article_rating($article){
$rating = $article->find('span.rating', 0); $rating = $article->find('span.rating', 0);
if($rating === false) if($rating === false)
$this->returnServerError('Cannot find article rating!'); returnServerError('Cannot find article rating!');
return $rating->getAttribute('aria-label'); return $rating->getAttribute('aria-label');
} }
@ -166,7 +163,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
private function extract_article_summary($article){ private function extract_article_summary($article){
$summary = $article->find('[itemprop=summary]', 0); $summary = $article->find('[itemprop=summary]', 0);
if($summary === false) if($summary === false)
$this->returnServerError('Cannot find article summary!'); returnServerError('Cannot find article summary!');
return strip_tags($summary->innertext); 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! // Notice: This first part is the same as in extract_article_summary!
$summary = $article->find('[itemprop=summary]', 0); $summary = $article->find('[itemprop=summary]', 0);
if($summary === false) if($summary === false)
$this->returnServerError('Cannot find article summary!'); returnServerError('Cannot find article summary!');
$anchor = $summary->find('a', 0); $anchor = $summary->find('a', 0);
if($anchor === false) 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 // We need to parse the aside manually
$aside = $article->find('aside', 0); $aside = $article->find('aside', 0);
if($aside === false) 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) // Go through all h2 elements to find index of required span (I know... it's stupid)
$author_position = 'Unknown'; $author_position = 'Unknown';
@ -214,7 +211,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
private function extract_article_description($article){ private function extract_article_description($article){
$description = $article->find('div[itemprop=description]', 0); $description = $article->find('div[itemprop=description]', 0);
if($description === false) if($description === false)
$this->returnServerError('Cannot find article description!'); returnServerError('Cannot find article description!');
return $this->fix_url($description->innertext); return $this->fix_url($description->innertext);
} }
@ -224,17 +221,14 @@ class KununuBridge extends HttpCachingBridgeAbstract {
*/ */
private function extract_full_description($uri){ private function extract_full_description($uri){
// Load full article // Load full article
if($this->get_cached_time($uri) <= strtotime('-24 hours')) $html = getSimpleHTMLDOMCached($uri);
$this->remove_from_cache($uri);
$html = $this->get_cached($uri);
if($html === false) if($html === false)
$this->returnServerError('Could not load full description!'); returnServerError('Could not load full description!');
// Find the article // Find the article
$article = $html->find('article', 0); $article = $html->find('article', 0);
if($article === false) 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 :) // Luckily they use the same layout for the review overview and full article pages :)
return $this->extract_article_description($article); return $this->extract_article_description($article);

View File

@ -1,12 +1,13 @@
<?php <?php
class LWNprevBridge extends BridgeAbstract{ class LWNprevBridge extends BridgeAbstract{
public $maintainer = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
public $name = 'LWN Free Weekly Edition'; const NAME = 'LWN Free Weekly Edition';
public $uri = 'https://lwn.net/'; const URI = 'https://lwn.net/';
public $description = 'LWN Free Weekly Edition available one week late'; const CACHE_TIMEOUT = 604800; // 1 week
const DESCRIPTION = 'LWN Free Weekly Edition available one week late';
function getURI(){ function getURI(){
return $this->uri.'free/bigpage'; return self::URI.'free/bigpage';
} }
private function jumpToNextTag(&$node){ private function jumpToNextTag(&$node){
@ -32,8 +33,8 @@ class LWNprevBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
// Because the LWN page is written in loose HTML and not XHTML, // Because the LWN page is written in loose HTML and not XHTML,
// Simple HTML Dom is not accurate enough for the job // Simple HTML Dom is not accurate enough for the job
$content=$this->getContents($this->getURI()) $content=getContents($this->getURI())
or $this->returnServerError('No results for LWNprev'); or returnServerError('No results for LWNprev');
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$html=new DOMDocument(); $html=new DOMDocument();
@ -48,7 +49,7 @@ class LWNprevBridge extends BridgeAbstract{
break; break;
} }
} }
$realURI=$this->uri.$a->getAttribute('href'); $realURI=self::URI.$a->getAttribute('href');
$URICounter=0; $URICounter=0;
$edition=$html->getElementsByTagName('h1')->item(0)->textContent; $edition=$html->getElementsByTagName('h1')->item(0)->textContent;
@ -82,7 +83,7 @@ class LWNprevBridge extends BridgeAbstract{
$h2FirstChild=$h2->firstChild; $h2FirstChild=$h2->firstChild;
$this->jumpToNextTag($h2FirstChild); $this->jumpToNextTag($h2FirstChild);
if($h2FirstChild->nodeName==='a'){ if($h2FirstChild->nodeName==='a'){
$item['uri']=$this->uri.$h2FirstChild->getAttribute('href'); $item['uri']=self::URI.$h2FirstChild->getAttribute('href');
}else{ }else{
$item['uri']=$realURI.'#'.$URICounter; $item['uri']=$realURI.'#'.$URICounter;
} }
@ -140,8 +141,4 @@ class LWNprevBridge extends BridgeAbstract{
$this->items[]=$item; $this->items[]=$item;
} }
} }
public function getCacheDuration(){
return 604800; // one week
}
} }

View File

@ -1,17 +1,18 @@
<?php <?php
class LeBonCoinBridge extends BridgeAbstract{ class LeBonCoinBridge extends BridgeAbstract{
public $maintainer = "16mhz"; const MAINTAINER = "16mhz";
public $name = "LeBonCoin"; const NAME = "LeBonCoin";
public $uri = "http://www.leboncoin.fr/"; const URI = "http://www.leboncoin.fr/";
public $description = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword ."; const DESCRIPTION = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword .";
public $parameters = array( array( const PARAMETERS = array( array(
'k'=>array('name'=>'Mot Clé'), 'k'=>array('name'=>'Mot Clé'),
'r'=>array( 'r'=>array(
'name'=>'Région', 'name'=>'Région',
'type'=>'list', 'type'=>'list',
'values'=>array( 'values'=>array(
'Toute la France'=>'ile_de_france/occasions',
'Alsace'=>'alsace', 'Alsace'=>'alsace',
'Aquitaine'=>'aquitaine', 'Aquitaine'=>'aquitaine',
'Auvergne'=>'auvergne', 'Auvergne'=>'auvergne',
@ -142,11 +143,11 @@ class LeBonCoinBridge extends BridgeAbstract{
$category='annonces'; $category='annonces';
} }
$html = $this->getSimpleHTMLDOM( $html = getSimpleHTMLDOM(
$this->uri.$category.'/offres/' . $this->getInput('r') . '/?' self::URI.$category.'/offres/' . $this->getInput('r') . '/?'
.'f=a&th=1&' .'f=a&th=1&'
.'q=' . urlencode($this->getInput('k')) .'q=' . urlencode($this->getInput('k'))
) or $this->returnServerError('Could not request LeBonCoin.'); ) or returnServerError('Could not request LeBonCoin.');
$list = $html->find('.tabsContent', 0); $list = $html->find('.tabsContent', 0);
if($list === NULL) { if($list === NULL) {

View File

@ -1,58 +0,0 @@
<?php
class LeJournalDuGeekBridge extends BridgeAbstract{
public $maintainer = "polopollo";
public $name = "journaldugeek.com (FR)";
public $uri = "http://www.journaldugeek.com/";
public $description = "Returns the 5 newest posts from LeJournalDuGeek (full text).";
private function LeJournalDuGeekStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $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 . '<p><a href="' . $element->href . '">Source : ' . $element->href . '</a></p>';
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: <a href="' . $element->src . '">' . $element->src . '</a><br>';
}
}
$text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $text);
$text = strip_tags($text, '<p><b><a><blockquote><img><em><br/><br><ul><li>');
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
}
}

View File

@ -1,12 +1,24 @@
<?php <?php
class LeMondeInformatiqueBridge extends BridgeAbstract { class LeMondeInformatiqueBridge extends FeedExpander {
public $maintainer = "ORelio"; const MAINTAINER = "ORelio";
public $name = "Le Monde Informatique"; const NAME = "Le Monde Informatique";
public $uri = "http://www.lemondeinformatique.fr/"; const URI = "http://www.lemondeinformatique.fr/";
public $description = "Returns the newest articles."; const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns the newest articles.";
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . 'rss/rss.xml', 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$article_html = getSimpleHTMLDOMCached($item['uri'])
or returnServerError('Could not request LeMondeInformatique: ' . $item['uri']);
$item['content'] = $this->CleanArticle($article_html->find('div#article', 0)->innertext);
$item['title'] = $article_html->find('h1.cleanprint-title', 0)->plaintext;
return $item;
}
function StripCDATA($string) { function StripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string); $string = str_replace('<![CDATA[', '', $string);
@ -23,41 +35,8 @@ class LeMondeInformatiqueBridge extends BridgeAbstract {
} }
function CleanArticle($article_html) { function CleanArticle($article_html) {
$article_html = StripWithDelimiters($article_html, '<script', '</script>'); $article_html = $this->StripWithDelimiters($article_html, '<script', '</script>');
$article_html = StripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>'); $article_html = $this->StripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>');
return $article_html; return $article_html;
} }
$html = $this->getSimpleHTMLDOM($this->uri.'rss/rss.xml')
or $this->returnServerError('Could not request LeMondeInformatique: '
.$this->uri.'rss/rss.xml');
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 5) {
//Retrieve article details
$article_uri = $element->innertext;
$article_uri = substr($article_uri, strpos($article_uri, '<link>') + 6);
$article_uri = substr($article_uri, 0, strpos($article_uri, '</link>'));
$article_html = $this->getSimpleHTMLDOM($article_uri) or $this->returnServerError('Could not request LeMondeInformatique: '.$article_uri);
$article_content = CleanArticle($article_html->find('div#article', 0)->innertext);
$article_title = $article_html->find('h1.cleanprint-title', 0)->plaintext;
//Build and add final item
$item = array();
$item['uri'] = $article_uri;
$item['title'] = $article_title;
$item['author'] = StripCDATA($element->find('dc:creator', 0)->innertext);
$item['timestamp'] = strtotime($element->find('dc:date', 0)->plaintext);
$item['content'] = $article_content;
$this->items[] = $item;
$limit++;
}
}
}
public function getCacheDuration() {
return 1800; // 30 minutes
}
} }

View File

@ -0,0 +1,70 @@
<?php
class LegifranceJOBridge extends BridgeAbstract{
const MAINTAINER = 'Pierre Mazière';
const NAME = 'Journal Officiel de la République Française';
const URI = 'https://www.legifrance.gouv.fr/affichJO.do';
const DESCRIPTION = 'Returns the laws and decrees officially registered daily in France';
const PARAMETERS=array();
private $author;
private $timestamp;
private $uri;
private function extractItem($section,$subsection=null,$origin=null){
$item=array();
$item['author']=$this->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'].='<p><a href="'.$href.'">'.$text.'</a></p>';
}
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);
}
}
}

View File

@ -1,36 +0,0 @@
<?php
class Les400CulsBridge extends RssExpander{
public $maintainer = "unknown";
public $name = "Les 400 Culs";
public $uri = "http://sexes.blogs.liberation.fr/";
public $description = "La planete sexe vue par Agnes Girard via rss-bridge";
public function collectData(){
$this->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
}
}

View File

@ -1,14 +1,15 @@
<?php <?php
class LesJoiesDuCodeBridge extends BridgeAbstract{ class LesJoiesDuCodeBridge extends BridgeAbstract{
public $maintainer = "superbaillot.net"; const MAINTAINER = "superbaillot.net";
public $name = "Les Joies Du Code"; const NAME = "Les Joies Du Code";
public $uri = "http://lesjoiesducode.fr/"; const URI = "http://lesjoiesducode.fr/";
public $description = "LesJoiesDuCode"; const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "LesJoiesDuCode";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request LesJoiesDuCode.'); or returnServerError('Could not request LesJoiesDuCode.');
foreach($html->find('div.blog-post') as $element) { foreach($html->find('div.blog-post') as $element) {
$item = array(); $item = array();
@ -43,8 +44,4 @@ class LesJoiesDuCodeBridge extends BridgeAbstract{
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 7200; // 2h hours
}
} }

View File

@ -1,43 +1,23 @@
<?php <?php
class LichessBridge extends FeedExpander {
class LichessBridge extends HttpCachingBridgeAbstract const MAINTAINER = 'AmauryCarrade';
{ const NAME = 'Lichess Blog';
public $maintainer = 'AmauryCarrade'; const URI = 'http://fr.lichess.org/blog';
public $name = 'Lichess Blog'; const DESCRIPTION = 'Returns the 5 newest posts from the Lichess blog (full text)';
public $uri = 'http://fr.lichess.org/blog';
public $description = 'Returns the 5 newest posts from the Lichess blog (full text)';
public function collectData() public function collectData(){
{ $this->collectExpandableDatas(self::URI . '.atom', 5);
$xml_feed = $this->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);
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->retrieve_lichess_post($item['uri']); $item['content'] = $this->retrieve_lichess_post($item['uri']);
return $item;
$this->items[] = $item;
$posts_loaded++;
}
}
} }
private function retrieve_lichess_post($blog_post_uri) private function retrieve_lichess_post($blog_post_uri){
{ $blog_post_html = getSimpleHTMLDOMCached($blog_post_uri);
if($this->get_cached_time($blog_post_uri) <= strtotime('-24 hours'))
$this->remove_from_cache($blog_post_uriuri);
$blog_post_html = $this->get_cached($blog_post_uri);
$blog_post_div = $blog_post_html->find('#lichess_blog', 0); $blog_post_div = $blog_post_html->find('#lichess_blog', 0);
$post_chapo = $blog_post_div->find('.shortlede', 0)->innertext; $post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;

View File

@ -1,12 +1,13 @@
<?php <?php
class LinkedInCompanyBridge extends BridgeAbstract{ class LinkedInCompanyBridge extends BridgeAbstract{
public $maintainer = "regisenguehard"; const MAINTAINER = "regisenguehard";
public $name = "LinkedIn Company"; const NAME = "LinkedIn Company";
public $uri = "https://www.linkedin.com/"; const URI = "https://www.linkedin.com/";
public $description = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/<strong style=\"font-weight:bold;\">apple</strong>)"; const CACHE_TIMEOUT = 21600; //6
const DESCRIPTION = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/<strong style=\"font-weight:bold;\">apple</strong>)";
public $parameters = array( array( const PARAMETERS = array( array(
'c'=>array( 'c'=>array(
'name'=>'Company name', 'name'=>'Company name',
'required'=>true 'required'=>true
@ -15,10 +16,10 @@ class LinkedInCompanyBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$link = $this->uri.'company/'.$this->getInput('c'); $link = self::URI.'company/'.$this->getInput('c');
$html = $this->getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or $this->returnServerError('Could not request LinkedIn.'); or returnServerError('Could not request LinkedIn.');
foreach($html->find('//*[@id="my-feed-post"]/li') as $element) { foreach($html->find('//*[@id="my-feed-post"]/li') as $element) {
$title = $element->find('span.share-body', 0)->innertext; $title = $element->find('span.share-body', 0)->innertext;
@ -32,8 +33,4 @@ class LinkedInCompanyBridge extends BridgeAbstract{
} }
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,46 +1,11 @@
<?php <?php
class LolibooruBridge extends BridgeAbstract{ require_once('MoebooruBridge.php');
public $maintainer = "mitsukarenai"; class LolibooruBridge extends MoebooruBridge{
public $name = "Lolibooru";
public $uri = "http://lolibooru.moe/";
public $description = "Returns images from given page and tags";
public $parameters = array( array( const MAINTAINER = "mitsukarenai";
'p'=>array( const NAME = "Lolibooru";
'name'=>'page', const URI = "https://lolibooru.moe/";
'defaultValue'=>1, const DESCRIPTION = "Returns images from given page and tags";
'type'=>'number'
),
't'=>array('name'=>'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'] = '<a href="' . $item['imageUri'] . '"><img src="' . $json['preview_url'] . '" /></a><br>Tags: '.$json['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View File

@ -1,87 +1,87 @@
<?php <?php
define('MANGAREADER_LIMIT', 10); // The default limit class MangareaderBridge extends BridgeAbstract {
class MangareaderBridge extends BridgeAbstract{
public $maintainer = "logmanoriginal"; const MAINTAINER = "logmanoriginal";
public $name = "Mangareader Bridge"; const NAME = "Mangareader Bridge";
public $uri = "http://www.mangareader.net/"; const URI = "http://www.mangareader.net/";
public $description = "Returns the latest updates, popular mangas or manga updates (new chapters)"; const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the latest updates, popular mangas or manga updates (new chapters)";
public $parameters = array( const PARAMETERS = array(
'Get latest updates' => array(), 'Get latest updates' => array(),
'Get popular mangas' => array( 'Get popular mangas' => array(
'category'=>array( 'category' => array(
'name'=>'Category', 'name' => 'Category',
'type'=>'list', 'type' => 'list',
'required'=>true, 'required' => true,
'values'=>array( 'values' => array(
'All'=>'all', 'All' => 'all',
'Action'=>'action', 'Action' => 'action',
'Adventure'=>'adventure', 'Adventure' => 'adventure',
'Comedy'=>'comedy', 'Comedy' => 'comedy',
'Demons'=>'demons', 'Demons' => 'demons',
'Drama'=>'drama', 'Drama' => 'drama',
'Ecchi'=>'ecchi', 'Ecchi' => 'ecchi',
'Fantasy'=>'fantasy', 'Fantasy' => 'fantasy',
'Gender Bender'=>'gender-bender', 'Gender Bender' => 'gender-bender',
'Harem'=>'harem', 'Harem' => 'harem',
'Historical'=>'historical', 'Historical' => 'historical',
'Horror'=>'horror', 'Horror' => 'horror',
'Josei'=>'josei', 'Josei' => 'josei',
'Magic'=>'magic', 'Magic' => 'magic',
'Martial Arts'=>'martial-arts', 'Martial Arts' => 'martial-arts',
'Mature'=>'mature', 'Mature' => 'mature',
'Mecha'=>'mecha', 'Mecha' => 'mecha',
'Military'=>'military', 'Military' => 'military',
'Mystery'=>'mystery', 'Mystery' => 'mystery',
'One Shot'=>'one-shot', 'One Shot' => 'one-shot',
'Psychological'=>'psychological', 'Psychological' => 'psychological',
'Romance'=>'romance', 'Romance' => 'romance',
'School Life'=>'school-life', 'School Life' => 'school-life',
'Sci-Fi'=>'sci-fi', 'Sci-Fi' => 'sci-fi',
'Seinen'=>'seinen', 'Seinen' => 'seinen',
'Shoujo'=>'shoujo', 'Shoujo' => 'shoujo',
'Shoujoai'=>'shoujoai', 'Shoujoai' => 'shoujoai',
'Shounen'=>'shounen', 'Shounen' => 'shounen',
'Shounenai'=>'shounenai', 'Shounenai' => 'shounenai',
'Slice of Life'=>'slice-of-life', 'Slice of Life' => 'slice-of-life',
'Smut'=>'smut', 'Smut' => 'smut',
'Sports'=>'sports', 'Sports' => 'sports',
'Super Power'=>'super-power', 'Super Power' => 'super-power',
'Supernatural'=>'supernatural', 'Supernatural' => 'supernatural',
'Tragedy'=>'tragedy', 'Tragedy' => 'tragedy',
'Vampire'=>'vampire', 'Vampire' => 'vampire',
'Yaoi'=>'yaoi', 'Yaoi' => 'yaoi',
'Yuri'=>'yuri' 'Yuri' => 'yuri'
), ),
'exampleValue'=>'All', 'exampleValue' => 'All',
'title'=>'Select your category' 'title' => 'Select your category'
) )
), ),
'Get manga updates' => array( 'Get manga updates' => array(
'path'=>array( 'path' => array(
'name'=>'Path', 'name' => 'Path',
'required'=>true, 'required' => true,
'pattern'=>'[a-zA-Z0-9-_]*', 'pattern' => '[a-zA-Z0-9-_]*',
'exampleValue'=>'bleach, umi-no-kishidan', 'exampleValue' => 'bleach, umi-no-kishidan',
'title'=>'URL part of desired manga' 'title' => 'URL part of desired manga'
), ),
'limit'=>array( 'limit' => array(
'name'=>'Limit', 'name' => 'Limit',
'type'=>'number', 'type' => 'number',
'exampleValue'=>10, 'defaultValue' => 10,
'title'=>'Number of items to return [-1 returns all]' 'title' => 'Number of items to return [-1 returns all]'
) )
) )
); );
private $request=''; private $request = '';
public function collectData(){ public function collectData(){
// We'll use the DOM parser for this as it makes navigation easier // We'll use the DOM parser for this as it makes navigation easier
$html = $this->getContents($this->getURI()); $html = getContents($this->getURI());
if(!$html){ if(!$html){
$this->returnClientError('Could not receive data for ' . $path . '!'); returnClientError('Could not receive data for ' . $path . '!');
} }
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$doc = new DomDocument; $doc = new DomDocument;
@ -95,7 +95,38 @@ class MangareaderBridge extends BridgeAbstract{
switch($this->queriedContext){ switch($this->queriedContext){
case 'Get latest updates': case 'Get latest updates':
$this->request = 'Latest updates'; $this->request = 'Latest updates';
$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, " -"));
$this->get_popular_mangas($xpath);
break;
case 'Get manga updates':
$limit = $this->getInput('limit');
if(empty($limit)){
$limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue'];
}
$this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")
->item(0)
->nodeValue;
$this->get_manga_updates($xpath, $limit);
break;
}
// Return some dummy-data if no content available
if(empty($this->items)){
$item = array();
$item['content'] = "<p>No updates available</p>";
$this->items[] = $item;
}
}
private function get_latest_updates($xpath){
// Query each item (consists of Manga + chapters) // Query each item (consists of Manga + chapters)
$nodes = $xpath->query("//*[@id='latestchapters']/table//td"); $nodes = $xpath->query("//*[@id='latestchapters']/table//td");
@ -108,7 +139,7 @@ class MangareaderBridge extends BridgeAbstract{
if (isset($manga) && $chapters->length >= 1){ if (isset($manga) && $chapters->length >= 1){
$item = array(); $item = array();
$item['uri'] = $this->uri. htmlspecialchars($manga->getAttribute('href')); $item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href'));
$item['title'] = htmlspecialchars($manga->nodeValue); $item['title'] = htmlspecialchars($manga->nodeValue);
// Add each chapter to the feed // Add each chapter to the feed
@ -118,18 +149,21 @@ class MangareaderBridge extends BridgeAbstract{
if($item['content'] <> ""){ if($item['content'] <> ""){
$item['content'] .= "<br>"; $item['content'] .= "<br>";
} }
$item['content'] .= "<a href='" .$this->uri. htmlspecialchars($chapter->getAttribute('href')) . "'>" . htmlspecialchars($chapter->nodeValue) . "</a>"; $item['content'] .=
"<a href='"
. self::URI
. htmlspecialchars($chapter->getAttribute('href'))
. "'>"
. htmlspecialchars($chapter->nodeValue)
. "</a>";
} }
$this->items[] = $item; $this->items[] = $item;
} }
} }
break; }
case 'Get popular mangas':
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
$this->request = substr($pagetitle, 0, strrpos($pagetitle, " -")); // "Popular mangas for ..."
private function get_popular_mangas($xpath){
// Query all mangas // Query all mangas
$mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']"); $mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
@ -137,53 +171,58 @@ class MangareaderBridge extends BridgeAbstract{
// The thumbnail is encrypted in a css-style... // The thumbnail is encrypted in a css-style...
// format: "background-image:url('<the part which is actually interesting>')" // format: "background-image:url('<the part which is actually interesting>')"
$mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga)->item(0)->getAttribute('style'); $mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga)
->item(0)
->getAttribute('style');
$thumbnail = substr($mangaimgelement, 22, strlen($mangaimgelement) - 24); $thumbnail = substr($mangaimgelement, 22, strlen($mangaimgelement) - 24);
$item = array(); $item = array();
$item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->nodeValue); $item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)
$item['uri'] = $this->uri . $xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->getAttribute('href'); ->item(0)
$item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga)->item(0)->nodeValue); ->nodeValue);
$item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga)->item(0)->nodeValue; $item['uri'] = self::URI . $xpath->query(".//*[@class='manga_name']//a", $manga)
$item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga)->item(0)->nodeValue); ->item(0)
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnail . '" alt="' . $item['title'] . '" /></a><p>' . $item['genre'] . '</p><p>' . $item['chaptercount'] . '</p>'; ->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'] = <<<EOD
<a href="{$item['uri']}"><img src="{$thumbnail}" alt="{$item['title']}" /></a>
<p>{$item['genre']}</p>
<p>{$item['chaptercount']}</p>
EOD;
$this->items[] = $item; $this->items[] = $item;
} }
break;
case 'Get manga updates':
$limit = $this->getInput('limit');
if(empty($limit)){
$limit = MANGAREADER_LIMIT;
} }
$this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")->item(0)->nodeValue; private function get_manga_updates($xpath, $limit){
$query = "(.//*[@id='listing']//tr)[position() > 1]"; $query = "(.//*[@id='listing']//tr)[position() > 1]";
if($limit !== -1){ if($limit !== -1){
$query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - " . $limit . "]"; $query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]";
} }
$chapters = $xpath->query($query); $chapters = $xpath->query($query);
foreach ($chapters as $chapter){ foreach ($chapters as $chapter){
$item = array(); $item = array();
$item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)->item(0)->nodeValue); $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)
$item['uri'] = $this->uri . $xpath->query("td[1]/a", $chapter)->item(0)->getAttribute('href'); ->item(0)
$item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)->item(0)->nodeValue); ->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); array_unshift($this->items, $item);
} }
break;
}
// Return some dummy-data if no content available
if(empty($this->items)){
$item = array();
$item['content'] = "<p>No updates available</p>";
$this->items[] = $item;
}
} }
public function getURI(){ public function getURI(){
@ -201,16 +240,12 @@ class MangareaderBridge extends BridgeAbstract{
$path = $this->getInput('path'); $path = $this->getInput('path');
break; break;
} }
return $this->uri . $path; return self::URI . $path;
} }
public function getName(){ public function getName(){
return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge'; return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge';
} }
public function getCacheDuration(){
return 10800; // 3 hours
}
} }
?> ?>

View File

@ -1,39 +1,11 @@
<?php <?php
class MilbooruBridge extends BridgeAbstract{ require_once('Shimmie2Bridge.php');
class MilbooruBridge extends Shimmie2Bridge{
public $maintainer = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
public $name = "Milbooru"; const NAME = "Milbooru";
public $uri = "http://sheslostcontrol.net/moe/shimmie/"; const URI = "http://sheslostcontrol.net/moe/shimmie/";
public $description = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
public $parameters = array( array(
'p'=>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'] = '<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,46 @@
<?php
class MoebooruBridge extends BridgeAbstract{
const NAME = "Moebooru";
const URI = "https://moe.dev.myconan.net/";
const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns images from given page";
const PARAMETERS = array( array(
'p'=>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'] = '<a href="' . $item['imageUri'] . '"><img src="' . $json['preview_url'] . '" /></a><br>Tags: '.$json['tags'];
$this->items[] = $item;
}
}
}

View File

@ -1,26 +1,23 @@
<?php <?php
class MondeDiploBridge extends BridgeAbstract{ class MondeDiploBridge extends BridgeAbstract{
public $maintainer = "Pitchoule"; const MAINTAINER = "Pitchoule";
public $name = 'Monde Diplomatique'; const NAME = 'Monde Diplomatique';
public $uri = 'http://www.monde-diplomatique.fr/'; const URI = 'http://www.monde-diplomatique.fr/';
public $description = "Returns most recent results from MondeDiplo."; const CACHE_TIMEOUT = 21600; //6h
const DESCRIPTION = "Returns most recent results from MondeDiplo.";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Could not request MondeDiplo. for : ' . $this->uri); or returnServerError('Could not request MondeDiplo. for : ' . self::URI);
foreach($html->find('div.unarticle') as $article) { foreach($html->find('div.unarticle') as $article) {
$element = $article->parent(); $element = $article->parent();
$item = array(); $item = array();
$item['uri'] = $this->uri . $element->href; $item['uri'] = self::URI . $element->href;
$item['title'] = $element->find('h3', 0)->plaintext; $item['title'] = $element->find('h3', 0)->plaintext;
$item['content'] = $element->find('div.dates_auteurs', 0)->plaintext . '<br>' . strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true); $item['content'] = $element->find('div.dates_auteurs', 0)->plaintext . '<br>' . strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true);
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,29 +1,29 @@
<?php <?php
class MsnMondeBridge extends BridgeAbstract{ class MsnMondeBridge extends BridgeAbstract{
public $maintainer = "kranack"; const MAINTAINER = "kranack";
public $name = 'MSN Actu Monde'; const NAME = 'MSN Actu Monde';
public $uri = 'http://www.msn.com/'; const URI = 'http://www.msn.com/';
public $description = "Returns the 10 newest posts from MSN Actualités (full text)"; const DESCRIPTION = "Returns the 10 newest posts from MSN Actualités (full text)";
public function getURI(){ public function getURI(){
return $this->uri.'fr-fr/actualite/monde'; return self::URI.'fr-fr/actualite/monde';
} }
private function MsnMondeExtractContent($url, &$item) { 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['content'] = $html2->find('#content', 0)->find('article', 0)->find('section', 0)->plaintext;
$item['timestamp'] = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime); $item['timestamp'] = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime);
} }
public function collectData(){ 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; $limit = 0;
foreach($html->find('.smalla') as $article) { foreach($html->find('.smalla') as $article) {
if($limit < 10) { if($limit < 10) {
$item = array(); $item = array();
$item['title'] = utf8_decode($article->find('h4', 0)->innertext); $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->MsnMondeExtractContent($item['uri'], $item);
$this->items[] = $item; $this->items[] = $item;
$limit++; $limit++;

View File

@ -1,42 +1,12 @@
<?php <?php
class MspabooruBridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
class MspabooruBridge extends GelbooruBridge{
public $maintainer = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
public $name = "Mspabooru"; const NAME = "Mspabooru";
public $uri = "http://mspabooru.com/"; const URI = "http://mspabooru.com/";
public $description = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
public $parameters = array( array( const PIDBYPAGE=50;
'p'=>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'] = '<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,68 +0,0 @@
<?php
class NakedSecurityBridge extends BridgeAbstract {
public $maintainer = 'ORelio';
public $name = 'Naked Security';
public $uri = 'https://nakedsecurity.sophos.com/';
public $description = 'Returns the newest articles.';
public function collectData(){
function StripRecursiveHTMLSection($string, $tag_name, $tag_start) {
$open_tag = '<'.$tag_name;
$close_tag = '</'.$tag_name.'>';
$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', '<div class="entry-prefix"');
$article_content = StripRecursiveHTMLSection($article_content , 'script', '<script');
$article_content = StripRecursiveHTMLSection($article_content , 'aside', '<aside');
$article_content = '<p><img src="'.$article_image.'" /></p><p><b>'.$article_summary.'</b></p>'.$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++;
}
}
}
}

View File

@ -1,14 +1,15 @@
<?php <?php
class NasaApodBridge extends BridgeAbstract{ class NasaApodBridge extends BridgeAbstract{
public $maintainer = "corenting"; const MAINTAINER = "corenting";
public $name = "NASA APOD Bridge"; const NAME = "NASA APOD Bridge";
public $uri = "http://apod.nasa.gov/apod/"; const URI = "http://apod.nasa.gov/apod/";
public $description = "Returns the 3 latest NASA APOD pictures and explanations"; const CACHE_TIMEOUT = 43200; // 12h
const DESCRIPTION = "Returns the 3 latest NASA APOD pictures and explanations";
public function collectData(){ public function collectData(){
$html = $this->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("<br>", $html->find('b', 0)->innertext); $list = explode("<br>", $html->find('b', 0)->innertext);
for($i = 0; $i < 3;$i++) for($i = 0; $i < 3;$i++)
@ -17,10 +18,10 @@ class NasaApodBridge extends BridgeAbstract{
$item = array(); $item = array();
$uri_page = $html->find('a',$i + 3)->href; $uri_page = $html->find('a',$i + 3)->href;
$uri = $this->uri.$uri_page; $uri = self::URI.$uri_page;
$item['uri'] = $uri; $item['uri'] = $uri;
$picture_html = $this->getSimpleHTMLDOM($uri); $picture_html = getSimpleHTMLDOM($uri);
$picture_html_string = $picture_html->innertext; $picture_html_string = $picture_html->innertext;
//Extract image and explanation //Extract image and explanation
@ -39,8 +40,4 @@ class NasaApodBridge extends BridgeAbstract{
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 3600*12; // 12 hours
}
} }

View File

@ -1,14 +1,12 @@
<?php <?php
class NeuviemeArtBridge extends BridgeAbstract { class NeuviemeArtBridge extends FeedExpander {
public $maintainer = "ORelio"; const MAINTAINER = "ORelio";
public $name = '9ème Art Bridge'; const NAME = '9ème Art Bridge';
public $uri = "http://www.9emeart.fr/"; const URI = "http://www.9emeart.fr/";
public $description = "Returns the newest articles."; const DESCRIPTION = "Returns the newest articles.";
public function collectData(){ private function StripWithDelimiters($string, $start, $end) {
function StripWithDelimiters($string, $start, $end) {
while (strpos($string, $start) !== false) { while (strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
@ -16,39 +14,42 @@ class NeuviemeArtBridge extends BridgeAbstract {
} return $string; } return $string;
} }
$feedUrl = $this->uri.'9emeart.rss'; protected function parseItem($item){
$html = $this->getSimpleHTMLDOM($feedUrl) or $this->returnServerError('Could not request 9eme Art: '.$feedUrl); $item = parent::parseItem($item);
$limit = 0;
foreach ($html->find('item') as $element) { $article_html = getSimpleHTMLDOMCached($item['uri']);
if ($limit < 5) { if(!$article_html){
$item['content'] = 'Could not request 9eme Art: '.$item['uri'];
return $item;
}
//Retrieve article Uri and get that page $article_image = '';
$article_uri = $element->find('guid', 0)->plaintext; foreach ($article_html->find('img.img_full') as $img){
$article_html = $this->getSimpleHTMLDOM($article_uri) or $this->returnServerError('Could not request 9eme Art: '.$article_uri); if ($img->alt == $item['title']){
$article_image = self::URI.$img->src;
break;
}
}
//Build article contents from corresponding elements $article_content='';
$article_title = trim($element->find('title', 0)->plaintext); if($article_image){
$article_image = $element->find('enclosure', 0)->url; $article_content = '<p><img src="'.$article_image.'" /></p>';
foreach ($article_html->find('img.img_full') as $img) }
if ($img->alt == $article_title) $article_content .= str_replace(
$article_image = $this->uri.$img->src; 'src="/', 'src="'.self::URI,
$article_content = '<p><img src="'.$article_image.'" /></p>' $article_html->find('div.newsGenerique_con', 0)->innertext
.str_replace('src="/', 'src="'.$this->uri, $article_html->find('div.newsGenerique_con', 0)->innertext); );
$article_content = StripWithDelimiters($article_content, '<script', '</script>'); $article_content = $this->StripWithDelimiters($article_content, '<script', '</script>');
$article_content = StripWithDelimiters($article_content, '<style', '</style>'); $article_content = $this->StripWithDelimiters($article_content, '<style', '</style>');
$article_content = StripWithDelimiters($article_content, '<link', '>'); $article_content = $this->StripWithDelimiters($article_content, '<link', '>');
//Build and add final item
$item = array();
$item['uri'] = $article_uri;
$item['title'] = $article_title;
$item['author'] = $article_html->find('a[class=upp transition_fast upp]', 0)->plaintext;
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$item['content'] = $article_content; $item['content'] = $article_content;
$this->items[] = $item;
$limit++; return $item;
}
} }
public function collectData(){
$feedUrl = self::URI.'9emeart.rss';
$this->collectExpandableDatas($feedUrl);
} }
} }

View File

@ -1,19 +1,23 @@
<?php <?php
class NextInpactBridge extends BridgeAbstract { class NextInpactBridge extends FeedExpander {
public $maintainer = "qwertygc"; const MAINTAINER = "qwertygc";
public $name = "NextInpact Bridge"; const NAME = "NextInpact Bridge";
public $uri = "http://www.nextinpact.com/"; const URI = "http://www.nextinpact.com/";
public $description = "Returns the newest articles."; const DESCRIPTION = "Returns the newest articles.";
private function StripCDATA($string) { public function collectData(){
$string = str_replace('<![CDATA[', '', $string); $this->collectExpandableDatas(self::URI . 'rss/news.xml', 10);
$string = str_replace(']]>', '', $string); }
return $string;
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->ExtractContent($item['uri']);
return $item;
} }
private function ExtractContent($url) { private function ExtractContent($url) {
$html2 = $this->getSimpleHTMLDOM($url); $html2 = getSimpleHTMLDOMCached($url);
$text = '<p><em>'.$html2->find('span.sub_title', 0)->innertext.'</em></p>' $text = '<p><em>'.$html2->find('span.sub_title', 0)->innertext.'</em></p>'
.'<p><img src="'.$html2->find('div.container_main_image_article', 0)->find('img.dedicated',0)->src.'" alt="-" /></p>' .'<p><img src="'.$html2->find('div.container_main_image_article', 0)->find('img.dedicated',0)->src.'" alt="-" /></p>'
.'<div>'.$html2->find('div[itemprop=articleBody]', 0)->innertext.'</div>'; .'<div>'.$html2->find('div[itemprop=articleBody]', 0)->innertext.'</div>';
@ -22,22 +26,4 @@ class NextInpactBridge extends BridgeAbstract {
$text = $text.'<p><em>'.$premium_article->innertext.'</em></p>'; $text = $text.'<p><em>'.$premium_article->innertext.'</em></p>';
return $text; return $text;
} }
public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri.'rss/news.xml') or $this->returnServerError('Could not request NextInpact.');
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 3) {
$item = array();
$item['title'] = $this->StripCDATA($element->find('title', 0)->innertext);
$item['uri'] = $this->StripCDATA($element->find('guid', 0)->plaintext);
$item['author'] = $this->StripCDATA($element->find('creator', 0)->innertext);
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$item['content'] = $this->ExtractContent($item['uri']);
$this->items[] = $item;
$limit++;
}
}
}
} }

View File

@ -1,12 +1,12 @@
<?php <?php
class NextgovBridge extends BridgeAbstract { class NextgovBridge extends FeedExpander {
public $maintainer = 'ORelio'; const MAINTAINER = 'ORelio';
public $name = 'Nextgov Bridge'; const NAME = 'Nextgov Bridge';
public $uri = 'https://www.nextgov.com/'; const URI = 'https://www.nextgov.com/';
public $description = 'USA Federal technology news, best practices, and web 2.0 tools.'; const DESCRIPTION = 'USA Federal technology news, best practices, and web 2.0 tools.';
public $parameters = array( array( const PARAMETERS = array( array(
'category'=>array( 'category'=>array(
'name'=>'Category', 'name'=>'Category',
'type'=>'list', 'type'=>'list',
@ -26,16 +26,28 @@ class NextgovBridge extends BridgeAbstract {
)); ));
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . 'rss/' . $this->getInput('category') . '/', 10);
function ExtractFromDelimiters($string, $start, $end) {
if (strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved;
} return false;
} }
function StripWithDelimiters($string, $start, $end) { protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = '';
$namespaces = $newsItem->getNamespaces(true);
if(isset($namespaces['media'])){
$media = $newsItem->children($namespaces['media']);
if(isset($media->content)){
$attributes = $media->content->attributes();
$item['content'] = '<img src="' . $attributes['url'] . '">';
}
}
$item['content'] .= $this->ExtractContent($item['uri']);
return $item;
}
private function StripWithDelimiters($string, $start, $end) {
while (strpos($string, $start) !== false) { while (strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
@ -43,40 +55,16 @@ class NextgovBridge extends BridgeAbstract {
} return $string; } return $string;
} }
$category = $this->getInput('category'); private function ExtractContent($url){
$url = $this->getURI().'rss/'.$category.'/'; $article = getSimpleHTMLDOMCached($url)
$html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Nextgov: '.$url); or returnServerError('Could not request Nextgov: ' . $url);
$limit = 0;
foreach ($html->find('item') as $element) {
if ($limit >= 10) {
break;
}
$article_url = ExtractFromDelimiters($element->innertext, '<link>', '</link>');
$article_author = ExtractFromDelimiters($element->innertext, 'dc/elements/1.1/">', '</dc:creator>');
$article_title = $element->find('title', 0)->plaintext;
$article_subtitle = $element->find('description', 0)->plaintext;
$article_timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$article_thumbnail = ExtractFromDelimiters($element->innertext, '<media:content url="', '"');
$article = $this->getSimpleHTMLDOM($article_url) or $this->returnServerError('Could not request Nextgov: '.$article_url);
$contents = $article->find('div.wysiwyg', 0)->innertext; $contents = $article->find('div.wysiwyg', 0)->innertext;
$contents = StripWithDelimiters($contents, '<div class="ad-container">', '</div>'); $contents = $this->StripWithDelimiters($contents, '<div class="ad-container">', '</div>');
$contents = StripWithDelimiters($contents, '<div', '</div>'); //ad outer div $contents = $this->StripWithDelimiters($contents, '<div', '</div>'); //ad outer div
$contents = StripWithDelimiters($contents, '<script', '</script>'); return $this->StripWithDelimiters($contents, '<script', '</script>');
$contents = ($article_thumbnail == '' ? '' : '<p><img src="'.$article_thumbnail.'" /></p>') $contents = ($article_thumbnail == '' ? '' : '<p><img src="'.$article_thumbnail.'" /></p>')
.'<p><b>'.$article_subtitle.'</b></p>' .'<p><b>'.$article_subtitle.'</b></p>'
.trim($contents); .trim($contents);
$item = array();
$item['uri'] = $article_url;
$item['title'] = $article_title;
$item['author'] = $article_author;
$item['timestamp'] = $article_timestamp;
$item['content'] = $contents;
$this->items[] = $item;
$limit++;
}
} }
} }

View File

@ -1,13 +1,23 @@
<?php <?php
class NiceMatinBridge extends BridgeAbstract{ class NiceMatinBridge extends FeedExpander {
public $maintainer = "pit-fgfjiudghdf"; const MAINTAINER = "pit-fgfjiudghdf";
public $name = "NiceMatin"; const NAME = "NiceMatin";
public $uri = "http://www.nicematin.com/"; const URI = "http://www.nicematin.com/";
public $description = "Returns the 10 newest posts from NiceMatin (full text)"; const DESCRIPTION = "Returns the 10 newest posts from NiceMatin (full text)";
public function collectData(){
$this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->NiceMatinExtractContent($item['uri']);
return $item;
}
private function NiceMatinExtractContent($url) { private function NiceMatinExtractContent($url) {
$html = $this->getSimpleHTMLDOM($url); $html = getSimpleHTMLDOMCached($url);
if(!$html) if(!$html)
return 'Could not acquire content from url: ' . $url . '!'; return 'Could not acquire content from url: ' . $url . '!';
@ -19,29 +29,4 @@ class NiceMatinBridge extends BridgeAbstract{
$text = strip_tags($text, '<p><a><img>'); $text = strip_tags($text, '<p><a><img>');
return $text; return $text;
} }
public function collectData(){
$html = $this->getSimpleHTMLDOM($this->uri.'derniere-minute/rss')
or $this->returnServerError('Could not request NiceMatin.');
$limit = 0;
foreach($html->find('item') as $element) {
if($limit >= 10) {
break;
}
// We need to fix the 'link' tag as simplehtmldom cannot parse it (just rename it and load back as dom)
$element_text = $element->outertext;
$element_text = str_replace('<link>', '<url>', $element_text);
$element_text = str_replace('</link>', '</url>', $element_text);
$element = str_get_html($element_text);
$item = array();
$item['title'] = $element->find('title', 0)->innertext;
$item['uri'] = $element->find('url', 0)->innertext;
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$item['content'] = $this->NiceMatinExtractContent($item['uri']);
$this->items[] = $item;
$limit++;
}
}
} }

View File

@ -1,29 +1,29 @@
<?php <?php
class NovelUpdatesBridge extends BridgeAbstract{ class NovelUpdatesBridge extends BridgeAbstract{
public $maintainer = "albirew"; const MAINTAINER = "albirew";
public $name = "Novel Updates"; const NAME = "Novel Updates";
public $uri = "http://www.novelupdates.com/"; const URI = "http://www.novelupdates.com/";
public $description = "Returns releases from Novel Updates"; const CACHE_TIMEOUT = 21600; // 6h
public $parameters = array( array( const DESCRIPTION = "Returns releases from Novel Updates";
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 = getSimpleHTMLDOM($this->getURI())
or $this->returnClientError('This URL seems malformed, please check it.'); or 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 = $this->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,16 +37,16 @@ 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(){
return 21600; // 6 hours
} }
} }

View File

@ -1,48 +0,0 @@
<?php
class NumeramaBridge extends HttpCachingBridgeAbstract {
public $maintainer = 'mitsukarenai';
public $name = 'Numerama';
public $uri = 'http://www.numerama.com/';
public $description = 'Returns the 5 newest posts from Numerama (full text)';
public function collectData(){
function NumeramaStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
return $string;
}
$feed = $this->uri.'feed/';
$html = $this->getSimpleHTMLDOM($feed) or $this->returnServerError('Could not request Numerama: '.$feed);
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 5) {
$item = array();
$item['title'] = html_entity_decode(NumeramaStripCDATA($element->find('title', 0)->innertext));
$item['author'] = NumeramaStripCDATA($element->find('dc:creator', 0)->innertext);
$item['uri'] = NumeramaStripCDATA($element->find('guid', 0)->plaintext);
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$article_url = NumeramaStripCDATA($element->find('guid', 0)->plaintext);
if($this->get_cached_time($article_url) <= strtotime('-24 hours'))
$this->remove_from_cache($article_url);
$article_html = $this->get_cached($article_url) or $this->returnServerError('Could not request Numerama: '.$article_url);
$contents = $article_html->find('section[class=related-article]', 0)->innertext = ''; // remove related articles block
$contents = '<img alt="" style="max-width:300px;" src="'.$article_html->find('meta[property=og:image]', 0)->getAttribute('content').'">'; // add post picture
$contents = $contents.$article_html->find('article[class=post-content]', 0)->innertext; // extract the post
$item['content'] = $contents;
$this->items[] = $item;
$limit++;
}
}
}
public function getCacheDuration() {
return 1800; // 30min
}
}

View File

@ -1,15 +1,17 @@
<?php <?php
class OpenClassroomsBridge extends BridgeAbstract{ class OpenClassroomsBridge extends BridgeAbstract{
public $maintainer = "sebsauvage"; const MAINTAINER = "sebsauvage";
public $name = "OpenClassrooms Bridge"; const NAME = "OpenClassrooms Bridge";
public $uri = "https://openclassrooms.com/"; const URI = "https://openclassrooms.com/";
public $description = "Returns latest tutorials from OpenClassrooms."; const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns latest tutorials from OpenClassrooms.";
public $parameters = array( array( const PARAMETERS = array( array(
'u'=>array( 'u'=>array(
'name'=>'Catégorie', 'name'=>'Catégorie',
'type'=>'list', 'type'=>'list',
'required'=>true,
'values'=>array( 'values'=>array(
'Arts & Culture'=>'arts', 'Arts & Culture'=>'arts',
'Code'=>'code', 'Code'=>'code',
@ -24,28 +26,21 @@ class OpenClassroomsBridge extends BridgeAbstract{
) )
)); ));
public function getURI(){
public function collectData(){ return self::URI.'/courses?categories='.$this->getInput('u').'&'
if (empty($this->getInput('u'))) .'title=&sort=updatedAt+desc';
{
$this->returnServerError('Error: You must chose a category.');
} }
$html = ''; public function collectData(){
$link = 'https://openclassrooms.com/courses?categories='.$this->getInput('u').'&title=&sort=updatedAt+desc'; $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request OpenClassrooms.');
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request OpenClassrooms.');
foreach($html->find('.courseListItem') as $element) { foreach($html->find('.courseListItem') as $element) {
$item = array(); $item = array();
$item['uri'] = 'https://openclassrooms.com'.$element->find('a', 0)->href; $item['uri'] = self::URI.$element->find('a', 0)->href;
$item['title'] = $element->find('h3', 0)->plaintext; $item['title'] = $element->find('h3', 0)->plaintext;
$item['content'] = $element->find('slidingItem__descriptionContent', 0)->plaintext; $item['content'] = $element->find('slidingItem__descriptionContent', 0)->plaintext;
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getCacheDuration(){
return 21600; // 6 hours
}
} }

View File

@ -1,13 +1,14 @@
<?php <?php
class ParuVenduImmoBridge extends BridgeAbstract class ParuVenduImmoBridge extends BridgeAbstract
{ {
public $maintainer = "polo2ro"; const MAINTAINER = "polo2ro";
public $name = "Paru Vendu Immobilier"; const NAME = "Paru Vendu Immobilier";
public $uri = "http://www.paruvendu.fr"; const URI = "http://www.paruvendu.fr";
public $description = "Returns the ads from the first page of search result."; const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the ads from the first page of search result.";
public $parameters = array( array( const PARAMETERS = array( array(
'minarea'=>array( 'minarea'=>array(
'name'=>'Minimal surface m²', 'name'=>'Minimal surface m²',
'type'=>'number' 'type'=>'number'
@ -25,30 +26,8 @@ class ParuVenduImmoBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$html = ''; $html = getSimpleHTMLDOM($this->getURI())
$num = 20; or returnServerError('Could not request paruvendu.');
$appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1';
$maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1';
$link = $this->uri.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison;
if ($this->getInput('minarea')) {
$link .= '&sur0='.urlencode($this->getInput('minarea'));
}
if ($this->getInput('maxprice')) {
$link .= '&px1='.urlencode($this->getInput('maxprice'));
}
if ($this->getInput('pa')) {
$link .= '&pa='.urlencode($this->getInput('pa'));
}
if ($this->getInput('lo')) {
$link .= '&lo='.urlencode($this->getInput('lo'));
}
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request paruvendu.');
foreach($html->find('div.annonce a') as $element) { foreach($html->find('div.annonce a') as $element) {
@ -71,7 +50,7 @@ class ParuVenduImmoBridge extends BridgeAbstract
list($href) = explode('#', $element->href); list($href) = explode('#', $element->href);
$item = array(); $item = array();
$item['uri'] = $this->uri.$href; $item['uri'] = self::URI.$href;
$item['title'] = $element->title; $item['title'] = $element->title;
$item['content'] = $img.$desc.$price; $item['content'] = $img.$desc.$price;
$this->items[] = $item; $this->items[] = $item;
@ -79,21 +58,39 @@ class ParuVenduImmoBridge extends BridgeAbstract
} }
} }
public function getURI(){
$appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1';
$maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1';
$link = self::URI.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison;
if ($this->getInput('minarea')) {
$link .= '&sur0='.urlencode($this->getInput('minarea'));
}
if ($this->getInput('maxprice')) {
$link .= '&px1='.urlencode($this->getInput('maxprice'));
}
if ($this->getInput('pa')) {
$link .= '&pa='.urlencode($this->getInput('pa'));
}
if ($this->getInput('lo')) {
$link .= '&lo='.urlencode($this->getInput('lo'));
}
return $link;
}
public function getName(){ public function getName(){
$request=''; $request='';
if($this->getInput('minarea') && $minarea=$this->getInput('minarea');
!empty($this->getInput('minarea')) if(!empty($minarea)){
){ $request .= ' '.$minarea.' m2';
$request .= ' '.$this->getInput('minarea').' m2';
} }
if($this->getInput('lo') && $location=$this->getInput('lo');
!empty($this->getInput('lo'))){ if(!empty($location)){
$request .= ' In: '.$this->getInput('lo'); $request .= ' In: '.$location;
} }
return 'Paru Vendu Immobilier'.$request; return 'Paru Vendu Immobilier'.$request;
} }
public function getCacheDuration(){
return 10800; // 3 hours
}
} }

View File

@ -1,48 +1,41 @@
<?php <?php
class PickyWallpapersBridge extends BridgeAbstract { class PickyWallpapersBridge extends BridgeAbstract {
private $category; const MAINTAINER = "nel50n";
private $subcategory; const NAME = "PickyWallpapers Bridge";
private $resolution; const URI = "http://www.pickywallpapers.com/";
const CACHE_TIMEOUT = 43200; // 12h
const DESCRIPTION = "Returns the latests wallpapers from PickyWallpapers";
public $maintainer = "nel50n"; const PARAMETERS = array( array(
public $name = "PickyWallpapers Bridge"; 'c'=>array(
public $uri = "http://www.pickywallpapers.com/"; 'name'=>'category',
public $description = "Returns the latests wallpapers from PickyWallpapers"; 'required'=>true
),
public $parameters = array( array(
'c'=>array('name'=>'category'),
's'=>array('name'=>'subcategory'), 's'=>array('name'=>'subcategory'),
'm'=>array( 'm'=>array(
'name'=>'Max number of wallpapers', 'name'=>'Max number of wallpapers',
'defaultValue'=>12,
'type'=>'number' 'type'=>'number'
), ),
'r'=>array( 'r'=>array(
'name'=>'resolution', 'name'=>'resolution',
'exampleValue'=>'1920x1200, 1680x1050,…', 'exampleValue'=>'1920x1200, 1680x1050,…',
'defaultValue'=>'1920x1200',
'pattern'=>'[0-9]{3,4}x[0-9]{3,4}' 'pattern'=>'[0-9]{3,4}x[0-9]{3,4}'
) )
)); ));
public function collectData(){ public function collectData(){
$html = '';
if (!$this->getInput('c')) {
$this->returnClientError('You must specify at least a category (?c=...).');
} else {
$baseUri = 'http://www.pickywallpapers.com';
$this->category = $this->getInput('c');
$this->subcategory = $this->getInput('s') ?: '';
$this->resolution = $this->getInput('r') ?: '1920x1200'; // Wide wallpaper default
$num = 0;
$max = $this->getInput('m') ?: 12;
$lastpage = 1; $lastpage = 1;
$num = 0;
$max = $this->getInput('m');
$resolution = $this->getInput('r'); // Wide wallpaper default
for ($page = 1; $page <= $lastpage; $page++) { for ($page = 1; $page <= $lastpage; $page++) {
$link = $baseUri.'/'.$this->resolution.'/'.$this->category.'/'.(!empty($this->subcategory)?$this->subcategory.'/':'').'page-'.$page.'/'; $html = getSimpleHTMLDOM($this->getURI().'/page-'.$page.'/')
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.'); or returnServerError('No results for this query.');
if ($page === 1) { if ($page === 1) {
preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches); preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches);
@ -52,7 +45,7 @@ class PickyWallpapersBridge extends BridgeAbstract {
foreach($html->find('.items li img') as $element) { foreach($html->find('.items li img') as $element) {
$item = array(); $item = array();
$item['uri'] = str_replace('www', 'wallpaper', $baseUri).'/'.$this->resolution.'/'.basename($element->src); $item['uri'] = str_replace('www', 'wallpaper', self::URI).'/'.$resolution.'/'.basename($element->src);
$item['timestamp'] = time(); $item['timestamp'] = time();
$item['title'] = $element->alt; $item['title'] = $element->alt;
$item['content'] = $item['title'].'<br><a href="'.$item['uri'].'">'.$element.'</a>'; $item['content'] = $item['title'].'<br><a href="'.$item['uri'].'">'.$element.'</a>';
@ -64,13 +57,17 @@ class PickyWallpapersBridge extends BridgeAbstract {
} }
} }
} }
public function getURI(){
$subcategory = $this->getInput('s');
$link = self::URI.$this->getInput('r').'/'.$this->getInput('c').'/'.$subcategory;
return $link;
} }
public function getName(){ public function getName(){
return 'PickyWallpapers - '.$this->category.(!empty($this->subcategory) ? ' > '.$this->subcategory : '').' ['.$this->resolution.']'; $subcategory = $this->getInput('s');
} return 'PickyWallpapers - '.$this->getInput('c')
.($subcategory? ' > '.$subcategory : '')
public function getCacheDuration(){ .' ['.$this->getInput('r').']';
return 43200; // 12 hours
} }
} }

View File

@ -1,98 +1,121 @@
<?php <?php
class PinterestBridge extends BridgeAbstract{ class PinterestBridge extends BridgeAbstract {
private $username; const MAINTAINER = "pauder";
private $board; const NAME = "Pinterest Bridge";
private $query; const URI = "http://www.pinterest.com/";
const DESCRIPTION = "Returns the newest images on a board";
public $maintainer = "pauder"; const PARAMETERS = array(
public $name = "Pinterest Bridge";
public $uri = "http://www.pinterest.com";
public $description = "Returns the newest images on a board";
public $parameters = array(
'By username and board' => array( 'By username and board' => array(
'u'=>array('name'=>'username'), 'u' => array(
'b'=>array('name'=>'board') 'name' => 'username',
'required' => true
),
'b' => array(
'name' => 'board',
'required' => true
)
), ),
'From search' => array( 'From search' => array(
'q'=>array('name'=>'Keyword') 'q' => array(
'name' => 'Keyword',
'required' => true
)
) )
); );
public function collectData(){ public function collectData(){
$html = ''; $html = getSimpleHTMLDOM($this->getURI());
if ($this->getInput('u') || $this->getInput('b')) { if(!$html){
switch($this->queriedContext){
if (empty($this->getInput('u'))) case 'By username and board':
{ returnServerError('Username and/or board not found');
$this->returnClientError('You must specify a Pinterest username (?u=...).'); case 'From search':
returnServerError('Could not request Pinterest.');
}
} }
if (empty($this->getInput('b'))) if($this->queriedContext === 'From search'){
{ foreach($html->find('div.pinWrapper') as $div){
$this->returnClientError('You must specify a Pinterest board for this username (?b=...).'); $item = array();
}
$this->username = $this->getInput('u');
$this->board = $this->getInput('b');
$html = $this->getSimpleHTMLDOM($this->getURI().'/'.urlencode($this->username).'/'.urlencode($this->board)) or $this->returnServerError('Username and/or board not found');
} else if ($this->getInput('q'))
{
$this->query = $this->getInput('q');
$html = $this->getSimpleHTMLDOM($this->getURI().'/search/?q='.urlencode($this->query)) or $this->returnServerError('Could not request Pinterest.');
}
else {
$this->returnClientError('You must specify a Pinterest username and a board name (?u=...&b=...).');
}
foreach($html->find('div.pinWrapper') as $div)
{
$a = $div->find('a.pinImageWrapper',0);
$a = $div->find('a.pinImageWrapper', 0);
$img = $a->find('img', 0); $img = $a->find('img', 0);
$item = array(); $item['uri'] = $this->getURI() . $a->getAttribute('href');
$item['uri'] = $this->getURI().$a->getAttribute('href'); $item['content'] = '<img src="'
$item['content'] = '<img src="' . htmlentities(str_replace('/236x/', '/736x/', $img->getAttribute('src'))) . '" alt="" />'; . htmlentities(str_replace('/236x/', '/736x/', $img->getAttribute('src')))
. '" alt="" />';
if (isset($this->query))
{
$avatar = $div->find('div.creditImg', 0)->find('img', 0); $avatar = $div->find('div.creditImg', 0)->find('img', 0);
$avatar = $avatar->getAttribute('data-src'); $avatar = $avatar->getAttribute('data-src');
$avatar = str_replace("\\", "", $avatar); $avatar = str_replace("\\", "", $avatar);
$username = $div->find('div.creditName', 0); $username = $div->find('div.creditName', 0);
$board = $div->find('div.creditTitle', 0); $board = $div->find('div.creditTitle', 0);
$item['username'] =$username->innertext; $item['username'] = $username->innertext;
$item['fullname'] = $board->innertext; $item['fullname'] = $board->innertext;
$item['avatar'] = $avatar; $item['avatar'] = $avatar;
$item['content'] .= '<br /><img align="left" style="margin: 2px 4px;" src="'.htmlentities($item['avatar']).'" /> <strong>'.$item['username'].'</strong>'; $item['content'] .= '<br /><img align="left" style="margin: 2px 4px;" src="'
$item['content'] .= '<br />'.$item['fullname']; . htmlentities($item['avatar'])
} . '" /> <strong>'
. $item['username']
. '</strong>'
. '<br />'
. $item['fullname'];
$item['title'] = $img->getAttribute('alt'); $item['title'] = $img->getAttribute('alt');
//$item['timestamp'] = $media->created_time;
$this->items[] = $item; $this->items[] = $item;
} }
} elseif($this->queriedContext === 'By username and board'){
$container = $html->find('SCRIPT[type="application/ld+json"]', 0)
or returnServerError('Unable to find data container!');
$json = json_decode($container->innertext, true);
foreach($json['itemListElement'] as $element){
$item = array();
$item['uri'] = $element['item']['sharedContent']['author']['url'];
$item['title'] = $element['item']['name'];
$item['author'] = $element['item']['user']['name'];
$item['timestamp'] = strtotime($element['item']['datePublished']);
$item['content'] = <<<EOD
<a href="{$item['uri']}">
<img src="{$element['item']['image']}">
</a>
<p>{$element['item']['text']}</p>
EOD;
$this->items[] = $item;
}
}
}
public function getURI(){
switch($this->queriedContext){
case 'By username and board':
$uri = self::URI . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));
break;
case 'From search':
$uri = self::URI . 'search/?q=' . urlencode($this->getInput('q'));
break;
}
return $uri;
} }
public function getName(){ public function getName(){
switch($this->queriedContext){
if (isset($this->query)) case 'By username and board':
{ $specific = $this->getInput('u') . '-' . $this->getInput('b');
return $this->query .' - Pinterest'; break;
} else { case 'From search':
return $this->username .' - '. $this->board.' - Pinterest'; $specific = $this->getInput('q');
break;
} }
return $specific . ' - ' . self::NAME;
} }
} }

View File

@ -1,19 +1,20 @@
<?php <?php
class PlanetLibreBridge extends BridgeAbstract{ class PlanetLibreBridge extends BridgeAbstract{
public $maintainer = "pit-fgfjiudghdf"; const MAINTAINER = "pit-fgfjiudghdf";
public $name = "PlanetLibre"; const NAME = "PlanetLibre";
public $uri = "http://www.planet-libre.org"; const URI = "http://www.planet-libre.org";
public $description = "Returns the 5 newest posts from PlanetLibre (full text)"; const DESCRIPTION = "Returns the 5 newest posts from PlanetLibre (full text)";
private function PlanetLibreExtractContent($url){ private function PlanetLibreExtractContent($url){
$html2 = $this->getSimpleHTMLDOM($url); $html2 = getSimpleHTMLDOM($url);
$text = $html2->find('div[class="post-text"]', 0)->innertext; $text = $html2->find('div[class="post-text"]', 0)->innertext;
return $text; return $text;
} }
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM('http://www.planet-libre.org/') or $this->returnServerError('Could not request PlanetLibre.'); $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request PlanetLibre.');
$limit = 0; $limit = 0;
foreach($html->find('div.post') as $element) { foreach($html->find('div.post') as $element) {
if($limit < 5) { if($limit < 5) {
@ -27,8 +28,4 @@ class PlanetLibreBridge extends BridgeAbstract{
} }
} }
} }
public function getCacheDuration(){
return 3600*2; // 1 hour
}
} }

View File

@ -1,34 +0,0 @@
<?php
class ProjectMGameBridge extends BridgeAbstract{
public $maintainer = "corenting";
public $name = "Project M Game Bridge";
public $uri = "http://projectmgame.com/en/";
public $description = "Returns the newest articles.";
public function collectData(){
$html = '';
$html = $this->getSimpleHTMLDOM('http://projectmgame.com/en/') or $this->returnServerError('Error while downloading the Project M homepage');
foreach($html->find('article') as $article) {
$item = array();
$item['uri'] = 'http://projectmgame.com/en/'.$article->find('section div.info_block a',0)->href;
$item['title'] = $article->find('h1 p',0)->innertext;
$p_list = $article->find('section p');
$content = '';
foreach($p_list as $p) $content .= $p->innertext;
$item['content'] = $content;
// get publication date
$str_date = $article->find('section div.info_block a',0)->innertext;
$item['timestamp'] = strtotime($str_date);
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 10800; //3 hours
}
}

View File

@ -1,11 +1,12 @@
<?php <?php
class RTBFBridge extends BridgeAbstract { class RTBFBridge extends BridgeAbstract {
public $name = "RTBF Bridge"; const NAME = "RTBF Bridge";
public $uri = "http://www.rtbf.be/auvio/emissions"; const URI = "http://www.rtbf.be/auvio/emissions/";
public $description = "Returns the newest RTBF videos by series ID"; const CACHE_TIMEOUT = 21600; //6h
public $maintainer = "Frenzie"; const DESCRIPTION = "Returns the newest RTBF videos by series ID";
const MAINTAINER = "Frenzie";
public $parameters = array( array( const PARAMETERS = array( array(
'c'=>array( 'c'=>array(
'name'=>'series id', 'name'=>'series id',
'exampleValue'=>9500, 'exampleValue'=>9500,
@ -18,14 +19,16 @@ class RTBFBridge extends BridgeAbstract {
$limit = 10; $limit = 10;
$count = 0; $count = 0;
if ($this->getInput('c')) { $html = getSimpleHTMLDOM($this->getURI())
$html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$this->getInput('c')) or $this->returnServerError('Could not request RTBF.'); or returnServerError('Could not request RTBF.');
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) { foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
if($count < $limit) { if($count >= $limit) {
break;
}
$item = array(); $item = array();
$item['id'] = $element->getAttribute('data-id'); $item['id'] = $element->getAttribute('data-id');
$item['uri'] = 'http://www.rtbf.be/auvio/detail?id='.$item['id']; $item['uri'] = self::URI.'detail?id='.$item['id'];
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset')); $thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
$thumbnailUriLastSrc = end($thumbnailUriSrcSet); $thumbnailUriLastSrc = end($thumbnailUriSrcSet);
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0]; $thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
@ -36,17 +39,12 @@ class RTBFBridge extends BridgeAbstract {
$count++; $count++;
} }
} }
}
else { public function getURI(){
$this->returnClientError('You must specify a series id.'); return self::URI.'detail?id='.$this->getInput('c');
}
} }
public function getName(){ public function getName(){
return (!empty($this->request) ? $this->request .' - ' : '') .'RTBF Bridge'; return $this->getInput('c') .' - RTBF Bridge';
}
public function getCacheDuration(){
return 21600; // 6 hours
} }
} }

View File

@ -0,0 +1,43 @@
<?php
class ReadComicsBridge extends BridgeAbstract{
const MAINTAINER = "niawag";
const NAME = "Read Comics";
const URI = "http://www.readcomics.tv/";
const DESCRIPTION = "Enter the comics as they appear in the website uri, separated by semicolons, ex: good-comic-1;good-comic-2; ...";
const PARAMETERS = array( array(
'q'=>array(
'name'=>'keywords, separated by semicolons',
'exampleValue'=>'first list;second list;...',
'required'=>true
),
));
public function collectData(){
function parseDateTimestamp($element){
$guessedDate = $element->find('span',0)->plaintext;
$guessedDate = strptime($guessedDate, '%m/%d/%Y');
$timestamp = mktime(0, 0, 0, $guessedDate['tm_mon'] + 1, $guessedDate['tm_mday'], date('Y'));
return $timestamp;
}
$keywordsList = explode(";",$this->getInput('q'));
foreach($keywordsList as $keywords){
$html = $this->getSimpleHTMLDOM(self::URI.'comic/'.rawurlencode($keywords))
or $this->returnServerError('Could not request readcomics.tv.');
foreach($html->find('li') as $element) {
$item = array();
$item['uri'] = $element->find('a.ch-name',0)->href;
$item['id'] = $item['uri'];
$item['timestamp'] = parseDateTimestamp($element);
$item['title'] = $element->find('a.ch-name',0)->plaintext;
if(isset($item['title']))
$this->items[] = $item;
}
}
}
}

View File

@ -1,10 +1,11 @@
<?php <?php
class Releases3DSBridge extends BridgeAbstract { class Releases3DSBridge extends BridgeAbstract {
public $maintainer = "ORelio"; const MAINTAINER = "ORelio";
public $name = "3DS Scene Releases"; const NAME = "3DS Scene Releases";
public $uri = "http://www.3dsdb.com/"; const URI = "http://www.3dsdb.com/";
public $description = "Returns the newest scene releases."; const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the newest scene releases.";
public function collectData(){ public function collectData(){
@ -32,13 +33,23 @@ class Releases3DSBridge extends BridgeAbstract {
} }
} }
$dataUrl = 'http://3dsdb.com/xml.php'; $dataUrl = self::URI.'xml.php';
$xml = $this->getContents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl); $xml = getContents($dataUrl) or returnServerError('Could not request 3dsdb: '.$dataUrl);
$limit = 0; $limit = 0;
foreach (array_reverse(explode('<release>', $xml)) as $element) { foreach (array_reverse(explode('<release>', $xml)) as $element) {
if ($limit < 5) { if ($limit >= 5) {
if (strpos($element, '</release>') !== false) { break;
}
if (strpos($element, '</release>') === false) {
continue;
}
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
if (empty($releasename)) {
continue;
}
$id = ExtractFromDelimiters($element, '<id>', '</id>'); $id = ExtractFromDelimiters($element, '<id>', '</id>');
$name = ExtractFromDelimiters($element, '<name>', '</name>'); $name = ExtractFromDelimiters($element, '<name>', '</name>');
@ -50,18 +61,15 @@ class Releases3DSBridge extends BridgeAbstract {
$titleid = ExtractFromDelimiters($element, '<titleid>', '</titleid>'); $titleid = ExtractFromDelimiters($element, '<titleid>', '</titleid>');
$imgcrc = ExtractFromDelimiters($element, '<imgcrc>', '</imgcrc>'); $imgcrc = ExtractFromDelimiters($element, '<imgcrc>', '</imgcrc>');
$filename = ExtractFromDelimiters($element, '<filename>', '</filename>'); $filename = ExtractFromDelimiters($element, '<filename>', '</filename>');
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
$trimmedsize = ExtractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>'); $trimmedsize = ExtractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>');
$firmware = ExtractFromDelimiters($element, '<firmware>', '</firmware>'); $firmware = ExtractFromDelimiters($element, '<firmware>', '</firmware>');
$type = ExtractFromDelimiters($element, '<type>', '</type>'); $type = ExtractFromDelimiters($element, '<type>', '</type>');
$card = ExtractFromDelimiters($element, '<card>', '</card>'); $card = ExtractFromDelimiters($element, '<card>', '</card>');
if (!empty($releasename)) {
//Retrieve cover art and short desc from IGN? //Retrieve cover art and short desc from IGN?
$ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = ''; $ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = '';
$ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name); $ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name);
if ($ignResult = $this->getSimpleHTMLDOM($ignSearchUrl)) { if ($ignResult = getSimpleHTMLDOM($ignSearchUrl)) {
$ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src; $ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src;
$ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext; $ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext;
$ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href; $ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href;
@ -109,11 +117,4 @@ class Releases3DSBridge extends BridgeAbstract {
$limit++; $limit++;
} }
} }
}
}
}
public function getCacheDuration() {
return 10800; //3 hours
}
} }

View File

@ -1,13 +1,13 @@
<?php <?php
class ReporterreBridge extends BridgeAbstract{ class ReporterreBridge extends BridgeAbstract{
public $maintainer = "nyutag"; const MAINTAINER = "nyutag";
public $name = "Reporterre Bridge"; const NAME = "Reporterre Bridge";
public $uri = "http://www.reporterre.net/"; const URI = "http://www.reporterre.net/";
public $description = "Returns the newest articles."; const DESCRIPTION = "Returns the newest articles.";
private function ExtractContentReporterre($url) { private function ExtractContentReporterre($url) {
$html2 = $this->getSimpleHTMLDOM($url); $html2 = getSimpleHTMLDOM($url);
foreach($html2->find('div[style=text-align:justify]') as $e) { foreach($html2->find('div[style=text-align:justify]') as $e) {
$text = $e->outertext; $text = $e->outertext;
@ -17,14 +17,14 @@ class ReporterreBridge extends BridgeAbstract{
unset ($html2); unset ($html2);
// Replace all relative urls with absolute ones // Replace all relative urls with absolute ones
$text = preg_replace('/(href|src)(\=[\"\'])(?!http)([^"\']+)/ims', "$1$2" . $this->uri . "$3", $text); $text = preg_replace('/(href|src)(\=[\"\'])(?!http)([^"\']+)/ims', "$1$2" . self::URI . "$3", $text);
$text = strip_tags($text, '<p><br><a><img>'); $text = strip_tags($text, '<p><br><a><img>');
return $text; return $text;
} }
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM('http://www.reporterre.net/spip.php?page=backend') or $this->returnServerError('Could not request Reporterre.'); $html = getSimpleHTMLDOM(self::URI.'spip.php?page=backend') or returnServerError('Could not request Reporterre.');
$limit = 0; $limit = 0;
foreach($html->find('item') as $element) { foreach($html->find('item') as $element) {

View File

@ -1,42 +1,22 @@
<?php <?php
class Rue89Bridge extends BridgeAbstract{ class Rue89Bridge extends FeedExpander {
public $maintainer = "pit-fgfjiudghdf"; const MAINTAINER = "pit-fgfjiudghdf";
public $name = "Rue89"; const NAME = "Rue89";
public $uri = "http://rue89.nouvelobs.com/"; const URI = "http://rue89.nouvelobs.com/";
public $description = "Returns the 5 newest posts from Rue89 (full text)"; const DESCRIPTION = "Returns the 5 newest posts from Rue89 (full text)";
private function rue89getDatas($url){ protected function parseItem($item){
$item = parent::parseItem($item);
$url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($url, -8)) . "/full"; $url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($item['uri'], -8)) . "/full";
$datas = json_decode($this->getContents($url), true); $datas = json_decode(getContents($url), true);
$item['content'] = $datas['node']['body'];
return $datas["node"];
return $item;
} }
public function collectData(){ public function collectData(){
$this->collectExpandableDatas('http://api.rue89.nouvelobs.com/feed');
$html = $this->getSimpleHTMLDOM('http://api.rue89.nouvelobs.com/feed') or $this->returnServerError('Could not request Rue89.');
$limit = 0;
foreach($html->find('item') as $element) {
if($limit < 5) {
$datas = $this->rue89getDatas(str_replace('#commentaires', '', ($element->find('comments', 0)->plaintext)));
$item = array();
$item['title'] = $datas["title"];
$item['author'] = $datas["author"][0]["name"];
$item['timestamp'] = $datas["updated"];
$item['content'] = $datas["body"];
$item['uri'] = $datas["url"];
$this->items[] = $item;
}
}
} }
} }

View File

@ -1,46 +1,12 @@
<?php <?php
class Rule34Bridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
public $maintainer = "mitsukarenai"; class Rule34Bridge extends GelbooruBridge{
public $name = "Rule34";
public $uri = "http://rule34.xxx/";
public $description = "Returns images from given page";
public $parameters = array( array( const MAINTAINER = "mitsukarenai";
'p'=>array( const NAME = "Rule34";
'name'=>'page', const URI = "http://rule34.xxx/";
'type'=>'number' const DESCRIPTION = "Returns images from given page";
),
't'=>array('name'=>'tags')
));
public function collectData(){ const PIDBYPAGE=50;
$page = 0;$tags='';
if ($this->getInput('p')) {
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p'));
$page = $page - 1;
$page = $page * 50;
}
if ($this->getInput('t')) {
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("http://rule34.xxx/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Rule34.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = 'http://rule34.xxx/'.$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'] = 'Rule34 | '.$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
}
} }

Some files were not shown because too many files have changed in this diff Show More