mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-22 22:46:53 +00:00
Merge master.
This commit is contained in:
commit
38c4f43a3e
@ -1,7 +1,5 @@
|
||||
language: php
|
||||
php:
|
||||
- '5.4'
|
||||
- '5.5'
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- hhvm
|
||||
@ -14,3 +12,10 @@ script:
|
||||
- phpenv rehash
|
||||
- phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
|
||||
- phpunit -c tests/phpunit.xml
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: nightly
|
||||
|
||||
|
44
CHANGELOG.md
44
CHANGELOG.md
@ -7,13 +7,14 @@ Alpha 0.1
|
||||
* Includes refactoring.
|
||||
* Unstable.
|
||||
|
||||
Alpha 0.2 (current development version)
|
||||
Alpha 0.2
|
||||
===
|
||||
|
||||
## Important changes
|
||||
* 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 now has a [Wiki](https://github.com/rss-bridge/rss-bridge/wiki)
|
||||
* RSS-Bridge now supports [Travis-CI](https://travis-ci.org)
|
||||
|
||||
## General changes
|
||||
* 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 new format [MrssFormat](formats/MrssFormat.php)
|
||||
* Added parameter `author` - for display of the feed author name - to all formats
|
||||
* Added new abstractions of the BridgeInterface:
|
||||
- [HttpCachingBridgeAbstract](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API)
|
||||
- [RssExpander](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API)
|
||||
* Added new abstraction of the BridgeInterface:
|
||||
- [FeedExpander](https://github.com/RSS-Bridge/rss-bridge/wiki/Bridge-API)
|
||||
* 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)
|
||||
* Changed design of the welcome screen
|
||||
* Changed design of HtmlFormat
|
||||
* Changed behavior of debug mode:
|
||||
- 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 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
|
||||
- Changed the parameter loading algorithm to be loaded by RSS-Bridge core
|
||||
* Improved checks for PHP version, configuration and extensions
|
||||
* Many bug fixes
|
||||
|
||||
## Modified Bridges
|
||||
@ -46,7 +48,6 @@ Alpha 0.2 (current development version)
|
||||
* AcrimedBridge
|
||||
* AllocineFRBridge
|
||||
* AnimeUltimeBridge
|
||||
* ArstechnicaBridge
|
||||
* Arte7Bridge
|
||||
* AskfmBridge
|
||||
* BandcampBridge
|
||||
@ -80,17 +81,13 @@ Alpha 0.2 (current development version)
|
||||
* FlickrTagBridge
|
||||
* FootitoBridge
|
||||
* FourchanBridge
|
||||
* Freenews
|
||||
* FuturaSciencesBridge
|
||||
* GBAtempBridge
|
||||
* Gawker
|
||||
* GelbooruBridge
|
||||
* GiphyBridge
|
||||
* GithubIssueBridge
|
||||
* GitlabCommitsBridge
|
||||
* GizmodoFRBridge
|
||||
* GizmodoBridge
|
||||
* GooglePlusPostBridge
|
||||
* GuruMedBridge
|
||||
* HDWallpapersBridge
|
||||
* HentaiHavenBridge
|
||||
* IdenticaBridge
|
||||
@ -102,33 +99,31 @@ Alpha 0.2 (current development version)
|
||||
* KununuBridge
|
||||
* LWNprevBridge
|
||||
* LeBonCoinBridge
|
||||
* LeJournalDuGeekBridge
|
||||
* LegifranceJOBridge
|
||||
* LeMondeInformatiqueBridge
|
||||
* Les400Culs
|
||||
* LesJoiesDuCodeBridge
|
||||
* LichessBridge
|
||||
* LinkedInCompany
|
||||
* LinkedInCompanyBridge
|
||||
* LolibooruBridge
|
||||
* MangareaderBridge
|
||||
* MilbooruBridge
|
||||
* MoebooruBridge
|
||||
* MondeDiploBridge
|
||||
* MsnMondeBridge
|
||||
* MspabooruBridge
|
||||
* NakedSecurityBridge
|
||||
* NasaApodBridge
|
||||
* NeuviemeArtBridge
|
||||
* NextInpactBridge
|
||||
* NextgovBridge
|
||||
* NiceMatinBridge
|
||||
* NovelUpdatesBridge
|
||||
* NumeramaBridge
|
||||
* OpenClassroomsBridge
|
||||
* ParuVenduImmoBridge
|
||||
* PickyWallpapersBridge
|
||||
* PinterestBridge
|
||||
* PlanetLibreBridge
|
||||
* ProjectMGameBridge
|
||||
* RTBFBridge
|
||||
* ReadComicsBridge
|
||||
* Releases3DSBridge
|
||||
* ReporterreBridge
|
||||
* Rue89Bridge
|
||||
@ -139,9 +134,9 @@ Alpha 0.2 (current development version)
|
||||
* ScmbBridge
|
||||
* ScoopItBridge
|
||||
* SensCritiqueBridge
|
||||
* Sexactu
|
||||
* SexactuBridge
|
||||
* ShanaprojectBridge
|
||||
* SiliconBridge
|
||||
* Shimmie2Bridge
|
||||
* SoundcloudBridge
|
||||
* StripeAPIChangeLogBridge
|
||||
* SuperbWallpapersBridge
|
||||
@ -150,22 +145,19 @@ Alpha 0.2 (current development version)
|
||||
* TbibBridge
|
||||
* TheCodingLoveBridge
|
||||
* TheHackerNewsBridge
|
||||
* TheOatMealBridge
|
||||
* ThePirateBayBridge
|
||||
* TwitchApiBridge
|
||||
* UnsplashBridge
|
||||
* ViadeoCompany
|
||||
* ViadeoCompanyBridge
|
||||
* VineBridge
|
||||
* VkBridge
|
||||
* WallpaperStopBridge
|
||||
* WebfailBridge
|
||||
* WeLiveSecurityBridge
|
||||
* WhydBridge
|
||||
* WikipediaBridge
|
||||
* WordPressBridge
|
||||
* WorldOfTanks
|
||||
* WorldOfTanksBridge
|
||||
* XbooruBridge
|
||||
* YandereBridge
|
||||
* YoutubeBridge
|
||||
* ZDNetBridge
|
||||
* ZatazBridge
|
||||
* ZoneTelechargementBridge
|
||||
|
@ -51,8 +51,9 @@ RSS-Bridge hashtag (#rss-bridge) search on Twitter, in ATOM format (as displayed
|
||||
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`)
|
||||
* `allow_url_fopen=1` in `php.ini`
|
||||
|
||||
Enabling/Disabling bridges
|
||||
===
|
||||
@ -107,6 +108,9 @@ Patch/contributors :
|
||||
* [kraoc](https://github.com/kraoc)
|
||||
* [lagaisse](https://github.com/lagaisse)
|
||||
* [az5he6ch](https://github.com/az5he6ch)
|
||||
* [niawag](https://github.com/niawag)
|
||||
* [JeremyRand](https://github.com/JeremyRand)
|
||||
* [mro](https://github.com/mro)
|
||||
|
||||
Licenses
|
||||
===
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
class ABCTabsBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "kranack";
|
||||
public $name = "ABC Tabs Bridge";
|
||||
public $uri = "http://www.abc-tabs.com/";
|
||||
public $description = "Returns 22 newest tabs";
|
||||
const MAINTAINER = "kranack";
|
||||
const NAME = "ABC Tabs Bridge";
|
||||
const URI = "http://www.abc-tabs.com/";
|
||||
const DESCRIPTION = "Returns 22 newest tabs";
|
||||
|
||||
public function collectData(){
|
||||
$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);
|
||||
|
||||
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['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['id'] = 'http://www.abc-tabs.com' . $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['id'] = static::URI . $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;
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,25 @@
|
||||
<?php
|
||||
class AcrimedBridge extends RssExpander{
|
||||
class AcrimedBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Acrimed Bridge";
|
||||
const URI = "http://www.acrimed.org/";
|
||||
const CACHE_TIMEOUT = 4800; //2hours
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
public $maintainer = "qwertygc";
|
||||
public $name = "Acrimed Bridge";
|
||||
public $uri = "http://www.acrimed.org/";
|
||||
public $description = "Returns the newest articles.";
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$this->collectExpandableDatas("http://www.acrimed.org/spip.php?page=backend");
|
||||
|
||||
}
|
||||
|
||||
protected function parseRSSItem($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/");
|
||||
|
||||
$item['content'] = $article;
|
||||
|
||||
|
||||
return $item;
|
||||
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 4800; // 2 hours
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas(static::URI.'spip.php?page=backend');
|
||||
}
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
|
||||
$articlePage = getSimpleHTMLDOM($newsItem->link);
|
||||
$article = sanitize($articlePage->find('article.article1', 0)->innertext);
|
||||
$article = defaultImageSrcTo($article, static::URI);
|
||||
$item['content'] = $article;
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
class AllocineFRBridge extends BridgeAbstract{
|
||||
|
||||
|
||||
public $maintainer = "superbaillot.net";
|
||||
public $name = "Allo Cine Bridge";
|
||||
public $uri = "http://www.allocine.fr";
|
||||
public $description = "Bridge for allocine.fr";
|
||||
public $parameters = array( array(
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Allo Cine Bridge";
|
||||
const CACHE_TIMEOUT = 25200; // 7h
|
||||
const URI = "http://www.allocine.fr/";
|
||||
const DESCRIPTION = "Bridge for allocine.fr";
|
||||
const PARAMETERS = array( array(
|
||||
'category'=>array(
|
||||
'name'=>'category',
|
||||
'type'=>'list',
|
||||
@ -24,13 +25,13 @@ class AllocineFRBridge extends BridgeAbstract{
|
||||
public function getURI(){
|
||||
switch($this->getInput('category')){
|
||||
case 'faux-raccord':
|
||||
$uri = 'http://www.allocine.fr/video/programme-12284/saison-24580/';
|
||||
$uri = static::URI.'video/programme-12284/saison-27129/';
|
||||
break;
|
||||
case 'top-5':
|
||||
$uri = 'http://www.allocine.fr/video/programme-12299/saison-22542/';
|
||||
$uri = static::URI.'video/programme-12299/saison-29561/';
|
||||
break;
|
||||
case 'tueurs-en-serie':
|
||||
$uri = 'http://www.allocine.fr/video/programme-12286/saison-22938/';
|
||||
$uri = static::URI.'video/programme-12286/saison-22938/';
|
||||
break;
|
||||
}
|
||||
|
||||
@ -38,21 +39,21 @@ class AllocineFRBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name.' : '
|
||||
return self::NAME.' : '
|
||||
.array_search(
|
||||
$this->getInput('category'),
|
||||
$this->parameters[$this->queriedContext]['category']['values']
|
||||
self::PARAMETERS[$this->queriedContext]['category']['values']
|
||||
);
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||
or $this->returnServerError("Could not request ".$this->getURI()." !");
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError("Could not request ".$this->getURI()." !");
|
||||
|
||||
$category=array_search(
|
||||
$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)
|
||||
{
|
||||
$content = str_replace('src="/', 'src="http://www.allocine.fr/', $content);
|
||||
$content = str_replace('href="/', 'href="http://www.allocine.fr/', $content);
|
||||
$content = str_replace('src=\'/', 'src=\'http://www.allocine.fr/', $content);
|
||||
$content = str_replace('href=\'/', 'href=\'http://www.allocine.fr/', $content);
|
||||
$content = str_replace('src="/', 'src="'.static::URI, $content);
|
||||
$content = str_replace('href="/', 'href="'.static::URI, $content);
|
||||
$content = str_replace('src=\'/', 'src=\''.static::URI, $content);
|
||||
$content = str_replace('href=\'/', 'href=\''.static::URI, $content);
|
||||
$item['content'] = $content;
|
||||
$item['title'] = trim($title->innertext);
|
||||
$item['uri'] = "http://www.allocine.fr" . $title->href;
|
||||
$item['uri'] = static::URI . $title->href;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 25200; // 7 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class AnimeUltimeBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = 'ORelio';
|
||||
public $name = 'Anime-Ultime';
|
||||
public $uri = 'http://www.anime-ultime.net/';
|
||||
public $description = 'Returns the 10 newest releases posted on Anime-Ultime';
|
||||
public $parameters = array( array(
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'Anime-Ultime';
|
||||
const URI = 'http://www.anime-ultime.net/';
|
||||
const CACHE_TIMEOUT = 10800; // 3h
|
||||
const DESCRIPTION = 'Returns the 10 newest releases posted on Anime-Ultime';
|
||||
const PARAMETERS = array( array(
|
||||
'type'=>array(
|
||||
'name'=>'Type',
|
||||
'type'=>'list',
|
||||
@ -25,7 +26,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
//Add type filter if provided
|
||||
$typeFilter = array_search(
|
||||
$this->getInput('type'),
|
||||
$this->parameters[$this->queriedContext]['type']['values']
|
||||
self::PARAMETERS[$this->queriedContext]['type']['values']
|
||||
);
|
||||
|
||||
//Build date and filters for making requests
|
||||
@ -37,9 +38,9 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
foreach (array($thismonth, $lastmonth) as $requestFilter) {
|
||||
|
||||
//Retrive page contents
|
||||
$url = $this->uri.'history-0-1/'.$requestFilter;
|
||||
$html = $this->getSimpleHTMLDOM($url)
|
||||
or $this->returnServerError('Could not request Anime-Ultime: '.$url);
|
||||
$url = self::URI.'history-0-1/'.$requestFilter;
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Could not request Anime-Ultime: '.$url);
|
||||
|
||||
//Relases are sorted by day : process each day individually
|
||||
foreach ($html->find('div.history', 0)->find('h3') as $daySection) {
|
||||
@ -58,7 +59,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
|
||||
//Retrieve metadata from table columns
|
||||
$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_episode = html_entity_decode(str_pad($release->find('td', 1)->plaintext, 2, '0', STR_PAD_LEFT));
|
||||
$item_fansub = $release->find('td', 2)->plaintext;
|
||||
@ -67,8 +68,8 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
if (!empty($item_uri)) {
|
||||
|
||||
//Retrieve description from description page and convert relative image src info absolute image src
|
||||
$html_item = $this->getContents($item_uri)
|
||||
or $this->returnServerError('Could not request Anime-Ultime: '.$item_uri);
|
||||
$html_item = getContents($item_uri)
|
||||
or returnServerError('Could not request Anime-Ultime: '.$item_uri);
|
||||
$item_description = substr(
|
||||
$html_item,
|
||||
strpos($html_item, 'class="principal_contain" align="center">')
|
||||
@ -79,7 +80,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
strpos($item_description, '<div id="table">')
|
||||
);
|
||||
$item_description = str_replace(
|
||||
'src="images', 'src="'.$this->uri.'images',
|
||||
'src="images', 'src="'.self::URI.'images',
|
||||
$item_description
|
||||
);
|
||||
$item_description = str_replace("\r", '', $item_description);
|
||||
@ -109,14 +110,10 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
public function getName() {
|
||||
$typeFilter = array_search(
|
||||
$this->getInput('type'),
|
||||
$this->parameters[$this->queriedContext]['type']['values']
|
||||
self::PARAMETERS[$this->queriedContext]['type']['values']
|
||||
);
|
||||
|
||||
return 'Latest '.$typeFilter.' - Anime-Ultime Bridge';
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return 3600*3; // 3 hours
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
<?php
|
||||
class Arte7Bridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Arte +7";
|
||||
public $uri = "http://www.arte.tv/";
|
||||
public $description = "Returns newest videos from ARTE +7";
|
||||
public $parameters = array(
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Arte +7";
|
||||
const URI = "http://www.arte.tv/";
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns newest videos from ARTE +7";
|
||||
const PARAMETERS = array(
|
||||
'Catégorie (Français)' => array(
|
||||
'catfr'=>array(
|
||||
'type'=>'list',
|
||||
@ -56,18 +57,19 @@
|
||||
break;
|
||||
}
|
||||
|
||||
$url = $this->uri.'guide/'.$lang.'/plus7/'.$category;
|
||||
$input = $this->getContents($url) or die('Could not request ARTE.');
|
||||
$url = self::URI.'guide/'.$lang.'/plus7/'.$category;
|
||||
$input = getContents($url) or die('Could not request ARTE.');
|
||||
if(strpos($input, 'categoryVideoSet') !== FALSE){
|
||||
$input = explode('categoryVideoSet: ', $input);
|
||||
$input = explode('}},', $input[1]);
|
||||
$input = explode('categoryVideoSet="', $input);
|
||||
$input = explode('}}', $input[1]);
|
||||
$input = $input[0].'}}';
|
||||
}else{
|
||||
$input = explode('videoSet: ', $input);
|
||||
$input = explode('}]},', $input[1]);
|
||||
$input = explode('videoSet="', $input);
|
||||
$input = explode('}]}', $input[1]);
|
||||
$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) {
|
||||
$item = array();
|
||||
@ -86,7 +88,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 1800; // 30 minutes
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class AskfmBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "az5he6ch";
|
||||
public $name = "Ask.fm Answers";
|
||||
public $uri = "http://ask.fm/";
|
||||
public $description = "Returns answers from an Ask.fm user";
|
||||
public $parameters = array(
|
||||
const MAINTAINER = "az5he6ch";
|
||||
const NAME = "Ask.fm Answers";
|
||||
const URI = "http://ask.fm/";
|
||||
const CACHE_TIMEOUT = 300; //5 min
|
||||
const DESCRIPTION = "Returns answers from an Ask.fm user";
|
||||
const PARAMETERS = array(
|
||||
'Ask.fm username'=>array(
|
||||
'u'=>array(
|
||||
'name'=>'Username',
|
||||
@ -15,12 +16,12 @@ class AskfmBridge extends BridgeAbstract{
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||
or $this->returnServerError('Requested username can\'t be found.');
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Requested username can\'t be found.');
|
||||
|
||||
foreach($html->find('div.streamItem-answer') as $element) {
|
||||
$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);
|
||||
$item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES));
|
||||
$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>';
|
||||
// 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;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name.' : '.$this->getInput('u');
|
||||
return self::NAME.' : '.$this->getInput('u');
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class BandcampBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "sebsauvage";
|
||||
public $name = "Bandcamp Tag";
|
||||
public $uri = "http://bandcamp.com/";
|
||||
public $description = "New bandcamp release by tag";
|
||||
public $parameters = array( array(
|
||||
const MAINTAINER = "sebsauvage";
|
||||
const NAME = "Bandcamp Tag";
|
||||
const URI = "http://bandcamp.com/";
|
||||
const CACHE_TIMEOUT = 600; // 10min
|
||||
const DESCRIPTION = "New bandcamp release by tag";
|
||||
const PARAMETERS = array( array(
|
||||
'tag'=>array(
|
||||
'name'=>'tag',
|
||||
'type'=>'text',
|
||||
@ -14,8 +15,8 @@ class BandcampBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||
or $this->returnServerError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
foreach($html->find('li.item') as $release) {
|
||||
$script = $release->find('div.art', 0)->getAttribute('onclick');
|
||||
@ -33,14 +34,10 @@ class BandcampBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
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(){
|
||||
return $this->getInput('tag') .' - '.'Bandcamp Tag';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 600; // 10 minutes
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
class BastaBridge extends BridgeAbstract{
|
||||
public $maintainer = "qwertygc";
|
||||
public $name = "Bastamag Bridge";
|
||||
public $uri = "http://www.bastamag.net/";
|
||||
public $description = "Returns the newest articles.";
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Bastamag Bridge";
|
||||
const URI = "http://www.bastamag.net/";
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
public function collectData(){
|
||||
// Replaces all relative image URLs by absolute URLs. Relative URLs always start with 'local/'!
|
||||
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')
|
||||
or $this->returnServerError('Could not request Bastamag.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'spip.php?page=backend')
|
||||
or returnServerError('Could not request Bastamag.');
|
||||
$limit = 0;
|
||||
|
||||
foreach($html->find('item') as $element) {
|
||||
@ -21,15 +22,11 @@ class BastaBridge extends BridgeAbstract{
|
||||
$item['title'] = $element->find('title', 0)->innertext;
|
||||
$item['uri'] = $element->find('guid', 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;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 3600*2; // 2 hours
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,15 +1,16 @@
|
||||
<?php
|
||||
class BlaguesDeMerdeBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "superbaillot.net";
|
||||
public $name = "Blagues De Merde";
|
||||
public $uri = "http://www.blaguesdemerde.fr/";
|
||||
public $description = "Blagues De Merde";
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Blagues De Merde";
|
||||
const URI = "http://www.blaguesdemerde.fr/";
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Blagues De Merde";
|
||||
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request BDM.');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request BDM.');
|
||||
|
||||
foreach($html->find('article.joke_contener') as $element) {
|
||||
$item = array();
|
||||
@ -28,9 +29,5 @@ class BlaguesDeMerdeBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 7200; // 2h hours
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,48 +1,36 @@
|
||||
<?php
|
||||
class BooruprojectBridge extends BridgeAbstract{
|
||||
require_once('GelbooruBridge.php');
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Booruproject";
|
||||
public $uri = "http://booru.org/";
|
||||
public $description = "Returns images from given page and booruproject instance (****.booru.org)";
|
||||
class BooruprojectBridge extends GelbooruBridge{
|
||||
|
||||
public $parameters = array( array(
|
||||
'i'=>array(
|
||||
'name'=>'instance (required)',
|
||||
'required'=>true
|
||||
),
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
));
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Booruproject";
|
||||
const URI = "http://booru.org/";
|
||||
const DESCRIPTION = "Returns images from given page of booruproject";
|
||||
|
||||
function getURI(){
|
||||
return 'http://'.$this->getInput('i').'.booru.org/';
|
||||
const PARAMETERS = array(
|
||||
'global'=>array(
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
),
|
||||
'Booru subdomain (subdomain.booru.org)'=>array(
|
||||
'i'=>array(
|
||||
'name'=>'Subdomain',
|
||||
'required'=>true
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
const PIDBYPAGE=20;
|
||||
|
||||
public function getURI(){
|
||||
return 'http://'.$this->getInput('i').'.booru.org/';
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM(
|
||||
$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
|
||||
public function getName(){
|
||||
return static::NAME . ' ' . $this->getInput('i');
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,23 @@
|
||||
<?php
|
||||
class CADBridge extends BridgeAbstract{
|
||||
public $maintainer = "nyutag";
|
||||
public $name = "CAD Bridge";
|
||||
public $uri = "http://www.cad-comic.com/";
|
||||
public $description = "Returns the newest articles.";
|
||||
class CADBridge extends FeedExpander {
|
||||
const MAINTAINER = "nyutag";
|
||||
const NAME = "CAD Bridge";
|
||||
const URI = "http://www.cad-comic.com/";
|
||||
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) {
|
||||
$html3 = $this->getSimpleHTMLDOM($url);
|
||||
$html3 = getSimpleHTMLDOMCached($url);
|
||||
|
||||
// The request might fail due to missing https support or wrong URL
|
||||
if($html3 == false)
|
||||
@ -31,36 +42,5 @@ class CADBridge extends BridgeAbstract{
|
||||
return 'Daily comic not released yet';
|
||||
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
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class CNETBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = 'ORelio';
|
||||
public $name = 'CNET News';
|
||||
public $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 MAINTAINER = 'ORelio';
|
||||
const NAME = 'CNET News';
|
||||
const URI = 'http://www.cnet.com/';
|
||||
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')
|
||||
));
|
||||
|
||||
@ -37,21 +38,21 @@ class CNETBridge extends BridgeAbstract {
|
||||
return $article_html;
|
||||
}
|
||||
|
||||
$pageUrl = $this->uri.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/');
|
||||
$html = $this->getSimpleHTMLDOM($pageUrl) or $this->returnServerError('Could not request CNET: '.$pageUrl);
|
||||
$pageUrl = self::URI.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/');
|
||||
$html = getSimpleHTMLDOM($pageUrl) or returnServerError('Could not request CNET: '.$pageUrl);
|
||||
$limit = 0;
|
||||
|
||||
foreach($html->find('div.assetBody') as $element) {
|
||||
if ($limit < 8) {
|
||||
|
||||
$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_author = trim($element->find('a[rel=author]', 0)->plaintext);
|
||||
|
||||
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>')));
|
||||
|
||||
@ -69,10 +70,7 @@ class CNETBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'CNET News Bridge'.(empty($this->getInput('topic')) ? '' : ' - '.$this->getInput('topic'));
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return 1800; // 30 minutes
|
||||
$topic=$this->getInput('topic');
|
||||
return 'CNET News Bridge'.(empty($topic) ? '' : ' - '.$topic);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class CastorusBridge extends BridgeAbstract {
|
||||
public $maintainer = "logmanoriginal";
|
||||
public $name = "Castorus Bridge";
|
||||
public $uri = 'http://www.castorus.com';
|
||||
public $description = "Returns the latest changes";
|
||||
const MAINTAINER = "logmanoriginal";
|
||||
const NAME = "Castorus Bridge";
|
||||
const URI = 'http://www.castorus.com';
|
||||
const CACHE_TIMEOUT = 600; // 10min
|
||||
const DESCRIPTION = "Returns the latest changes";
|
||||
|
||||
public $parameters = array(
|
||||
const PARAMETERS = array(
|
||||
'Get latest changes' => array(),
|
||||
'Get latest changes via ZIP code' => array(
|
||||
'zip'=>array(
|
||||
@ -32,7 +33,7 @@ class CastorusBridge extends BridgeAbstract {
|
||||
$title = $activity->find('a', 0);
|
||||
|
||||
if(!$title)
|
||||
$this->returnServerError('Cannot find title!');
|
||||
returnServerError('Cannot find title!');
|
||||
|
||||
return htmlspecialchars(trim($title->plaintext));
|
||||
}
|
||||
@ -42,9 +43,9 @@ class CastorusBridge extends BridgeAbstract {
|
||||
$url = $activity->find('a', 0);
|
||||
|
||||
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
|
||||
@ -54,7 +55,7 @@ class CastorusBridge extends BridgeAbstract {
|
||||
$nodes = $activity->find('*');
|
||||
|
||||
if(!$nodes)
|
||||
$this->returnServerError('Cannot find nodes!');
|
||||
returnServerError('Cannot find nodes!');
|
||||
|
||||
foreach($nodes as $node){
|
||||
$node->outertext = '';
|
||||
@ -68,7 +69,7 @@ class CastorusBridge extends BridgeAbstract {
|
||||
$price = $activity->find('span', 1);
|
||||
|
||||
if(!$price)
|
||||
$this->returnServerError('Cannot find price!');
|
||||
returnServerError('Cannot find price!');
|
||||
|
||||
return $price->innertext;
|
||||
}
|
||||
@ -77,15 +78,15 @@ class CastorusBridge extends BridgeAbstract {
|
||||
$zip_filter = trim($this->getInput('zip'));
|
||||
$city_filter = trim($this->getInput('city'));
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->uri);
|
||||
$html = getSimpleHTMLDOM(self::URI);
|
||||
|
||||
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');
|
||||
|
||||
if(!$activities)
|
||||
$this->returnServerError('Failed to find activities!');
|
||||
returnServerError('Failed to find activities!');
|
||||
|
||||
foreach($activities as $activity){
|
||||
$item = array();
|
||||
@ -107,8 +108,4 @@ class CastorusBridge extends BridgeAbstract {
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 600; // 10 minutes
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
class CollegeDeFranceBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "pit-fgfjiudghdf";
|
||||
public $name = "CollegeDeFrance";
|
||||
public $uri = "http://www.college-de-france.fr/";
|
||||
public $description = "Returns the latest audio and video from CollegeDeFrance";
|
||||
const MAINTAINER = "pit-fgfjiudghdf";
|
||||
const NAME = "CollegeDeFrance";
|
||||
const URI = "http://www.college-de-france.fr/";
|
||||
const CACHE_TIMEOUT = 10800; // 3h
|
||||
const DESCRIPTION = "Returns the latest audio and video from CollegeDeFrance";
|
||||
|
||||
public function collectData(){
|
||||
$months = array(
|
||||
@ -30,8 +31,8 @@ class CollegeDeFranceBridge extends BridgeAbstract{
|
||||
* </a>
|
||||
* </li>
|
||||
*/
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
|
||||
or $this->returnServerError('Could not request CollegeDeFrance.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
|
||||
or returnServerError('Could not request CollegeDeFrance.');
|
||||
foreach($html->find('a[data-target]') as $element) {
|
||||
$item = array();
|
||||
$item['title'] = $element->find('.title', 0)->plaintext;
|
||||
@ -62,12 +63,8 @@ class CollegeDeFranceBridge extends BridgeAbstract{
|
||||
}
|
||||
$item['timestamp'] = $d->format('U');
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 3600*3; // 3 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +1,26 @@
|
||||
<?php
|
||||
class CommonDreamsBridge extends BridgeAbstract{
|
||||
class CommonDreamsBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "nyutag";
|
||||
public $name = "CommonDreams Bridge";
|
||||
public $uri = "http://www.commondreams.org/";
|
||||
public $description = "Returns the newest articles.";
|
||||
const MAINTAINER = "nyutag";
|
||||
const NAME = "CommonDreams Bridge";
|
||||
const URI = "http://www.commondreams.org/";
|
||||
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) {
|
||||
$html3 = $this->getSimpleHTMLDOM($url);
|
||||
$html3 = getSimpleHTMLDOMCached($url);
|
||||
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
|
||||
$html3->clear();
|
||||
unset ($html3);
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
class CopieDoubleBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "superbaillot.net";
|
||||
public $name = "CopieDouble";
|
||||
public $uri = "http://www.copie-double.com/";
|
||||
public $description = "CopieDouble";
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "CopieDouble";
|
||||
const URI = "http://www.copie-double.com/";
|
||||
const CACHE_TIMEOUT = 14400; // 4h
|
||||
const DESCRIPTION = "CopieDouble";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request CopieDouble.');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request CopieDouble.');
|
||||
$table = $html->find('table table', 2);
|
||||
|
||||
foreach($table->find('tr') as $element)
|
||||
@ -26,17 +27,13 @@ class CopieDoubleBridge extends BridgeAbstract{
|
||||
elseif(strpos($element->innertext, "/images/suivant.gif") === false)
|
||||
{
|
||||
$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('href="/', 'href="'.$this->uri,$content);
|
||||
$content = str_replace('src="/', 'src="/'.self::URI,$element->find("td", 0)->innertext);
|
||||
$content = str_replace('href="/', 'href="'.self::URI,$content);
|
||||
$item['content'] = $content;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 14400; // 4 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
<?php
|
||||
class CourrierInternationalBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "teromene";
|
||||
public $name = "Courrier International Bridge";
|
||||
public $uri = "http://CourrierInternational.com/";
|
||||
public $description = "Courrier International bridge";
|
||||
const MAINTAINER = "teromene";
|
||||
const NAME = "Courrier International Bridge";
|
||||
const URI = "http://CourrierInternational.com/";
|
||||
const CACHE_TIMEOUT = 300; // 5 min
|
||||
const DESCRIPTION = "Courrier International bridge";
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Error.');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Error.');
|
||||
|
||||
$element = $html->find("article");
|
||||
|
||||
@ -22,17 +23,20 @@ class CourrierInternationalBridge extends BridgeAbstract{
|
||||
$item['uri'] = $article->parent->getAttribute("href");
|
||||
|
||||
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['title'] = strip_tags($article->find(".title")[0]);
|
||||
$item['content'] = sanitize($content);
|
||||
$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(
|
||||
$dateTime['hour'],
|
||||
@ -52,10 +56,6 @@ class CourrierInternationalBridge extends BridgeAbstract{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 300; // 5 minutes
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class CpasbienBridge extends HttpCachingBridgeAbstract{
|
||||
class CpasbienBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = "lagaisse";
|
||||
public $name = "Cpasbien Bridge";
|
||||
public $uri = "http://www.cpasbien.io";
|
||||
public $description = "Returns latest torrents from a request query";
|
||||
const MAINTAINER = "lagaisse";
|
||||
const NAME = "Cpasbien Bridge";
|
||||
const URI = "http://www.cpasbien.io";
|
||||
const CACHE_TIMEOUT = 86400; // 24h
|
||||
const DESCRIPTION = "Returns latest torrents from a request query";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'q'=>array(
|
||||
'name'=>'Search',
|
||||
'required'=>true,
|
||||
@ -16,19 +17,18 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{
|
||||
|
||||
public function collectData(){
|
||||
$request = str_replace(" ","-",trim($this->getInput('q')));
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($request).'.html')
|
||||
or $this->returnServerError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'/recherche/'.urlencode($request).'.html')
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
foreach ($html->find('#gauche',0)->find('div') as $episode) {
|
||||
if ($episode->getAttribute('class')=='ligne0' ||
|
||||
$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['author'] = $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);
|
||||
if (isset($textefiche)) {
|
||||
$item['content'] = $textefiche->text();
|
||||
@ -40,7 +40,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@ -48,10 +48,6 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{
|
||||
|
||||
|
||||
public function getName(){
|
||||
return $this->getInput('q').' : '.$this->name;
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 60*60*24; // 24 hours
|
||||
return $this->getInput('q').' : '.self::NAME;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class CryptomeBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "BoboTiG";
|
||||
public $name = "Cryptome";
|
||||
public $uri = "https://cryptome.org/";
|
||||
public $description = "Returns the N most recent documents.";
|
||||
const MAINTAINER = "BoboTiG";
|
||||
const NAME = "Cryptome";
|
||||
const URI = "https://cryptome.org/";
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns the N most recent documents.";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'n'=>array(
|
||||
'name'=>'number of elements',
|
||||
'type'=>'number',
|
||||
@ -16,26 +17,23 @@ class CryptomeBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request Cryptome.');
|
||||
if (!empty($this->getInput('n'))) { /* number of documents */
|
||||
$num = min($this->getInput('n'), 20);
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request Cryptome.');
|
||||
$number=$this->getInput('n');
|
||||
if (!empty($number)) { /* number of documents */
|
||||
$num = min($number, 20);
|
||||
}
|
||||
|
||||
|
||||
foreach($html->find('pre') as $element) {
|
||||
for ( $i = 0; $i < $num; ++$i ) {
|
||||
$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['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;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class DailymotionBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Dailymotion Bridge";
|
||||
public $uri = "https://www.dailymotion.com/";
|
||||
public $description = "Returns the 5 newest videos by username/playlist or search";
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Dailymotion Bridge";
|
||||
const URI = "https://www.dailymotion.com/";
|
||||
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(
|
||||
'u'=>array(
|
||||
'name'=>'username',
|
||||
@ -35,7 +36,7 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
|
||||
function getMetadata($id) {
|
||||
$metadata=array();
|
||||
$html2 = $this->getSimpleHTMLDOM($this->uri.'video/'.$id);
|
||||
$html2 = getSimpleHTMLDOM(self::URI.'video/'.$id);
|
||||
if(!$html2){
|
||||
return $metadata;
|
||||
}
|
||||
@ -52,8 +53,8 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
$limit = 5;
|
||||
$count = 0;
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||
or $this->returnServerError('Could not request Dailymotion.');
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request Dailymotion.');
|
||||
|
||||
foreach($html->find('div.media a.preview_link') as $element) {
|
||||
if($count < $limit) {
|
||||
@ -90,7 +91,7 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
$uri=$this->uri;
|
||||
$uri=self::URI;
|
||||
switch($this->queriedContext){
|
||||
case 'By username':
|
||||
$uri.='user/'
|
||||
@ -110,8 +111,4 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 3600*3; // 3 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +1,51 @@
|
||||
<?php
|
||||
class DanbooruBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Danbooru";
|
||||
public $uri = "http://donmai.us/";
|
||||
public $description = "Returns images from given page";
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Danbooru";
|
||||
const URI = "http://donmai.us/";
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
|
||||
public $parameters = array( array(
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
));
|
||||
const PARAMETERS = array(
|
||||
'global'=>array(
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'defaultValue'=>1,
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
),
|
||||
0=>array()
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
$page = $this->getInput('p')?$this->getInput('p'):1;
|
||||
$tags = urlencode($this->getInput('t'));
|
||||
const PATHTODATA='article';
|
||||
const IDATTRIBUTE='data-id';
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->uri."posts?&page=$page&tags=$tags")
|
||||
or $this->returnServerError('Could not request Danbooru.');
|
||||
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
|
||||
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(){
|
||||
$html = getSimpleHTMLDOM($this->getFullURI())
|
||||
or returnServerError('Could not request '.$this->getName());
|
||||
|
||||
foreach($html->find(static::PATHTODATA) as $element) {
|
||||
$this->items[] = $this->getItemFromElement($element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
<?php
|
||||
class DansTonChatBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "Astalaseven";
|
||||
public $name = "DansTonChat Bridge";
|
||||
public $uri = "http://danstonchat.com/";
|
||||
public $description = "Returns latest quotes from DansTonChat.";
|
||||
const MAINTAINER = "Astalaseven";
|
||||
const NAME = "DansTonChat Bridge";
|
||||
const URI = "http://danstonchat.com/";
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns latest quotes from DansTonChat.";
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'latest.html')
|
||||
or $this->returnServerError('Could not request DansTonChat.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'latest.html')
|
||||
or returnServerError('Could not request DansTonChat.');
|
||||
|
||||
foreach($html->find('div.item') as $element) {
|
||||
$item = array();
|
||||
@ -19,8 +20,4 @@ class DansTonChatBridge extends BridgeAbstract{
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class DauphineLibereBridge extends BridgeAbstract {
|
||||
class DauphineLibereBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "qwertygc";
|
||||
public $name = "Dauphine Bridge";
|
||||
public $uri = "http://www.ledauphine.com/";
|
||||
public $description = "Returns the newest articles.";
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Dauphine Bridge";
|
||||
const URI = "http://www.ledauphine.com/";
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'u'=>array(
|
||||
'name'=>'Catégorie de l\'article',
|
||||
'type'=>'list',
|
||||
@ -30,41 +31,27 @@ class DauphineLibereBridge extends BridgeAbstract {
|
||||
)
|
||||
));
|
||||
|
||||
private function ExtractContent($url, $context) {
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$text = $html2->find('div.column', 0)->innertext;
|
||||
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
|
||||
return $text;
|
||||
}
|
||||
public function collectData(){
|
||||
$url = self::URI . 'rss';
|
||||
|
||||
public function collectData(){
|
||||
if (empty($this->getInput('u'))) {
|
||||
$url = self::URI . $this->getInput('u') . '/rss';
|
||||
}
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
$this->collectExpandableDatas($url, 10);
|
||||
}
|
||||
|
||||
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;
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->ExtractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
private function ExtractContent($url) {
|
||||
$html2 = getSimpleHTMLDOMCached($url);
|
||||
$text = $html2->find('div.column', 0)->innertext;
|
||||
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
class DemoBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "teromene";
|
||||
public $name = "DemoBridge";
|
||||
public $uri = "http://github.com/rss-bridge/rss-bridge";
|
||||
public $description = "Bridge used for demos";
|
||||
const MAINTAINER = "teromene";
|
||||
const NAME = "DemoBridge";
|
||||
const URI = "http://github.com/rss-bridge/rss-bridge";
|
||||
const DESCRIPTION = "Bridge used for demos";
|
||||
|
||||
public $parameters = array(
|
||||
const PARAMETERS = array(
|
||||
'testCheckbox' => array(
|
||||
'testCheckbox'=>array(
|
||||
'type'=>'checkbox',
|
||||
@ -46,8 +46,4 @@ class DemoBridge extends BridgeAbstract{
|
||||
$this->items[] = $item;
|
||||
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 00; // 1 hour
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,21 @@
|
||||
<?php
|
||||
class DeveloppezDotComBridge extends BridgeAbstract{
|
||||
class DeveloppezDotComBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "polopollo";
|
||||
public $name = "Developpez.com Actus (FR)";
|
||||
public $uri = "http://www.developpez.com/";
|
||||
public $description = "Returns the 15 newest posts from DeveloppezDotCom (full text).";
|
||||
const MAINTAINER = "polopollo";
|
||||
const NAME = "Developpez.com Actus (FR)";
|
||||
const URI = "http://www.developpez.com/";
|
||||
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) {
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
@ -32,32 +43,9 @@ class DeveloppezDotComBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
private function DeveloppezDotComExtractContent($url) {
|
||||
$articleHTMLContent = $this->getSimpleHTMLDOM($url);
|
||||
$articleHTMLContent = getSimpleHTMLDOMCached($url);
|
||||
$text = $this->convert_smart_quotes($articleHTMLContent->find('div.content', 0)->innertext);
|
||||
$text = utf8_encode($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
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
class DilbertBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = 'kranack';
|
||||
public $name = 'Dilbert Daily Strip';
|
||||
public $uri = 'http://dilbert.com';
|
||||
public $description = 'The Unofficial Dilbert Daily Comic Strip';
|
||||
const MAINTAINER = 'kranack';
|
||||
const NAME = 'Dilbert Daily Strip';
|
||||
const URI = 'http://dilbert.com';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = 'The Unofficial Dilbert Daily Comic Strip';
|
||||
|
||||
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) {
|
||||
|
||||
@ -31,9 +32,5 @@ class DilbertBridge extends BridgeAbstract {
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,41 +1,11 @@
|
||||
<?php
|
||||
class DollbooruBridge extends BridgeAbstract{
|
||||
require_once('Shimmie2Bridge.php');
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Dollbooru";
|
||||
public $uri = "http://dollbooru.org/";
|
||||
public $description = "Returns images from given page";
|
||||
class DollbooruBridge extends Shimmie2Bridge{
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,34 @@
|
||||
<?php
|
||||
class DuckDuckGoBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "Astalaseven";
|
||||
public $name = "DuckDuckGo";
|
||||
public $uri = "https://duckduckgo.com/";
|
||||
public $description = "Returns most recent results from DuckDuckGo.";
|
||||
const MAINTAINER = "Astalaseven";
|
||||
const NAME = "DuckDuckGo";
|
||||
const URI = "https://duckduckgo.com/";
|
||||
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(
|
||||
'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(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'html/?q='.$this->getInput('u').'+sort:date')
|
||||
or $this->returnServerError('Could not request DuckDuckGo.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'html/?q='.$this->getInput('u').$this->getInput('sort'))
|
||||
or returnServerError('Could not request DuckDuckGo.');
|
||||
|
||||
foreach($html->find('div.results_links') as $element) {
|
||||
$item = array();
|
||||
@ -24,8 +38,4 @@ class DuckDuckGoBridge extends BridgeAbstract{
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
class EZTVBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "alexAubin";
|
||||
public $name = "EZTV";
|
||||
public $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 MAINTAINER = "alexAubin";
|
||||
const NAME = "EZTV";
|
||||
const URI = "https://eztv.ch/";
|
||||
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(
|
||||
'name'=>'Show ids',
|
||||
'exampleValue'=>'showID1,showID2,…',
|
||||
@ -34,8 +34,8 @@ class EZTVBridge extends BridgeAbstract{
|
||||
foreach($showList as $showID){
|
||||
|
||||
// Get show page
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'shows/'.rawurlencode($showID).'/')
|
||||
or $this->returnServerError('Could not request EZTV for id "'.$showID.'"');
|
||||
$html = getSimpleHTMLDOM(self::URI.'shows/'.rawurlencode($showID).'/')
|
||||
or returnServerError('Could not request EZTV for id "'.$showID.'"');
|
||||
|
||||
// Loop on each element that look like an episode entry...
|
||||
foreach($html->find('.forum_header_border') as $element) {
|
||||
@ -53,7 +53,7 @@ class EZTVBridge extends BridgeAbstract{
|
||||
|
||||
// Fill item
|
||||
$item = array();
|
||||
$item['uri'] = $this->uri.$epinfo->href;
|
||||
$item['uri'] = self::URI.$epinfo->href;
|
||||
$item['id'] = $item['uri'];
|
||||
$item['timestamp'] = makeTimestamp($released->plaintext);
|
||||
$item['title'] = $epinfo->plaintext;
|
||||
|
@ -1,20 +1,21 @@
|
||||
<?php
|
||||
class EliteDangerousGalnetBridge extends BridgeAbstract
|
||||
{
|
||||
public $maintainer = "corenting";
|
||||
public $name = "Elite: Dangerous Galnet";
|
||||
public $uri = "https://community.elitedangerous.com/galnet/";
|
||||
public $description = "Returns the latest page of news from Galnet";
|
||||
const MAINTAINER = "corenting";
|
||||
const NAME = "Elite: Dangerous Galnet";
|
||||
const URI = "https://community.elitedangerous.com/galnet/";
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Returns the latest page of news from Galnet";
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Error while downloading the website content');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Error while downloading the website content');
|
||||
foreach($html->find('div.article') as $element) {
|
||||
$item = array();
|
||||
|
||||
$uri = $element->find('h3 a', 0)->href;
|
||||
$uri = $this->uri . substr($uri,strlen('/galnet/'));
|
||||
$uri = self::URI . substr($uri,strlen('/galnet/'));
|
||||
$item['uri'] = $uri;
|
||||
|
||||
$title = $element->find('h3 a', 0)->plaintext;
|
||||
@ -31,9 +32,4 @@ class EliteDangerousGalnetBridge extends BridgeAbstract
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration()
|
||||
{
|
||||
return 3600 * 2; // 2 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class ElsevierBridge extends BridgeAbstract{
|
||||
public $maintainer = 'Pierre Mazière';
|
||||
public $name = 'Elsevier journals recent articles';
|
||||
public $uri = 'http://www.journals.elsevier.com/';
|
||||
public $description = 'Returns the recent articles published in Elsevier journals';
|
||||
const MAINTAINER = 'Pierre Mazière';
|
||||
const NAME = 'Elsevier journals recent articles';
|
||||
const URI = 'http://www.journals.elsevier.com/';
|
||||
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(
|
||||
'name'=>'Journal name',
|
||||
'required'=>true,
|
||||
@ -56,8 +57,8 @@ class ElsevierBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$uri = $this->uri . $this->getInput('j') . '/recent-articles/';
|
||||
$html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Elsevier journal '.$this->getInput('j'));
|
||||
$uri = self::URI . $this->getInput('j') . '/recent-articles/';
|
||||
$html = getSimpleHTMLDOM($uri) or returnServerError('No results for Elsevier journal '.$this->getInput('j'));
|
||||
|
||||
foreach($html->find('.pod-listing') as $article){
|
||||
$item = array();
|
||||
@ -69,9 +70,5 @@ class ElsevierBridge extends BridgeAbstract{
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 43200; // 12h
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
class EstCeQuonMetEnProdBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = 'ORelio';
|
||||
public $name = 'Est-ce qu\'on met en prod aujourd\'hui ?';
|
||||
public $uri = 'https://www.estcequonmetenprodaujourdhui.info/';
|
||||
public $description = 'Should we put a website in production today? (French)';
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'Est-ce qu\'on met en prod aujourd\'hui ?';
|
||||
const URI = 'https://www.estcequonmetenprodaujourdhui.info/';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = 'Should we put a website in production today? (French)';
|
||||
|
||||
public function collectData(){
|
||||
function ExtractFromDelimiters($string, $start, $end) {
|
||||
@ -15,7 +16,7 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract {
|
||||
} 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['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 />')));
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class FacebookBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "teromene";
|
||||
public $name = "Facebook";
|
||||
public $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 MAINTAINER = "teromene";
|
||||
const NAME = "Facebook";
|
||||
const URI = "https://www.facebook.com/";
|
||||
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(
|
||||
'name'=>'Username',
|
||||
'required'=>true
|
||||
@ -31,7 +32,7 @@ class FacebookBridge extends BridgeAbstract{
|
||||
if (is_array($matches) && count($matches) > 1) {
|
||||
$link = $matches[1];
|
||||
if (strpos($link, '/') === 0)
|
||||
$link = $this->uri.$link.'"';
|
||||
$link = self::URI.$link.'"';
|
||||
if (strpos($link, 'facebook.com/l.php?u=') !== false)
|
||||
$link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
|
||||
return ' href="'.$link.'"';
|
||||
@ -92,8 +93,8 @@ class FacebookBridge extends BridgeAbstract{
|
||||
),
|
||||
);
|
||||
$context = stream_context_create($http_options);
|
||||
$html = $this->getContents($captcha_action, false, $context);
|
||||
if ($html === FALSE) { $this->returnServerError('Failed to submit captcha response back to Facebook'); }
|
||||
$html = getContents($captcha_action, false, $context);
|
||||
if ($html === FALSE) { returnServerError('Failed to submit captcha response back to Facebook'); }
|
||||
unset($_SESSION['captcha_fields']);
|
||||
$html = str_get_html($html);
|
||||
}
|
||||
@ -104,11 +105,11 @@ class FacebookBridge extends BridgeAbstract{
|
||||
//Retrieve page contents
|
||||
if (is_null($html)) {
|
||||
if (!strpos($this->getInput('u'), "/")) {
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.urlencode($this->getInput('u')).'?_fb_noscript=1')
|
||||
or $this->returnServerError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1')
|
||||
or returnServerError('No results for this query.');
|
||||
} else {
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'pages/'.$this->getInput('u').'?_fb_noscript=1')
|
||||
or $this->returnServerError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'pages/'.$this->getInput('u').'?_fb_noscript=1')
|
||||
or returnServerError('No results for this query.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,10 +124,10 @@ class FacebookBridge extends BridgeAbstract{
|
||||
foreach ($captcha->find('input, button') as $input)
|
||||
$captcha_fields[$input->name] = $input->value;
|
||||
$_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
|
||||
$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('Content-Type: text/html');
|
||||
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")).'...';
|
||||
|
||||
//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['title'] = $title;
|
||||
$item['author'] = $author;
|
||||
@ -206,8 +207,4 @@ class FacebookBridge extends BridgeAbstract{
|
||||
public function getName() {
|
||||
return (isset($this->authorName) ? $this->authorName.' - ' : '').'Facebook Bridge';
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return 300; // 5 minutes
|
||||
}
|
||||
}
|
||||
|
62
bridges/FeedExpanderExampleBridge.php
Normal file
62
bridges/FeedExpanderExampleBridge.php
Normal 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') . '!');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +1,23 @@
|
||||
<?php
|
||||
class FierPandaBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = "snroki";
|
||||
public $name = "Fier Panda Bridge";
|
||||
public $uri = "http://www.fier-panda.fr/";
|
||||
public $description = "Returns latest articles from Fier Panda.";
|
||||
const MAINTAINER = "snroki";
|
||||
const NAME = "Fier Panda Bridge";
|
||||
const URI = "http://www.fier-panda.fr/";
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = "Returns latest articles from Fier Panda.";
|
||||
|
||||
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) {
|
||||
$item = array();
|
||||
$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
|
||||
$element->find('p a', 0)->outertext = '';
|
||||
$item['content'] = $element->find('p', 0)->innertext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
class FlickrExploreBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "sebsauvage";
|
||||
public $name = "Flickr Explore";
|
||||
public $uri = "https://www.flickr.com/";
|
||||
public $description = "Returns the latest interesting images from Flickr";
|
||||
const MAINTAINER = "sebsauvage";
|
||||
const NAME = "Flickr Explore";
|
||||
const URI = "https://www.flickr.com/";
|
||||
const CACHE_TIMEOUT = 21600; // 6
|
||||
const DESCRIPTION = "Returns the latest interesting images from Flickr";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'explore')
|
||||
or $this->returnServerError('Could not request Flickr.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'explore')
|
||||
or returnServerError('Could not request Flickr.');
|
||||
|
||||
foreach($html->find('.photo-list-photo-view') as $element) {
|
||||
// Get the styles
|
||||
@ -22,24 +23,20 @@ class FlickrExploreBridge extends BridgeAbstract{
|
||||
$imageID = reset($imageURIs);
|
||||
|
||||
// Get the image JSON via Flickr API
|
||||
$imageJSON = json_decode($this->getContents(
|
||||
$imageJSON = json_decode(getContents(
|
||||
'https://api.flickr.com/services/rest/?'
|
||||
.'method=flickr.photos.getInfo&'
|
||||
.'api_key=103b574d49bd51f0e18bfe907da44a0f&'
|
||||
.'photo_id='.$imageID.'&'
|
||||
.'format=json&'
|
||||
.'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['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['title'] = $imageJSON->photo->title->_content;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class FlickrTagBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "erwang";
|
||||
public $name = "Flickr TagUser";
|
||||
public $uri = "http://www.flickr.com/";
|
||||
public $description = "Returns the tagged or user images from Flickr";
|
||||
const MAINTAINER = "erwang";
|
||||
const NAME = "Flickr TagUser";
|
||||
const URI = "http://www.flickr.com/";
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns the tagged or user images from Flickr";
|
||||
|
||||
public $parameters = array(
|
||||
const PARAMETERS = array(
|
||||
'By keyword' => array(
|
||||
'q'=>array(
|
||||
'name'=>'keyword',
|
||||
@ -25,27 +26,23 @@ class FlickrTagBridge extends BridgeAbstract{
|
||||
public function collectData(){
|
||||
switch($this->queriedContext){
|
||||
case 'By keyword':
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'search/?q='.urlencode($this->getInput('q')).'&s=rec')
|
||||
or $this->returnServerError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'search/?q='.urlencode($this->getInput('q')).'&s=rec')
|
||||
or returnServerError('No results for this query.');
|
||||
break;
|
||||
case 'by username':
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'photos/'.urlencode($this->getInput('u')).'/')
|
||||
or $this->returnServerError('Requested username can\'t be found.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'photos/'.urlencode($this->getInput('u')).'/')
|
||||
or returnServerError('Requested username can\'t be found.');
|
||||
break;
|
||||
}
|
||||
|
||||
foreach($html->find('span.photo_container') as $element) {
|
||||
$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');
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; // FIXME: Filter javascript ?
|
||||
$item['title'] = $element->find('a',0)->title;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
class FootitoBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "superbaillot.net";
|
||||
public $name = "Footito";
|
||||
public $uri = "http://www.footito.fr/";
|
||||
public $description = "Footito";
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Footito";
|
||||
const URI = "http://www.footito.fr/";
|
||||
const DESCRIPTION = "Footito";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request Footito.');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request Footito.');
|
||||
|
||||
foreach($html->find('div.post') as $element) {
|
||||
$item = array();
|
||||
|
@ -1,42 +1,43 @@
|
||||
<?php
|
||||
class FourchanBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "4chan";
|
||||
public $uri = "https://www.4chan.org/";
|
||||
public $description = "Returns posts from the specified thread";
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "4chan";
|
||||
const URI = "https://boards.4chan.org/";
|
||||
const CACHE_TIMEOUT = 300; // 5min
|
||||
const DESCRIPTION = "Returns posts from the specified thread";
|
||||
|
||||
public $parameters = array( array(
|
||||
't'=>array(
|
||||
'name'=>'Thread URL',
|
||||
'pattern'=>'(https:\/\/)?boards\.4chan\.org\/.*thread\/.*',
|
||||
const PARAMETERS = array( array(
|
||||
'c'=>array(
|
||||
'name'=>'Thread category',
|
||||
'required'=>true
|
||||
)
|
||||
),
|
||||
't'=>array(
|
||||
'name'=>'Thread number',
|
||||
'type'=>'number',
|
||||
'required'=>true
|
||||
)
|
||||
));
|
||||
|
||||
public function getURI(){
|
||||
return static::URI.$this->getInput('c').'/thread/'.$this->getInput('t');
|
||||
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$thread = parse_url($this->getInput('t'))
|
||||
or $this->returnClientError('This URL seems malformed, please check it.');
|
||||
if($thread['host'] !== 'boards.4chan.org')
|
||||
$this->returnClientError('4chan thread URL only.');
|
||||
|
||||
if(strpos($thread['path'], 'thread/') === FALSE)
|
||||
$this->returnClientError('You must specify the thread URL.');
|
||||
|
||||
$url = 'https://boards.4chan.org'.$thread['path'];
|
||||
$html = $this->getSimpleHTMLDOM($url)
|
||||
or $this->returnServerError("Could not request 4chan, thread not found");
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError("Could not request 4chan, thread not found");
|
||||
|
||||
foreach($html->find('div.postContainer') as $element) {
|
||||
$item = array();
|
||||
$item['id'] = $element->find('.post', 0)->getAttribute('id');
|
||||
$item['uri'] = $url.'#'.$item['id'];
|
||||
$item['uri'] = $this->getURI().'#'.$item['id'];
|
||||
$item['timestamp'] = $element->find('span.dateTime', 0)->getAttribute('data-utc');
|
||||
$item['author'] = $element->find('span.name', 0)->plaintext;
|
||||
|
||||
|
||||
if(!empty($element->find('.file', 0) ) ) {
|
||||
$file=$element->find('.file', 0);
|
||||
if(!empty($file) ) {
|
||||
$item['image'] = $element->find('.file a', 0)->href;
|
||||
$item['imageThumb'] = $element->find('.file img', 0)->src;
|
||||
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 )) {
|
||||
$item['subject'] = $element->find('span.subject', 0)->innertext;
|
||||
}
|
||||
$item['title'] = (isset($item['subject']) ? $item['subject'].' - ' : '' ) . 'reply '.$item['id'].' | '.$item['author'];
|
||||
|
||||
$item['title'] = 'reply '.$item['id'].' | '.$item['author'];
|
||||
if(isset($item['subject'])){
|
||||
$item['title'] = $item['subject'].' - '.$item['title'];
|
||||
}
|
||||
|
||||
$item['content'] = (isset($item['image']) ? '<a href="'.$item['image'].'"><img alt="'.$item['id'].'" src="'.$item['imageThumb'].'" /></a><br>' : '') . '<span id="'.$item['id'].'">'.$element->find('.postMessage', 0)->innertext.'</span>';
|
||||
$content = $element->find('.postMessage', 0)->innertext;
|
||||
$content = str_replace('href="#p','href="'.$this->getURI().'#p',$content);
|
||||
$item['content'] = '<span id="'.$item['id'].'">'.$content.'</span>';
|
||||
if(isset($item['image'])){
|
||||
$item['content'] = '<a href="'.$item['image'].'">'
|
||||
.'<img alt="'.$item['id'].'" src="'.$item['imageThumb'].'" />'
|
||||
.'</a><br>'
|
||||
.$item['content'];
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
$this->items = array_reverse($this->items);
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 300; // 5min
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
class FuturaSciencesBridge extends BridgeAbstract {
|
||||
class FuturaSciencesBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = 'ORelio';
|
||||
public $name = 'Futura-Sciences Bridge';
|
||||
public $uri = 'http://www.futura-sciences.com/';
|
||||
public $description = 'Returns the newest articles.';
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'Futura-Sciences Bridge';
|
||||
const URI = 'http://www.futura-sciences.com/';
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'feed'=> array(
|
||||
'name'=>'Feed',
|
||||
'type'=>'list',
|
||||
@ -79,108 +79,88 @@ class FuturaSciencesBridge extends BridgeAbstract {
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$url = self::URI . 'rss/' . $this->getInput('feed') . '.xml';
|
||||
$this->collectExpandableDatas($url, 10);
|
||||
}
|
||||
|
||||
function StripCDATA($string) {
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
}
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['uri'] = str_replace('#xtor=RSS-8', '', $item['uri']);
|
||||
$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) {
|
||||
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));
|
||||
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 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Extracts the author from an article or element
|
||||
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;
|
||||
|
||||
foreach (array(
|
||||
'<div class="clear',
|
||||
'<div class="sharebar2',
|
||||
'<div class="diaporamafullscreen"',
|
||||
'<div style="margin-bottom:10px;" class="noprint"',
|
||||
'<div class="ficheprevnext',
|
||||
'<div class="bar noprint',
|
||||
'<div class="toolbar noprint',
|
||||
'<div class="addthis_toolbox',
|
||||
'<div class="noprint',
|
||||
'<div class="bg bglight border border-full noprint',
|
||||
'<div class="httplogbar-wrapper noprint',
|
||||
'<div id="forumcomments'
|
||||
) as $div_start) {
|
||||
$contents = StripRecursiveHTMLSection($contents , 'div', $div_start);
|
||||
}
|
||||
|
||||
$contents = StripWithDelimiters($contents, '<hr ', '/>');
|
||||
$contents = StripWithDelimiters($contents, '<p class="content-date', '</p>');
|
||||
$contents = StripWithDelimiters($contents, '<h1 class="content-title', '</h1>');
|
||||
$contents = StripWithDelimiters($contents, 'fs:definition="', '"');
|
||||
$contents = StripWithDelimiters($contents, 'fs:xt:clicktype="', '"');
|
||||
$contents = StripWithDelimiters($contents, 'fs:xt:clickname="', '"');
|
||||
|
||||
$item = array();
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
function ExtractArticleContent($article){
|
||||
$contents = $article->find('div.content', 0)->innertext;
|
||||
|
||||
foreach (array(
|
||||
'<div class="clear',
|
||||
'<div class="sharebar2',
|
||||
'<div class="diaporamafullscreen"',
|
||||
'<div style="margin-bottom:10px;" class="noprint"',
|
||||
'<div class="ficheprevnext',
|
||||
'<div class="bar noprint',
|
||||
'<div class="toolbar noprint',
|
||||
'<div class="addthis_toolbox',
|
||||
'<div class="noprint',
|
||||
'<div class="bg bglight border border-full noprint',
|
||||
'<div class="httplogbar-wrapper noprint',
|
||||
'<div id="forumcomments'
|
||||
) as $div_start) {
|
||||
$contents = $this->StripRecursiveHTMLSection($contents , 'div', $div_start);
|
||||
}
|
||||
|
||||
$contents = $this->StripWithDelimiters($contents, '<hr ', '/>');
|
||||
$contents = $this->StripWithDelimiters($contents, '<p class="content-date', '</p>');
|
||||
$contents = $this->StripWithDelimiters($contents, '<h1 class="content-title', '</h1>');
|
||||
$contents = $this->StripWithDelimiters($contents, 'fs:definition="', '"');
|
||||
$contents = $this->StripWithDelimiters($contents, 'fs:xt:clicktype="', '"');
|
||||
$contents = $this->StripWithDelimiters($contents, 'fs:xt:clickname="', '"');
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
// 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 '';
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
class GBAtempBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = 'ORelio';
|
||||
public $name = 'GBAtemp';
|
||||
public $uri = 'http://gbatemp.net/';
|
||||
public $description = 'GBAtemp is a user friendly underground video game community.';
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'GBAtemp';
|
||||
const URI = 'http://gbatemp.net/';
|
||||
const DESCRIPTION = 'GBAtemp is a user friendly underground video game community.';
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'type'=>array(
|
||||
'name'=>'Type',
|
||||
'type'=>'list',
|
||||
@ -54,7 +54,7 @@ class GBAtempBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
private function fetch_post_content($uri, $site_url) {
|
||||
$html = $this->getSimpleHTMLDOM($uri);
|
||||
$html = getSimpleHTMLDOM($uri);
|
||||
if(!$html){
|
||||
return 'Could not request GBAtemp '.$uri;
|
||||
}
|
||||
@ -65,24 +65,24 @@ class GBAtempBridge extends BridgeAbstract {
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request GBAtemp.');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request GBAtemp.');
|
||||
|
||||
switch($this->getInput('type')){
|
||||
case 'N':
|
||||
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="', '"'));
|
||||
$author = $newsItem->find('a.username', 0)->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);
|
||||
}
|
||||
case 'R':
|
||||
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;
|
||||
$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;
|
||||
$time = intval($this->ExtractFromDelimiters($content->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
|
||||
$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>';
|
||||
$procons = $content->find('table.review_procons', 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);
|
||||
}
|
||||
case 'T':
|
||||
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;
|
||||
$time = intval($this->ExtractFromDelimiters($tutorialItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
|
||||
$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);
|
||||
}
|
||||
case 'F':
|
||||
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;
|
||||
$time = intval($this->ExtractFromDelimiters($postItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
|
||||
$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);
|
||||
}
|
||||
}
|
||||
@ -117,13 +117,8 @@ class GBAtempBridge extends BridgeAbstract {
|
||||
public function getName() {
|
||||
$type=array_search(
|
||||
$this->getInput('type'),
|
||||
$this->parameters[$this->queriedContext]['type']['values']
|
||||
self::PARAMETERS[$this->queriedContext]['type']['values']
|
||||
);
|
||||
return 'GBAtemp '.$type.' Bridge';
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return ($this->filter === 'Forum') ? 300 : 3600; // 5 minutes / 1 hour
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,40 +1,21 @@
|
||||
<?php
|
||||
class GelbooruBridge extends BridgeAbstract{
|
||||
require_once('DanbooruBridge.php');
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Gelbooru";
|
||||
public $uri = "http://gelbooru.com/";
|
||||
public $description = "Returns images from given page";
|
||||
class GelbooruBridge extends DanbooruBridge{
|
||||
|
||||
public $parameters = array( array(
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
));
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Gelbooru";
|
||||
const URI = "http://gelbooru.com/";
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM(
|
||||
$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.');
|
||||
const PATHTODATA='.thumb';
|
||||
const IDATTRIBUTE='id';
|
||||
|
||||
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'] = 'Gelbooru | '.$item['postid'];
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
const PIDBYPAGE=63;
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 1800; // 30 minutes
|
||||
protected function getFullURI(){
|
||||
return $this->getURI().'index.php?page=post&s=list&'
|
||||
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*static::PIDBYPAGE:'')
|
||||
.'&tags='.urlencode($this->getInput('t'));
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,13 @@ define('GIPHY_LIMIT', 10);
|
||||
|
||||
class GiphyBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "kraoc";
|
||||
public $name = "Giphy Bridge";
|
||||
public $uri = "http://giphy.com/";
|
||||
public $description = "Bridge for giphy.com";
|
||||
const MAINTAINER = "kraoc";
|
||||
const NAME = "Giphy Bridge";
|
||||
const URI = "http://giphy.com/";
|
||||
const CACHE_TIMEOUT = 300; //5min
|
||||
const DESCRIPTION = "Bridge for giphy.com";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
's'=>array(
|
||||
'name'=>'search tag',
|
||||
'required'=>true
|
||||
@ -22,8 +23,8 @@ class GiphyBridge extends BridgeAbstract{
|
||||
public function collectData(){
|
||||
$html = '';
|
||||
$base_url = 'http://giphy.com';
|
||||
$html = $this->getSimpleHTMLDOM($this->uri.'/search/'.urlencode($this->getInput('s').'/'))
|
||||
or $this->returnServerError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM(self::URI.'/search/'.urlencode($this->getInput('s').'/'))
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
$max = GIPHY_LIMIT;
|
||||
if ($this->getInput('n')) {
|
||||
@ -37,8 +38,8 @@ class GiphyBridge extends BridgeAbstract{
|
||||
$node = $entry->first_child();
|
||||
$href = $node->getAttribute('href');
|
||||
|
||||
$html2 = $this->getSimpleHTMLDOM($this->uri . $href)
|
||||
or $this->returnServerError('No results for this query.');
|
||||
$html2 = getSimpleHTMLDOM(self::URI . $href)
|
||||
or returnServerError('No results for this query.');
|
||||
$figure = $html2->getElementByTagName('figure');
|
||||
$img = $figure->firstChild();
|
||||
$caption = $figure->lastChild();
|
||||
@ -67,8 +68,4 @@ class GiphyBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 300; // 5 minutes
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class GithubIssueBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = 'Pierre Mazière';
|
||||
public $name = 'Github Issue';
|
||||
public $uri = 'https://github.com/';
|
||||
public $description = 'Returns the issues or comments of an issue of a github project';
|
||||
const MAINTAINER = 'Pierre Mazière';
|
||||
const NAME = 'Github Issue';
|
||||
const URI = 'https://github.com/';
|
||||
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 (
|
||||
'u'=>array(
|
||||
'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(
|
||||
'i'=>array(
|
||||
'name'=>'Issue number',
|
||||
@ -28,46 +34,157 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||
)
|
||||
);
|
||||
|
||||
public function getName(){
|
||||
$name=$this->getInput('u').'/'.$this->getInput('p');
|
||||
switch($this->queriedContext){
|
||||
case 'Project Issues':
|
||||
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['author']=$author;
|
||||
$item['uri']= $uri.'#'.$comment->getAttribute('id');
|
||||
$item['title']=html_entity_decode($title,ENT_QUOTES,'UTF-8');
|
||||
$item['timestamp']=strtotime($comment->find('relative-time',0)->getAttribute('datetime'));
|
||||
$item['content']=$content;
|
||||
return $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(){
|
||||
$uri = $this->uri.$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'));
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('No results for Github Issue '.$this->getURI());
|
||||
|
||||
switch($this->queriedContext){
|
||||
case 'Issue Comments':
|
||||
foreach($html->find('.js-comment-container') as $comment){
|
||||
|
||||
$item = array();
|
||||
$item['author']=$comment->find('img',0)->getAttribute('alt');
|
||||
|
||||
$comment=$comment->firstChild()->nextSibling();
|
||||
|
||||
$item['uri']=$uri.'#'.$comment->getAttribute('id');
|
||||
$item['title']=trim($comment->firstChild()->plaintext);
|
||||
$item['timestamp']=strtotime($comment->find('relative-time',0)->getAttribute('datetime'));
|
||||
$item['content']=$comment->find('.comment-body',0)->innertext;
|
||||
|
||||
$this->items[]=$item;
|
||||
}
|
||||
case 'Issue comments':
|
||||
$this->items=$this->extractIssueComments($html);
|
||||
break;
|
||||
case 'Project Issues':
|
||||
foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue){
|
||||
$item=array();
|
||||
$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['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;
|
||||
$item['content']='Comments: '.($comments?$comments:'0');
|
||||
$item['uri']=$this->uri.$issue->find('.js-navigation-open',0)->getAttribute('href');
|
||||
$item['content'].="\n".'Comments: '.($comments?$comments:'0');
|
||||
$item['uri']=self::URI.$issue->find('.js-navigation-open',0)->getAttribute('href');
|
||||
$this->items[]=$item;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 600; // ten minutes
|
||||
array_walk($this->items, function(&$item){
|
||||
$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']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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
32
bridges/GizmodoBridge.php
Normal 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');
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -4,12 +4,13 @@ class GooglePlusPostBridge extends BridgeAbstract
|
||||
protected $_title;
|
||||
protected $_url;
|
||||
|
||||
public $maintainer = "Grummfy";
|
||||
public $name = "Google Plus Post Bridge";
|
||||
public $uri = "https://plus.google.com/";
|
||||
public $description = "Returns user public post (without API).";
|
||||
const MAINTAINER = "Grummfy";
|
||||
const NAME = "Google Plus Post Bridge";
|
||||
const URI = "https://plus.google.com/";
|
||||
const CACHE_TIMEOUT = 600; //10min
|
||||
const DESCRIPTION = "Returns user public post (without API).";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'username'=>array(
|
||||
'name'=>'username or Id',
|
||||
'required'=>true
|
||||
@ -19,13 +20,13 @@ class GooglePlusPostBridge extends BridgeAbstract
|
||||
public function collectData()
|
||||
{
|
||||
// get content parsed
|
||||
// $html = $this->getSimpleHTMLDOM(__DIR__ . '/../posts2.html'
|
||||
$html = $this->getSimpleHTMLDOM($this->uri . urlencode($this->getInput('username')) . '/posts'
|
||||
// $html = getSimpleHTMLDOM(__DIR__ . '/../posts2.html'
|
||||
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('username')) . '/posts'
|
||||
// force language
|
||||
, false, stream_context_create(array('http'=> array(
|
||||
'header' => 'Accept-Language: fr,fr-be,fr-fr;q=0.8,en;q=0.4,en-us;q=0.2;*' . "\r\n"
|
||||
)))
|
||||
) OR $this->returnServerError('No results for this query.');
|
||||
) OR returnServerError('No results for this query.');
|
||||
|
||||
// get title, url, ... there is a lot of intresting stuff in meta
|
||||
$this->_title = $html->find('meta[property]', 0)->getAttribute('content');
|
||||
@ -48,7 +49,7 @@ class GooglePlusPostBridge extends BridgeAbstract
|
||||
// $item['title'] = $item['fullname'] = $post->find('header.lea', 0)->plaintext;
|
||||
$item['avatar'] = $post->find('div.ys img', 0)->src;
|
||||
// var_dump((($post->find('a.o-U-s', 0)->getAllAttributes())));
|
||||
$item['uri'] = $this->uri . $post->find('a.o-U-s', 0)->href;
|
||||
$item['uri'] = self::URI . $post->find('a.o-U-s', 0)->href;
|
||||
$item['timestamp'] = strtotime($post->find('a.o-U-s', 0)->plaintext);
|
||||
$this->items[] = $item;
|
||||
|
||||
@ -56,21 +57,21 @@ class GooglePlusPostBridge extends BridgeAbstract
|
||||
$hashtags = array();
|
||||
foreach($post->find('a.d-s') as $hashtag)
|
||||
{
|
||||
$hashtags[ trim($hashtag->plaintext) ] = $this->uri . $hashtag->href;
|
||||
$hashtags[ trim($hashtag->plaintext) ] = self::URI . $hashtag->href;
|
||||
}
|
||||
|
||||
$item['content'] = '';
|
||||
|
||||
// avatar display
|
||||
$item['content'] .= '<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>';
|
||||
|
||||
$content = $post->find('div.Al', 0);
|
||||
|
||||
// alter link
|
||||
// $content = $content->innertext;
|
||||
// $content = str_replace('href="./', 'href="' . $this->uri, $content);
|
||||
// $content = str_replace('href="photos', 'href="' . $this->uri . 'photos', $content);
|
||||
// $content = str_replace('href="./', 'href="' . self::URI, $content);
|
||||
// $content = str_replace('href="photos', 'href="' . self::URI . 'photos', $content);
|
||||
// XXX ugly but I don't have any idea how to do a better stuff, str_replace on link doesn't work as expected and ask too many checks
|
||||
foreach($content->find('a') as $link)
|
||||
{
|
||||
@ -86,7 +87,7 @@ class GooglePlusPostBridge extends BridgeAbstract
|
||||
{
|
||||
$link->href = substr($link->href, 1);
|
||||
}
|
||||
$link->href = $this->uri . $link->href;
|
||||
$link->href = self::URI . $link->href;
|
||||
}
|
||||
}
|
||||
$content = $content->innertext;
|
||||
@ -107,11 +108,6 @@ class GooglePlusPostBridge extends BridgeAbstract
|
||||
|
||||
public function getURI()
|
||||
{
|
||||
return $this->_url ?: $this->uri;
|
||||
}
|
||||
|
||||
public function getCacheDuration()
|
||||
{
|
||||
return 1; // 600; // 10 minutes
|
||||
return $this->_url ?: self::URI;
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,13 @@
|
||||
*/
|
||||
class GoogleSearchBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "sebsauvage";
|
||||
public $name = "Google search";
|
||||
public $uri = "https://www.google.com/";
|
||||
public $description = "Returns most recent results from Google search.";
|
||||
const MAINTAINER = "sebsauvage";
|
||||
const NAME = "Google search";
|
||||
const URI = "https://www.google.com/";
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns most recent results from Google search.";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'q'=>array(
|
||||
'name'=>"keyword",
|
||||
'required'=>true
|
||||
@ -25,10 +26,10 @@ class GoogleSearchBridge extends BridgeAbstract{
|
||||
public function collectData(){
|
||||
$html = '';
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->uri
|
||||
$html = getSimpleHTMLDOM(self::URI
|
||||
.'search?q=' . urlencode($this->getInput('q'))
|
||||
.'&num=100&complete=0&tbs=qdr:y,sbd:1')
|
||||
or $this->returnServerError('No results for this query.');
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
$emIsRes = $html->find('div[id=ires]',0);
|
||||
if( !is_null($emIsRes) ){
|
||||
@ -50,8 +51,4 @@ class GoogleSearchBridge extends BridgeAbstract{
|
||||
public function getName(){
|
||||
return $this->getInput('q') .' - Google search';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 1800; // 30 minutes
|
||||
}
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class HDWallpapersBridge extends BridgeAbstract {
|
||||
public $maintainer = "nel50n";
|
||||
public $name = "HD Wallpapers Bridge";
|
||||
public $uri = "http://www.hdwallpapers.in/";
|
||||
public $description = "Returns the latests wallpapers from HDWallpapers";
|
||||
const MAINTAINER = "nel50n";
|
||||
const NAME = "HD Wallpapers Bridge";
|
||||
const URI = "http://www.hdwallpapers.in/";
|
||||
const CACHE_TIMEOUT = 43200; //12h
|
||||
const DESCRIPTION = "Returns the latests wallpapers from HDWallpapers";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'c'=>array(
|
||||
'name'=>'category',
|
||||
'defaultValue'=>'latest_wallpapers'
|
||||
@ -29,8 +30,8 @@ class HDWallpapersBridge extends BridgeAbstract {
|
||||
$lastpage = 1;
|
||||
|
||||
for ($page = 1; $page <= $lastpage; $page++) {
|
||||
$link = $this->uri.'/'.$category.'/page/'.$page;
|
||||
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.');
|
||||
$link = self::URI.'/'.$category.'/page/'.$page;
|
||||
$html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.');
|
||||
|
||||
if ($page === 1) {
|
||||
preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches);
|
||||
@ -42,10 +43,10 @@ class HDWallpapersBridge extends BridgeAbstract {
|
||||
|
||||
$item = array();
|
||||
// http://www.hdwallpapers.in/download/yosemite_reflections-1680x1050.jpg
|
||||
$item['uri'] = $this->uri.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href);
|
||||
$item['uri'] = self::URI.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href);
|
||||
$item['timestamp'] = time();
|
||||
$item['title'] = $element->find('p', 0)->text();
|
||||
$item['content'] = $item['title'].'<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;
|
||||
|
||||
$num++;
|
||||
@ -58,8 +59,4 @@ class HDWallpapersBridge extends BridgeAbstract {
|
||||
public function getName(){
|
||||
return 'HDWallpapers - '.str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')).' ['.$this->getInput('r').']';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 43200; // 12 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
class HentaiHavenBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "albirew";
|
||||
public $name = "Hentai Haven";
|
||||
public $uri = "http://hentaihaven.org/";
|
||||
public $description = "Returns releases from Hentai Haven";
|
||||
const MAINTAINER = "albirew";
|
||||
const NAME = "Hentai Haven";
|
||||
const URI = "http://hentaihaven.org/";
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = "Returns releases from Hentai Haven";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request Hentai Haven.');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request Hentai Haven.');
|
||||
foreach($html->find('div.zoe-grid') as $element) {
|
||||
$item = array();
|
||||
$item['uri'] = $element->find('div.brick-content h3 a', 0)->href;
|
||||
@ -19,8 +20,4 @@ class HentaiHavenBridge extends BridgeAbstract{
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class IdenticaBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Identica Bridge";
|
||||
public $uri = "https://identi.ca/";
|
||||
public $description = "Returns user timelines";
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Identica Bridge";
|
||||
const URI = "https://identi.ca/";
|
||||
const CACHE_TIMEOUT = 300; // 5min
|
||||
const DESCRIPTION = "Returns user timelines";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'u'=>array(
|
||||
'name'=>'username',
|
||||
'required'=>true
|
||||
@ -14,8 +15,8 @@ class IdenticaBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||
or $this->returnServerError('Requested username can\'t be found.');
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Requested username can\'t be found.');
|
||||
|
||||
foreach($html->find('li.major') as $dent) {
|
||||
$item = array();
|
||||
@ -32,10 +33,6 @@ class IdenticaBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
return $this->uri.urlencode($this->getInput('u'));
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 300; // 5 minutes
|
||||
return self::URI.urlencode($this->getInput('u'));
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
class InstagramBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "pauder";
|
||||
public $name = "Instagram Bridge";
|
||||
public $uri = "http://instagram.com/";
|
||||
public $description = "Returns the newest images";
|
||||
const MAINTAINER = "pauder";
|
||||
const NAME = "Instagram Bridge";
|
||||
const URI = "http://instagram.com/";
|
||||
const DESCRIPTION = "Returns the newest images";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'u'=>array(
|
||||
'name'=>'username',
|
||||
'required'=>true
|
||||
@ -14,8 +14,8 @@ class InstagramBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||
or $this->returnServerError('Could not request Instagram.');
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request Instagram.');
|
||||
|
||||
$innertext = null;
|
||||
|
||||
@ -46,7 +46,7 @@ class InstagramBridge extends BridgeAbstract{
|
||||
{
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $this->uri.'/p/'.$media->code.'/';
|
||||
$item['uri'] = self::URI.'p/'.$media->code.'/';
|
||||
$item['content'] = '<img src="' . htmlentities($media->display_src) . '" />';
|
||||
if (isset($media->caption))
|
||||
{
|
||||
@ -65,7 +65,7 @@ class InstagramBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
return $this->uri.urlencode($this->getInput('u'));
|
||||
return self::URI.urlencode($this->getInput('u'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class IsoHuntBridge extends BridgeAbstract{
|
||||
public $maintainer = 'logmanoriginal';
|
||||
public $name = 'isoHunt Bridge';
|
||||
public $uri = 'https://isohunt.to/';
|
||||
public $description = 'Returns the latest results by category or search result';
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'isoHunt Bridge';
|
||||
const URI = 'https://isohunt.to/';
|
||||
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
|
||||
* Notice: The categories "News" and "Top Searches" are received from the main page
|
||||
@ -90,7 +91,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
);
|
||||
|
||||
public function getURI(){
|
||||
$uri=$this->uri;
|
||||
$uri=self::URI;
|
||||
switch($this->queriedContext){
|
||||
case 'By "Latest" category':
|
||||
switch($this->getInput('latest_category')){
|
||||
@ -132,27 +133,27 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
$categoryName =
|
||||
array_search(
|
||||
$this->getInput('latest_category'),
|
||||
$this->parameters['By "Latest" category']['latest_category']['values']
|
||||
self::PARAMETERS['By "Latest" category']['latest_category']['values']
|
||||
);
|
||||
$name = 'Latest '.$categoryName.' - ' . $this->name;
|
||||
$name = 'Latest '.$categoryName.' - ' . self::NAME;
|
||||
break;
|
||||
|
||||
case 'By "Torrent" category':
|
||||
$categoryName =
|
||||
array_search(
|
||||
$this->getInput('torrent_category'),
|
||||
$this->parameters['By "Torrent" category']['torrent_category']['values']
|
||||
self::PARAMETERS['By "Torrent" category']['torrent_category']['values']
|
||||
);
|
||||
$name = 'Category: ' . $categoryName . ' - ' . $this->name;
|
||||
$name = 'Category: ' . $categoryName . ' - ' . self::NAME;
|
||||
break;
|
||||
|
||||
case 'Search torrent by name':
|
||||
$categoryName =
|
||||
array_search(
|
||||
$this->getInput('search_category'),
|
||||
$this->parameters['Search torrent by name']['search_category']['values']
|
||||
self::PARAMETERS['Search torrent by name']['search_category']['values']
|
||||
);
|
||||
$name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . $this->name;
|
||||
$name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . self::NAME;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -199,30 +200,26 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 300; // 5 minutes
|
||||
}
|
||||
|
||||
#region Helper functions for "Movie Torrents"
|
||||
|
||||
private function get_movie_torrents($html){
|
||||
$container = $html->find('div#w0', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find torrent container!');
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('article');
|
||||
if(!$torrents)
|
||||
$this->returnServerError('Unable to find torrents!');
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
foreach($torrents as $torrent){
|
||||
|
||||
$anchor = $torrent->find('a', 0);
|
||||
if(!$anchor)
|
||||
$this->returnServerError('Unable to find anchor!');
|
||||
returnServerError('Unable to find anchor!');
|
||||
|
||||
$date = $torrent->find('small', 0);
|
||||
if(!$date)
|
||||
$this->returnServerError('Unable to find date!');
|
||||
returnServerError('Unable to find date!');
|
||||
|
||||
$item = array();
|
||||
|
||||
@ -243,11 +240,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function get_latest_hot_torrents($html){
|
||||
$container = $html->find('div#serps', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find torrent container!');
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('tr');
|
||||
if(!$torrents)
|
||||
$this->returnServerError('Unable to find torrents!');
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
// Remove first element (header row)
|
||||
$torrents = array_slice($torrents, 1);
|
||||
@ -256,11 +253,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
|
||||
$cell = $torrent->find('td', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find cell!');
|
||||
returnServerError('Unable to find cell!');
|
||||
|
||||
$element = $cell->find('a', 0);
|
||||
if(!$element)
|
||||
$this->returnServerError('Unable to find element!');
|
||||
returnServerError('Unable to find element!');
|
||||
|
||||
$item = array();
|
||||
|
||||
@ -281,11 +278,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function get_latest_news($html){
|
||||
$container = $html->find('div#postcontainer', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find post container!');
|
||||
returnServerError('Unable to find post container!');
|
||||
|
||||
$posts = $container->find('div.index-post');
|
||||
if(!$posts)
|
||||
$this->returnServerError('Unable to find posts!');
|
||||
returnServerError('Unable to find posts!');
|
||||
|
||||
foreach($posts as $post){
|
||||
$item = array();
|
||||
@ -303,7 +300,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_news_extract_author($post){
|
||||
$author = $post->find('small', 0);
|
||||
if(!$author)
|
||||
$this->returnServerError('Unable to find author!');
|
||||
returnServerError('Unable to find author!');
|
||||
|
||||
// The author is hidden within a string like: 'Posted by {author} on {date}'
|
||||
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches);
|
||||
@ -314,7 +311,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_news_extract_timestamp($post){
|
||||
$date = $post->find('small', 0);
|
||||
if(!$date)
|
||||
$this->returnServerError('Unable to find date!');
|
||||
returnServerError('Unable to find date!');
|
||||
|
||||
// The date is hidden within a string like: 'Posted by {author} on {date}'
|
||||
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches);
|
||||
@ -332,7 +329,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_news_extract_title($post){
|
||||
$title = $post->find('a', 0);
|
||||
if(!$title)
|
||||
$this->returnServerError('Unable to find title!');
|
||||
returnServerError('Unable to find title!');
|
||||
|
||||
return $title->plaintext;
|
||||
}
|
||||
@ -340,7 +337,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_news_extract_uri($post){
|
||||
$uri = $post->find('a', 0);
|
||||
if(!$uri)
|
||||
$this->returnServerError('Unable to find uri!');
|
||||
returnServerError('Unable to find uri!');
|
||||
|
||||
return $uri->href;
|
||||
}
|
||||
@ -348,7 +345,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_news_extract_content($post){
|
||||
$content = $post->find('div', 0);
|
||||
if(!$content)
|
||||
$this->returnServerError('Unable to find content!');
|
||||
returnServerError('Unable to find content!');
|
||||
|
||||
// Remove <h2>...</h2> (title)
|
||||
foreach($content->find('h2') as $element){
|
||||
@ -370,11 +367,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function get_latest_torrents($html){
|
||||
$container = $html->find('div#serps', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find torrent container!');
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('tr[data-key]');
|
||||
if(!$torrents)
|
||||
$this->returnServerError('Unable to find torrents!');
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
foreach($torrents as $torrent){
|
||||
$item = array();
|
||||
@ -392,11 +389,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_torrents_extract_title($torrent){
|
||||
$cell = $torrent->find('td.title-row', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find title cell!');
|
||||
returnServerError('Unable to find title cell!');
|
||||
|
||||
$title = $cell->find('span', 0);
|
||||
if(!$title)
|
||||
$this->returnServerError('Unable to find title!');
|
||||
returnServerError('Unable to find title!');
|
||||
|
||||
return $title->plaintext;
|
||||
}
|
||||
@ -404,11 +401,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_torrents_extract_uri($torrent){
|
||||
$cell = $torrent->find('td.title-row', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find title cell!');
|
||||
returnServerError('Unable to find title cell!');
|
||||
|
||||
$uri = $cell->find('a', 0);
|
||||
if(!$uri)
|
||||
$this->returnServerError('Unable to find uri!');
|
||||
returnServerError('Unable to find uri!');
|
||||
|
||||
return $this->fix_relative_uri($uri->href);
|
||||
}
|
||||
@ -420,7 +417,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
|
||||
$user = $cell->find('a', 0);
|
||||
if(!$user)
|
||||
$this->returnServerError('Unable to find user!');
|
||||
returnServerError('Unable to find user!');
|
||||
|
||||
return $user->plaintext;
|
||||
}
|
||||
@ -428,7 +425,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
private function latest_torrents_extract_timestamp($torrent){
|
||||
$cell = $torrent->find('td.date-row', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find date cell!');
|
||||
returnServerError('Unable to find date cell!');
|
||||
|
||||
return strtotime('-' . $cell->plaintext, time());
|
||||
}
|
||||
@ -438,15 +435,15 @@ class IsoHuntBridge extends BridgeAbstract{
|
||||
#region Generic helper functions
|
||||
|
||||
private function load_html($uri){
|
||||
$html = $this->getSimpleHTMLDOM($uri);
|
||||
$html = getSimpleHTMLDOM($uri);
|
||||
if(!$html)
|
||||
$this->returnServerError('Unable to load ' . $uri . '!');
|
||||
returnServerError('Unable to load ' . $uri . '!');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function fix_relative_uri($uri){
|
||||
return preg_replace('/\//i', $this->uri, $uri, 1);
|
||||
return preg_replace('/\//i', self::URI, $uri, 1);
|
||||
}
|
||||
|
||||
private function build_category_uri($category, $order_popularity = false){
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||
class JapanExpoBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = 'Ginko';
|
||||
public $name = 'Japan Expo Actualités';
|
||||
public $uri = 'http://www.japan-expo-paris.com/fr/actualites';
|
||||
public $description = 'Returns most recent entries from Japan Expo actualités.';
|
||||
public $parameters = array( array(
|
||||
const MAINTAINER = 'Ginko';
|
||||
const NAME = 'Japan Expo Actualités';
|
||||
const URI = 'http://www.japan-expo-paris.com/fr/actualites';
|
||||
const CACHE_TIMEOUT = 14400; // 4h
|
||||
const DESCRIPTION = 'Returns most recent entries from Japan Expo actualités.';
|
||||
const PARAMETERS = array( array(
|
||||
'mode'=>array(
|
||||
'name'=>'Show full contents',
|
||||
'type'=>'checkbox',
|
||||
@ -42,8 +43,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||
}
|
||||
};
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request JapanExpo: '.$this->uri);
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request JapanExpo: '.self::URI);
|
||||
$fullcontent = $this->getInput('mode');
|
||||
$count = 0;
|
||||
|
||||
@ -59,10 +60,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||
if ($count >= 5) {
|
||||
break;
|
||||
}
|
||||
if($this->get_cached_time($url) <= strtotime('-24 hours'))
|
||||
$this->remove_from_cache($url);
|
||||
|
||||
$article_html = $this->get_cached($url) or $this->returnServerError('Could not request JapanExpo: '.$url);
|
||||
$article_html = getSimpleHTMLDOMCached('Could not request JapanExpo: '.$url);
|
||||
$header = $article_html->find('header.pageHeadBox', 0);
|
||||
$timestamp = strtotime($header->find('time', 0)->datetime);
|
||||
$title_html = $header->find('div.section', 0)->next_sibling();
|
||||
@ -87,8 +86,4 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 14400; // 4 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +1,11 @@
|
||||
<?php
|
||||
class KonachanBridge extends BridgeAbstract{
|
||||
require_once('MoebooruBridge.php');
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Konachan";
|
||||
public $uri = "http://konachan.com/";
|
||||
public $description = "Returns images from given page";
|
||||
class KonachanBridge extends MoebooruBridge {
|
||||
|
||||
public $parameters = array( array(
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'defaultValue'=>1,
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
));
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Konachan";
|
||||
const URI = "http://konachan.com/";
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM(
|
||||
$this->uri.'/post?'
|
||||
.'&page='.$this->getInput('p')
|
||||
.'&tags='.urlencode($this->getInput('t'))
|
||||
) or $this->returnServerError('Could not request Konachan.');
|
||||
|
||||
$input_json = explode('Post.register(', $html);
|
||||
foreach($input_json as $element)
|
||||
$data[] = preg_replace('/}\)(.*)/', '}', $element);
|
||||
unset($data[0]);
|
||||
|
||||
foreach($data as $datai) {
|
||||
$json = json_decode($datai, TRUE);
|
||||
$item = array();
|
||||
$item['uri'] = $this->uri.'/post/show/'.$json['id'];
|
||||
$item['postid'] = $json['id'];
|
||||
$item['timestamp'] = $json['created_at'];
|
||||
$item['imageUri'] = $json['file_url'];
|
||||
$item['title'] = 'Konachan | '.$json['id'];
|
||||
$item['content'] = '<a href="' . $item['imageUri'] . '"><img src="' . $json['preview_url'] . '" /></a><br>Tags: '.$json['tags'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 1800; // 30 minutes
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +1,22 @@
|
||||
<?php
|
||||
class KoreusBridge extends BridgeAbstract{
|
||||
class KoreusBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "pit-fgfjiudghdf";
|
||||
public $name = "Koreus";
|
||||
public $uri = "http://www.koreus.com/";
|
||||
public $description = "Returns the 5 newest posts from Koreus (full text)";
|
||||
const MAINTAINER = "pit-fgfjiudghdf";
|
||||
const NAME = "Koreus";
|
||||
const URI = "http://www.koreus.com/";
|
||||
const DESCRIPTION = "Returns the newest posts from Koreus (full text)";
|
||||
|
||||
private function KoreusStripCDATA($string) {
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
}
|
||||
protected function parseItem($item) {
|
||||
$item = parent::parseItem($item);
|
||||
|
||||
private function KoreusExtractContent($url) {
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$text = $html2->find('p[class=itemText]', 0)->innertext;
|
||||
$text = utf8_encode(preg_replace('/(Sur le m.+?)+$/i','',$text));
|
||||
return $text;
|
||||
$html = getSimpleHTMLDOMCached($item['uri']);
|
||||
$text = $html->find('p.itemText', 0)->innertext;
|
||||
$item['content'] = utf8_encode($text);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM('http://feeds.feedburner.com/Koreus-articles') or $this->returnServerError('Could not request Koreus.');
|
||||
$limit = 0;
|
||||
|
||||
foreach($html->find('item') as $element) {
|
||||
if($limit < 5) {
|
||||
$item = array();
|
||||
$item['title'] = $this->KoreusStripCDATA($element->find('title', 0)->innertext);
|
||||
$item['uri'] = $this->KoreusStripCDATA($element->find('guid', 0)->plaintext);
|
||||
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
|
||||
$item['content'] = $this->KoreusExtractContent($item['uri']);
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
$this->collectExpandableDatas('http://feeds.feedburner.com/Koreus-articles');
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
public $maintainer = "logmanoriginal";
|
||||
public $name = "Kununu Bridge";
|
||||
public $uri = "https://www.kununu.com/";
|
||||
public $description = "Returns the latest reviews for a company and site of your choice.";
|
||||
class KununuBridge extends BridgeAbstract {
|
||||
const MAINTAINER = "logmanoriginal";
|
||||
const NAME = "Kununu Bridge";
|
||||
const URI = "https://www.kununu.com/";
|
||||
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(
|
||||
'site'=>array(
|
||||
'name'=>'Site',
|
||||
@ -55,33 +56,33 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
break;
|
||||
}
|
||||
|
||||
return $this->uri.$site.'/'.$company.'/'.$section;
|
||||
return self::URI.$site.'/'.$company.'/'.$section;
|
||||
}
|
||||
|
||||
function getName(){
|
||||
$company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($this->getInput('company')))));
|
||||
return ($this->companyName?:$company).' - '.$this->name;
|
||||
return ($this->companyName?:$company).' - '.self::NAME;
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$full = $this->getInput('full');
|
||||
|
||||
// Load page
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI());
|
||||
$html = getSimpleHTMLDOM($this->getURI());
|
||||
if(!$html)
|
||||
$this->returnServerError('Unable to receive data from ' . $this->getURI() . '!');
|
||||
returnServerError('Unable to receive data from ' . $this->getURI() . '!');
|
||||
// Update name for this request
|
||||
$this->companyName = $this->extract_company_name($html);
|
||||
|
||||
// Find the section with all the panels (reviews)
|
||||
$section = $html->find('section.kununu-scroll-element', 0);
|
||||
if($section === false)
|
||||
$this->returnServerError('Unable to find panel section!');
|
||||
returnServerError('Unable to find panel section!');
|
||||
|
||||
// Find all articles (within the panels)
|
||||
$articles = $section->find('article');
|
||||
if($articles === false || empty($articles))
|
||||
$this->returnServerError('Unable to find articles!');
|
||||
returnServerError('Unable to find articles!');
|
||||
|
||||
// Go through all articles
|
||||
foreach($articles as $article){
|
||||
@ -101,15 +102,11 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 86400; // 1 day
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes relative URLs in the given text
|
||||
*/
|
||||
private function fix_url($text){
|
||||
return preg_replace('/href=(\'|\")\//i', 'href="'.$this->uri, $text);
|
||||
return preg_replace('/href=(\'|\")\//i', 'href="'.self::URI, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,11 +125,11 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
private function extract_company_name($html){
|
||||
$panel = $html->find('div.panel', 0);
|
||||
if($panel === false)
|
||||
$this->returnServerError('Cannot find panel for company name!');
|
||||
returnServerError('Cannot find panel for company name!');
|
||||
|
||||
$company_name = $panel->find('h1', 0);
|
||||
if($company_name === false)
|
||||
$this->returnServerError('Cannot find company name!');
|
||||
returnServerError('Cannot find company name!');
|
||||
|
||||
return $company_name->plaintext;
|
||||
}
|
||||
@ -144,7 +141,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
// They conviniently provide a time attribute for us :)
|
||||
$date = $article->find('time[itemprop=dtreviewed]', 0);
|
||||
if($date === false)
|
||||
$this->returnServerError('Cannot find article date!');
|
||||
returnServerError('Cannot find article date!');
|
||||
|
||||
return strtotime($date->datetime);
|
||||
}
|
||||
@ -155,7 +152,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
private function extract_article_rating($article){
|
||||
$rating = $article->find('span.rating', 0);
|
||||
if($rating === false)
|
||||
$this->returnServerError('Cannot find article rating!');
|
||||
returnServerError('Cannot find article rating!');
|
||||
|
||||
return $rating->getAttribute('aria-label');
|
||||
}
|
||||
@ -166,7 +163,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
private function extract_article_summary($article){
|
||||
$summary = $article->find('[itemprop=summary]', 0);
|
||||
if($summary === false)
|
||||
$this->returnServerError('Cannot find article summary!');
|
||||
returnServerError('Cannot find article summary!');
|
||||
|
||||
return strip_tags($summary->innertext);
|
||||
}
|
||||
@ -178,13 +175,13 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
// Notice: This first part is the same as in extract_article_summary!
|
||||
$summary = $article->find('[itemprop=summary]', 0);
|
||||
if($summary === false)
|
||||
$this->returnServerError('Cannot find article summary!');
|
||||
returnServerError('Cannot find article summary!');
|
||||
|
||||
$anchor = $summary->find('a', 0);
|
||||
if($anchor === false)
|
||||
$this->returnServerError('Cannot find article URI!');
|
||||
returnServerError('Cannot find article URI!');
|
||||
|
||||
return $this->uri . $anchor->href;
|
||||
return self::URI . $anchor->href;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,7 +191,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
// We need to parse the aside manually
|
||||
$aside = $article->find('aside', 0);
|
||||
if($aside === false)
|
||||
$this->returnServerError('Cannot find article author information!');
|
||||
returnServerError('Cannot find article author information!');
|
||||
|
||||
// Go through all h2 elements to find index of required span (I know... it's stupid)
|
||||
$author_position = 'Unknown';
|
||||
@ -214,7 +211,7 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
private function extract_article_description($article){
|
||||
$description = $article->find('div[itemprop=description]', 0);
|
||||
if($description === false)
|
||||
$this->returnServerError('Cannot find article description!');
|
||||
returnServerError('Cannot find article description!');
|
||||
|
||||
return $this->fix_url($description->innertext);
|
||||
}
|
||||
@ -224,17 +221,14 @@ class KununuBridge extends HttpCachingBridgeAbstract {
|
||||
*/
|
||||
private function extract_full_description($uri){
|
||||
// Load full article
|
||||
if($this->get_cached_time($uri) <= strtotime('-24 hours'))
|
||||
$this->remove_from_cache($uri);
|
||||
|
||||
$html = $this->get_cached($uri);
|
||||
$html = getSimpleHTMLDOMCached($uri);
|
||||
if($html === false)
|
||||
$this->returnServerError('Could not load full description!');
|
||||
returnServerError('Could not load full description!');
|
||||
|
||||
// Find the article
|
||||
$article = $html->find('article', 0);
|
||||
if($article === false)
|
||||
$this->returnServerError('Cannot find article!');
|
||||
returnServerError('Cannot find article!');
|
||||
|
||||
// Luckily they use the same layout for the review overview and full article pages :)
|
||||
return $this->extract_article_description($article);
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class LWNprevBridge extends BridgeAbstract{
|
||||
public $maintainer = 'Pierre Mazière';
|
||||
public $name = 'LWN Free Weekly Edition';
|
||||
public $uri = 'https://lwn.net/';
|
||||
public $description = 'LWN Free Weekly Edition available one week late';
|
||||
const MAINTAINER = 'Pierre Mazière';
|
||||
const NAME = 'LWN Free Weekly Edition';
|
||||
const URI = 'https://lwn.net/';
|
||||
const CACHE_TIMEOUT = 604800; // 1 week
|
||||
const DESCRIPTION = 'LWN Free Weekly Edition available one week late';
|
||||
|
||||
function getURI(){
|
||||
return $this->uri.'free/bigpage';
|
||||
return self::URI.'free/bigpage';
|
||||
}
|
||||
|
||||
private function jumpToNextTag(&$node){
|
||||
@ -32,8 +33,8 @@ class LWNprevBridge extends BridgeAbstract{
|
||||
public function collectData(){
|
||||
// Because the LWN page is written in loose HTML and not XHTML,
|
||||
// Simple HTML Dom is not accurate enough for the job
|
||||
$content=$this->getContents($this->getURI())
|
||||
or $this->returnServerError('No results for LWNprev');
|
||||
$content=getContents($this->getURI())
|
||||
or returnServerError('No results for LWNprev');
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
$html=new DOMDocument();
|
||||
@ -48,7 +49,7 @@ class LWNprevBridge extends BridgeAbstract{
|
||||
break;
|
||||
}
|
||||
}
|
||||
$realURI=$this->uri.$a->getAttribute('href');
|
||||
$realURI=self::URI.$a->getAttribute('href');
|
||||
$URICounter=0;
|
||||
|
||||
$edition=$html->getElementsByTagName('h1')->item(0)->textContent;
|
||||
@ -82,7 +83,7 @@ class LWNprevBridge extends BridgeAbstract{
|
||||
$h2FirstChild=$h2->firstChild;
|
||||
$this->jumpToNextTag($h2FirstChild);
|
||||
if($h2FirstChild->nodeName==='a'){
|
||||
$item['uri']=$this->uri.$h2FirstChild->getAttribute('href');
|
||||
$item['uri']=self::URI.$h2FirstChild->getAttribute('href');
|
||||
}else{
|
||||
$item['uri']=$realURI.'#'.$URICounter;
|
||||
}
|
||||
@ -140,8 +141,4 @@ class LWNprevBridge extends BridgeAbstract{
|
||||
$this->items[]=$item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 604800; // one week
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
<?php
|
||||
class LeBonCoinBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "16mhz";
|
||||
public $name = "LeBonCoin";
|
||||
public $uri = "http://www.leboncoin.fr/";
|
||||
public $description = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword .";
|
||||
const MAINTAINER = "16mhz";
|
||||
const NAME = "LeBonCoin";
|
||||
const URI = "http://www.leboncoin.fr/";
|
||||
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é'),
|
||||
'r'=>array(
|
||||
'name'=>'Région',
|
||||
'type'=>'list',
|
||||
'values'=>array(
|
||||
'Toute la France'=>'ile_de_france/occasions',
|
||||
'Alsace'=>'alsace',
|
||||
'Aquitaine'=>'aquitaine',
|
||||
'Auvergne'=>'auvergne',
|
||||
@ -142,11 +143,11 @@ class LeBonCoinBridge extends BridgeAbstract{
|
||||
$category='annonces';
|
||||
}
|
||||
|
||||
$html = $this->getSimpleHTMLDOM(
|
||||
$this->uri.$category.'/offres/' . $this->getInput('r') . '/?'
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI.$category.'/offres/' . $this->getInput('r') . '/?'
|
||||
.'f=a&th=1&'
|
||||
.'q=' . urlencode($this->getInput('k'))
|
||||
) or $this->returnServerError('Could not request LeBonCoin.');
|
||||
) or returnServerError('Could not request LeBonCoin.');
|
||||
|
||||
$list = $html->find('.tabsContent', 0);
|
||||
if($list === NULL) {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -1,63 +1,42 @@
|
||||
<?php
|
||||
class LeMondeInformatiqueBridge extends BridgeAbstract {
|
||||
class LeMondeInformatiqueBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "ORelio";
|
||||
public $name = "Le Monde Informatique";
|
||||
public $uri = "http://www.lemondeinformatique.fr/";
|
||||
public $description = "Returns the newest articles.";
|
||||
const MAINTAINER = "ORelio";
|
||||
const NAME = "Le Monde Informatique";
|
||||
const URI = "http://www.lemondeinformatique.fr/";
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
public function collectData(){
|
||||
|
||||
function StripCDATA($string) {
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
function StripWithDelimiters($string, $start, $end) {
|
||||
while (strpos($string, $start) !== false) {
|
||||
$section_to_remove = substr($string, strpos($string, $start));
|
||||
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
|
||||
$string = str_replace($section_to_remove, '', $string);
|
||||
} return $string;
|
||||
}
|
||||
|
||||
function CleanArticle($article_html) {
|
||||
$article_html = StripWithDelimiters($article_html, '<script', '</script>');
|
||||
$article_html = StripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>');
|
||||
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++;
|
||||
}
|
||||
}
|
||||
$this->collectExpandableDatas(self::URI . 'rss/rss.xml', 10);
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return 1800; // 30 minutes
|
||||
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) {
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
function StripWithDelimiters($string, $start, $end) {
|
||||
while (strpos($string, $start) !== false) {
|
||||
$section_to_remove = substr($string, strpos($string, $start));
|
||||
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
|
||||
$string = str_replace($section_to_remove, '', $string);
|
||||
} return $string;
|
||||
}
|
||||
|
||||
function CleanArticle($article_html) {
|
||||
$article_html = $this->StripWithDelimiters($article_html, '<script', '</script>');
|
||||
$article_html = $this->StripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>');
|
||||
return $article_html;
|
||||
}
|
||||
}
|
||||
|
70
bridges/LegifranceJOBridge.php
Normal file
70
bridges/LegifranceJOBridge.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
class LesJoiesDuCodeBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "superbaillot.net";
|
||||
public $name = "Les Joies Du Code";
|
||||
public $uri = "http://lesjoiesducode.fr/";
|
||||
public $description = "LesJoiesDuCode";
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Les Joies Du Code";
|
||||
const URI = "http://lesjoiesducode.fr/";
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "LesJoiesDuCode";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request LesJoiesDuCode.');
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request LesJoiesDuCode.');
|
||||
|
||||
foreach($html->find('div.blog-post') as $element) {
|
||||
$item = array();
|
||||
@ -43,8 +44,4 @@ class LesJoiesDuCodeBridge extends BridgeAbstract{
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 7200; // 2h hours
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +1,23 @@
|
||||
<?php
|
||||
class LichessBridge extends FeedExpander {
|
||||
|
||||
class LichessBridge extends HttpCachingBridgeAbstract
|
||||
{
|
||||
public $maintainer = 'AmauryCarrade';
|
||||
public $name = 'Lichess Blog';
|
||||
public $uri = 'http://fr.lichess.org/blog';
|
||||
public $description = 'Returns the 5 newest posts from the Lichess blog (full text)';
|
||||
const MAINTAINER = 'AmauryCarrade';
|
||||
const NAME = 'Lichess Blog';
|
||||
const URI = 'http://fr.lichess.org/blog';
|
||||
const DESCRIPTION = 'Returns the 5 newest posts from the Lichess blog (full text)';
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$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);
|
||||
|
||||
$item['content'] = $this->retrieve_lichess_post($item['uri']);
|
||||
|
||||
$this->items[] = $item;
|
||||
$posts_loaded++;
|
||||
}
|
||||
}
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas(self::URI . '.atom', 5);
|
||||
}
|
||||
|
||||
private function retrieve_lichess_post($blog_post_uri)
|
||||
{
|
||||
if($this->get_cached_time($blog_post_uri) <= strtotime('-24 hours'))
|
||||
$this->remove_from_cache($blog_post_uriuri);
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->retrieve_lichess_post($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
$blog_post_html = $this->get_cached($blog_post_uri);
|
||||
private function retrieve_lichess_post($blog_post_uri){
|
||||
$blog_post_html = getSimpleHTMLDOMCached($blog_post_uri);
|
||||
$blog_post_div = $blog_post_html->find('#lichess_blog', 0);
|
||||
|
||||
$post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class LinkedInCompanyBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "regisenguehard";
|
||||
public $name = "LinkedIn Company";
|
||||
public $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 MAINTAINER = "regisenguehard";
|
||||
const NAME = "LinkedIn Company";
|
||||
const URI = "https://www.linkedin.com/";
|
||||
const CACHE_TIMEOUT = 21600; //6
|
||||
const DESCRIPTION = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/<strong style=\"font-weight:bold;\">apple</strong>)";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'c'=>array(
|
||||
'name'=>'Company name',
|
||||
'required'=>true
|
||||
@ -15,10 +16,10 @@ class LinkedInCompanyBridge extends BridgeAbstract{
|
||||
|
||||
public function collectData(){
|
||||
$html = '';
|
||||
$link = $this->uri.'company/'.$this->getInput('c');
|
||||
$link = self::URI.'company/'.$this->getInput('c');
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($link)
|
||||
or $this->returnServerError('Could not request LinkedIn.');
|
||||
$html = getSimpleHTMLDOM($link)
|
||||
or returnServerError('Could not request LinkedIn.');
|
||||
|
||||
foreach($html->find('//*[@id="my-feed-post"]/li') as $element) {
|
||||
$title = $element->find('span.share-body', 0)->innertext;
|
||||
@ -32,8 +33,4 @@ class LinkedInCompanyBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +1,11 @@
|
||||
<?php
|
||||
class LolibooruBridge extends BridgeAbstract{
|
||||
require_once('MoebooruBridge.php');
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Lolibooru";
|
||||
public $uri = "http://lolibooru.moe/";
|
||||
public $description = "Returns images from given page and tags";
|
||||
class LolibooruBridge extends MoebooruBridge{
|
||||
|
||||
public $parameters = array( array(
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'defaultValue'=>1,
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
));
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Lolibooru";
|
||||
const URI = "https://lolibooru.moe/";
|
||||
const DESCRIPTION = "Returns images from given page and tags";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM(
|
||||
$this->uri.'post?'
|
||||
.'&page='.$this->getInput('p')
|
||||
.'&tags='.urlencode($this->getInput('t'))
|
||||
) or $this->returnServerError('Could not request Lolibooru.');
|
||||
|
||||
$input_json = explode('Post.register(', $html);
|
||||
foreach($input_json as $element)
|
||||
$data[] = preg_replace('/}\)(.*)/', '}', $element);
|
||||
unset($data[0]);
|
||||
|
||||
foreach($data as $datai) {
|
||||
$json = json_decode($datai, TRUE);
|
||||
$item = array();
|
||||
$item['uri'] = $this->uri.'post/show/'.$json['id'];
|
||||
$item['postid'] = $json['id'];
|
||||
$item['timestamp'] = $json['created_at'];
|
||||
$item['imageUri'] = $json['file_url'];
|
||||
$item['title'] = 'Lolibooru | '.$json['id'];
|
||||
$item['content'] = '<a href="' . $item['imageUri'] . '"><img src="' . $json['preview_url'] . '" /></a><br>Tags: '.$json['tags'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 1800; // 30 minutes
|
||||
}
|
||||
}
|
||||
|
@ -1,190 +1,229 @@
|
||||
<?php
|
||||
define('MANGAREADER_LIMIT', 10); // The default limit
|
||||
class MangareaderBridge extends BridgeAbstract{
|
||||
class MangareaderBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = "logmanoriginal";
|
||||
public $name = "Mangareader Bridge";
|
||||
public $uri = "http://www.mangareader.net/";
|
||||
public $description = "Returns the latest updates, popular mangas or manga updates (new chapters)";
|
||||
const MAINTAINER = "logmanoriginal";
|
||||
const NAME = "Mangareader Bridge";
|
||||
const URI = "http://www.mangareader.net/";
|
||||
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 popular mangas' => array(
|
||||
'category'=>array(
|
||||
'name'=>'Category',
|
||||
'type'=>'list',
|
||||
'required'=>true,
|
||||
'values'=>array(
|
||||
'All'=>'all',
|
||||
'Action'=>'action',
|
||||
'Adventure'=>'adventure',
|
||||
'Comedy'=>'comedy',
|
||||
'Demons'=>'demons',
|
||||
'Drama'=>'drama',
|
||||
'Ecchi'=>'ecchi',
|
||||
'Fantasy'=>'fantasy',
|
||||
'Gender Bender'=>'gender-bender',
|
||||
'Harem'=>'harem',
|
||||
'Historical'=>'historical',
|
||||
'Horror'=>'horror',
|
||||
'Josei'=>'josei',
|
||||
'Magic'=>'magic',
|
||||
'Martial Arts'=>'martial-arts',
|
||||
'Mature'=>'mature',
|
||||
'Mecha'=>'mecha',
|
||||
'Military'=>'military',
|
||||
'Mystery'=>'mystery',
|
||||
'One Shot'=>'one-shot',
|
||||
'Psychological'=>'psychological',
|
||||
'Romance'=>'romance',
|
||||
'School Life'=>'school-life',
|
||||
'Sci-Fi'=>'sci-fi',
|
||||
'Seinen'=>'seinen',
|
||||
'Shoujo'=>'shoujo',
|
||||
'Shoujoai'=>'shoujoai',
|
||||
'Shounen'=>'shounen',
|
||||
'Shounenai'=>'shounenai',
|
||||
'Slice of Life'=>'slice-of-life',
|
||||
'Smut'=>'smut',
|
||||
'Sports'=>'sports',
|
||||
'Super Power'=>'super-power',
|
||||
'Supernatural'=>'supernatural',
|
||||
'Tragedy'=>'tragedy',
|
||||
'Vampire'=>'vampire',
|
||||
'Yaoi'=>'yaoi',
|
||||
'Yuri'=>'yuri'
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'values' => array(
|
||||
'All' => 'all',
|
||||
'Action' => 'action',
|
||||
'Adventure' => 'adventure',
|
||||
'Comedy' => 'comedy',
|
||||
'Demons' => 'demons',
|
||||
'Drama' => 'drama',
|
||||
'Ecchi' => 'ecchi',
|
||||
'Fantasy' => 'fantasy',
|
||||
'Gender Bender' => 'gender-bender',
|
||||
'Harem' => 'harem',
|
||||
'Historical' => 'historical',
|
||||
'Horror' => 'horror',
|
||||
'Josei' => 'josei',
|
||||
'Magic' => 'magic',
|
||||
'Martial Arts' => 'martial-arts',
|
||||
'Mature' => 'mature',
|
||||
'Mecha' => 'mecha',
|
||||
'Military' => 'military',
|
||||
'Mystery' => 'mystery',
|
||||
'One Shot' => 'one-shot',
|
||||
'Psychological' => 'psychological',
|
||||
'Romance' => 'romance',
|
||||
'School Life' => 'school-life',
|
||||
'Sci-Fi' => 'sci-fi',
|
||||
'Seinen' => 'seinen',
|
||||
'Shoujo' => 'shoujo',
|
||||
'Shoujoai' => 'shoujoai',
|
||||
'Shounen' => 'shounen',
|
||||
'Shounenai' => 'shounenai',
|
||||
'Slice of Life' => 'slice-of-life',
|
||||
'Smut' => 'smut',
|
||||
'Sports' => 'sports',
|
||||
'Super Power' => 'super-power',
|
||||
'Supernatural' => 'supernatural',
|
||||
'Tragedy' => 'tragedy',
|
||||
'Vampire' => 'vampire',
|
||||
'Yaoi' => 'yaoi',
|
||||
'Yuri' => 'yuri'
|
||||
),
|
||||
'exampleValue'=>'All',
|
||||
'title'=>'Select your category'
|
||||
'exampleValue' => 'All',
|
||||
'title' => 'Select your category'
|
||||
)
|
||||
),
|
||||
'Get manga updates' => array(
|
||||
'path'=>array(
|
||||
'name'=>'Path',
|
||||
'required'=>true,
|
||||
'pattern'=>'[a-zA-Z0-9-_]*',
|
||||
'exampleValue'=>'bleach, umi-no-kishidan',
|
||||
'title'=>'URL part of desired manga'
|
||||
'path' => array(
|
||||
'name' => 'Path',
|
||||
'required' => true,
|
||||
'pattern' => '[a-zA-Z0-9-_]*',
|
||||
'exampleValue' => 'bleach, umi-no-kishidan',
|
||||
'title' => 'URL part of desired manga'
|
||||
),
|
||||
'limit'=>array(
|
||||
'name'=>'Limit',
|
||||
'type'=>'number',
|
||||
'exampleValue'=>10,
|
||||
'title'=>'Number of items to return [-1 returns all]'
|
||||
'limit' => array(
|
||||
'name' => 'Limit',
|
||||
'type' => 'number',
|
||||
'defaultValue' => 10,
|
||||
'title' => 'Number of items to return [-1 returns all]'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
private $request='';
|
||||
private $request = '';
|
||||
|
||||
public function collectData(){
|
||||
// We'll use the DOM parser for this as it makes navigation easier
|
||||
$html = $this->getContents($this->getURI());
|
||||
public function collectData(){
|
||||
// We'll use the DOM parser for this as it makes navigation easier
|
||||
$html = getContents($this->getURI());
|
||||
if(!$html){
|
||||
$this->returnClientError('Could not receive data for ' . $path . '!');
|
||||
returnClientError('Could not receive data for ' . $path . '!');
|
||||
}
|
||||
libxml_use_internal_errors(true);
|
||||
$doc = new DomDocument;
|
||||
@$doc->loadHTML($html);
|
||||
@$doc->loadHTML($html);
|
||||
libxml_clear_errors();
|
||||
|
||||
// Navigate via XPath
|
||||
$xpath = new DomXPath($doc);
|
||||
// Navigate via XPath
|
||||
$xpath = new DomXPath($doc);
|
||||
|
||||
$this->request = '';
|
||||
switch($this->queriedContext){
|
||||
case 'Get latest updates':
|
||||
$this->request = 'Latest updates';
|
||||
|
||||
// Query each item (consists of Manga + chapters)
|
||||
$nodes = $xpath->query("//*[@id='latestchapters']/table//td");
|
||||
|
||||
foreach ($nodes as $node){
|
||||
// Query the manga
|
||||
$manga = $xpath->query("a[@class='chapter']", $node)->item(0);
|
||||
|
||||
// Collect the chapters for each Manga
|
||||
$chapters = $xpath->query("a[@class='chaptersrec']", $node);
|
||||
|
||||
if (isset($manga) && $chapters->length >= 1){
|
||||
$item = array();
|
||||
$item['uri'] = $this->uri. htmlspecialchars($manga->getAttribute('href'));
|
||||
$item['title'] = htmlspecialchars($manga->nodeValue);
|
||||
|
||||
// Add each chapter to the feed
|
||||
$item['content'] = "";
|
||||
|
||||
foreach ($chapters as $chapter){
|
||||
if($item['content'] <> ""){
|
||||
$item['content'] .= "<br>";
|
||||
}
|
||||
$item['content'] .= "<a href='" .$this->uri. htmlspecialchars($chapter->getAttribute('href')) . "'>" . htmlspecialchars($chapter->nodeValue) . "</a>";
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
$this->get_latest_updates($xpath);
|
||||
break;
|
||||
|
||||
case 'Get popular mangas':
|
||||
// Find manga name within "Popular mangas for ..."
|
||||
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
|
||||
$this->request = substr($pagetitle, 0, strrpos($pagetitle, " -")); // "Popular mangas for ..."
|
||||
|
||||
// Query all mangas
|
||||
$mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
|
||||
|
||||
foreach ($mangas as $manga){
|
||||
|
||||
// The thumbnail is encrypted in a css-style...
|
||||
// format: "background-image:url('<the part which is actually interesting>')"
|
||||
$mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga)->item(0)->getAttribute('style');
|
||||
$thumbnail = substr($mangaimgelement, 22, strlen($mangaimgelement) - 24);
|
||||
|
||||
$item = array();
|
||||
$item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->nodeValue);
|
||||
$item['uri'] = $this->uri . $xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->getAttribute('href');
|
||||
$item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga)->item(0)->nodeValue);
|
||||
$item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga)->item(0)->nodeValue;
|
||||
$item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga)->item(0)->nodeValue);
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnail . '" alt="' . $item['title'] . '" /></a><p>' . $item['genre'] . '</p><p>' . $item['chaptercount'] . '</p>';
|
||||
$this->items[] = $item;
|
||||
}
|
||||
$this->request = substr($pagetitle, 0, strrpos($pagetitle, " -"));
|
||||
$this->get_popular_mangas($xpath);
|
||||
break;
|
||||
|
||||
case 'Get manga updates':
|
||||
$limit = $this->getInput('limit');
|
||||
if(empty($limit)){
|
||||
$limit = MANGAREADER_LIMIT;
|
||||
$limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue'];
|
||||
}
|
||||
|
||||
$this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")->item(0)->nodeValue;
|
||||
$this->request = $xpath->query(".//*[@id='mangaproperties']//*[@class='aname']")
|
||||
->item(0)
|
||||
->nodeValue;
|
||||
|
||||
$query = "(.//*[@id='listing']//tr)[position() > 1]";
|
||||
|
||||
if($limit !== -1){
|
||||
$query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - " . $limit . "]";
|
||||
}
|
||||
|
||||
$chapters = $xpath->query($query);
|
||||
|
||||
foreach ($chapters as $chapter){
|
||||
$item = array();
|
||||
$item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)->item(0)->nodeValue);
|
||||
$item['uri'] = $this->uri . $xpath->query("td[1]/a", $chapter)->item(0)->getAttribute('href');
|
||||
$item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)->item(0)->nodeValue);
|
||||
array_unshift($this->items, $item);
|
||||
}
|
||||
$this->get_manga_updates($xpath, $limit);
|
||||
break;
|
||||
}
|
||||
|
||||
// Return some dummy-data if no content available
|
||||
if(empty($this->items)){
|
||||
$item = array();
|
||||
$item['content'] = "<p>No updates available</p>";
|
||||
// Return some dummy-data if no content available
|
||||
if(empty($this->items)){
|
||||
$item = array();
|
||||
$item['content'] = "<p>No updates available</p>";
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_latest_updates($xpath){
|
||||
// Query each item (consists of Manga + chapters)
|
||||
$nodes = $xpath->query("//*[@id='latestchapters']/table//td");
|
||||
|
||||
foreach ($nodes as $node){
|
||||
// Query the manga
|
||||
$manga = $xpath->query("a[@class='chapter']", $node)->item(0);
|
||||
|
||||
// Collect the chapters for each Manga
|
||||
$chapters = $xpath->query("a[@class='chaptersrec']", $node);
|
||||
|
||||
if (isset($manga) && $chapters->length >= 1){
|
||||
$item = array();
|
||||
$item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href'));
|
||||
$item['title'] = htmlspecialchars($manga->nodeValue);
|
||||
|
||||
// Add each chapter to the feed
|
||||
$item['content'] = "";
|
||||
|
||||
foreach ($chapters as $chapter){
|
||||
if($item['content'] <> ""){
|
||||
$item['content'] .= "<br>";
|
||||
}
|
||||
$item['content'] .=
|
||||
"<a href='"
|
||||
. self::URI
|
||||
. htmlspecialchars($chapter->getAttribute('href'))
|
||||
. "'>"
|
||||
. htmlspecialchars($chapter->nodeValue)
|
||||
. "</a>";
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function get_popular_mangas($xpath){
|
||||
// Query all mangas
|
||||
$mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
|
||||
|
||||
foreach ($mangas as $manga){
|
||||
|
||||
// The thumbnail is encrypted in a css-style...
|
||||
// format: "background-image:url('<the part which is actually interesting>')"
|
||||
$mangaimgelement = $xpath->query(".//*[@class='imgsearchresults']", $manga)
|
||||
->item(0)
|
||||
->getAttribute('style');
|
||||
$thumbnail = substr($mangaimgelement, 22, strlen($mangaimgelement) - 24);
|
||||
|
||||
$item = array();
|
||||
$item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)
|
||||
->item(0)
|
||||
->nodeValue);
|
||||
$item['uri'] = self::URI . $xpath->query(".//*[@class='manga_name']//a", $manga)
|
||||
->item(0)
|
||||
->getAttribute('href');
|
||||
$item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga)
|
||||
->item(0)
|
||||
->nodeValue);
|
||||
$item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga)
|
||||
->item(0)
|
||||
->nodeValue;
|
||||
$item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga)
|
||||
->item(0)
|
||||
->nodeValue);
|
||||
$item['content'] = <<<EOD
|
||||
<a href="{$item['uri']}"><img src="{$thumbnail}" alt="{$item['title']}" /></a>
|
||||
<p>{$item['genre']}</p>
|
||||
<p>{$item['chaptercount']}</p>
|
||||
EOD;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_manga_updates($xpath, $limit){
|
||||
$query = "(.//*[@id='listing']//tr)[position() > 1]";
|
||||
|
||||
if($limit !== -1){
|
||||
$query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]";
|
||||
}
|
||||
|
||||
$chapters = $xpath->query($query);
|
||||
|
||||
foreach ($chapters as $chapter){
|
||||
$item = array();
|
||||
$item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)
|
||||
->item(0)
|
||||
->nodeValue);
|
||||
$item['uri'] = self::URI . $xpath->query("td[1]/a", $chapter)
|
||||
->item(0)
|
||||
->getAttribute('href');
|
||||
$item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)
|
||||
->item(0)
|
||||
->nodeValue);
|
||||
array_unshift($this->items, $item);
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
switch($this->queriedContext){
|
||||
@ -201,16 +240,12 @@ class MangareaderBridge extends BridgeAbstract{
|
||||
$path = $this->getInput('path');
|
||||
break;
|
||||
}
|
||||
return $this->uri . $path;
|
||||
return self::URI . $path;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 10800; // 3 hours
|
||||
}
|
||||
public function getName(){
|
||||
return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,39 +1,11 @@
|
||||
<?php
|
||||
class MilbooruBridge extends BridgeAbstract{
|
||||
require_once('Shimmie2Bridge.php');
|
||||
|
||||
class MilbooruBridge extends Shimmie2Bridge{
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Milbooru";
|
||||
public $uri = "http://sheslostcontrol.net/moe/shimmie/";
|
||||
public $description = "Returns images from given page";
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Milbooru";
|
||||
const URI = "http://sheslostcontrol.net/moe/shimmie/";
|
||||
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
|
||||
}
|
||||
}
|
||||
|
46
bridges/MoebooruBridge.php
Normal file
46
bridges/MoebooruBridge.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +1,23 @@
|
||||
<?php
|
||||
class MondeDiploBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "Pitchoule";
|
||||
public $name = 'Monde Diplomatique';
|
||||
public $uri = 'http://www.monde-diplomatique.fr/';
|
||||
public $description = "Returns most recent results from MondeDiplo.";
|
||||
const MAINTAINER = "Pitchoule";
|
||||
const NAME = 'Monde Diplomatique';
|
||||
const URI = 'http://www.monde-diplomatique.fr/';
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns most recent results from MondeDiplo.";
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->uri)
|
||||
or $this->returnServerError('Could not request MondeDiplo. for : ' . $this->uri);
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request MondeDiplo. for : ' . self::URI);
|
||||
|
||||
foreach($html->find('div.unarticle') as $article) {
|
||||
$element = $article->parent();
|
||||
$item = array();
|
||||
$item['uri'] = $this->uri . $element->href;
|
||||
$item['uri'] = self::URI . $element->href;
|
||||
$item['title'] = $element->find('h3', 0)->plaintext;
|
||||
$item['content'] = $element->find('div.dates_auteurs', 0)->plaintext . '<br>' . strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
<?php
|
||||
class MsnMondeBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "kranack";
|
||||
public $name = 'MSN Actu Monde';
|
||||
public $uri = 'http://www.msn.com/';
|
||||
public $description = "Returns the 10 newest posts from MSN Actualités (full text)";
|
||||
const MAINTAINER = "kranack";
|
||||
const NAME = 'MSN Actu Monde';
|
||||
const URI = 'http://www.msn.com/';
|
||||
const DESCRIPTION = "Returns the 10 newest posts from MSN Actualités (full text)";
|
||||
|
||||
public function getURI(){
|
||||
return $this->uri.'fr-fr/actualite/monde';
|
||||
return self::URI.'fr-fr/actualite/monde';
|
||||
}
|
||||
|
||||
private function MsnMondeExtractContent($url, &$item) {
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$html2 = getSimpleHTMLDOM($url);
|
||||
$item['content'] = $html2->find('#content', 0)->find('article', 0)->find('section', 0)->plaintext;
|
||||
$item['timestamp'] = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime);
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request MsnMonde.');
|
||||
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request MsnMonde.');
|
||||
$limit = 0;
|
||||
foreach($html->find('.smalla') as $article) {
|
||||
if($limit < 10) {
|
||||
$item = array();
|
||||
$item['title'] = utf8_decode($article->find('h4', 0)->innertext);
|
||||
$item['uri'] = $this->uri . utf8_decode($article->find('a', 0)->href);
|
||||
$item['uri'] = self::URI . utf8_decode($article->find('a', 0)->href);
|
||||
$this->MsnMondeExtractContent($item['uri'], $item);
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
|
@ -1,42 +1,12 @@
|
||||
<?php
|
||||
class MspabooruBridge extends BridgeAbstract{
|
||||
require_once('GelbooruBridge.php');
|
||||
|
||||
class MspabooruBridge extends GelbooruBridge{
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Mspabooru";
|
||||
public $uri = "http://mspabooru.com/";
|
||||
public $description = "Returns images from given page";
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Mspabooru";
|
||||
const URI = "http://mspabooru.com/";
|
||||
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.'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
|
||||
}
|
||||
const PIDBYPAGE=50;
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
class NasaApodBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "corenting";
|
||||
public $name = "NASA APOD Bridge";
|
||||
public $uri = "http://apod.nasa.gov/apod/";
|
||||
public $description = "Returns the 3 latest NASA APOD pictures and explanations";
|
||||
const MAINTAINER = "corenting";
|
||||
const NAME = "NASA APOD Bridge";
|
||||
const URI = "http://apod.nasa.gov/apod/";
|
||||
const CACHE_TIMEOUT = 43200; // 12h
|
||||
const DESCRIPTION = "Returns the 3 latest NASA APOD pictures and explanations";
|
||||
|
||||
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);
|
||||
|
||||
for($i = 0; $i < 3;$i++)
|
||||
@ -17,10 +18,10 @@ class NasaApodBridge extends BridgeAbstract{
|
||||
$item = array();
|
||||
|
||||
$uri_page = $html->find('a',$i + 3)->href;
|
||||
$uri = $this->uri.$uri_page;
|
||||
$uri = self::URI.$uri_page;
|
||||
$item['uri'] = $uri;
|
||||
|
||||
$picture_html = $this->getSimpleHTMLDOM($uri);
|
||||
$picture_html = getSimpleHTMLDOM($uri);
|
||||
$picture_html_string = $picture_html->innertext;
|
||||
|
||||
//Extract image and explanation
|
||||
@ -39,8 +40,4 @@ class NasaApodBridge extends BridgeAbstract{
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 3600*12; // 12 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +1,55 @@
|
||||
<?php
|
||||
class NeuviemeArtBridge extends BridgeAbstract {
|
||||
class NeuviemeArtBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "ORelio";
|
||||
public $name = '9ème Art Bridge';
|
||||
public $uri = "http://www.9emeart.fr/";
|
||||
public $description = "Returns the newest articles.";
|
||||
const MAINTAINER = "ORelio";
|
||||
const NAME = '9ème Art Bridge';
|
||||
const URI = "http://www.9emeart.fr/";
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
public function collectData(){
|
||||
private 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 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;
|
||||
}
|
||||
protected function parseItem($item){
|
||||
$item = parent::parseItem($item);
|
||||
|
||||
$feedUrl = $this->uri.'9emeart.rss';
|
||||
$html = $this->getSimpleHTMLDOM($feedUrl) or $this->returnServerError('Could not request 9eme Art: '.$feedUrl);
|
||||
$limit = 0;
|
||||
$article_html = getSimpleHTMLDOMCached($item['uri']);
|
||||
if(!$article_html){
|
||||
$item['content'] = 'Could not request 9eme Art: '.$item['uri'];
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($html->find('item') as $element) {
|
||||
if ($limit < 5) {
|
||||
$article_image = '';
|
||||
foreach ($article_html->find('img.img_full') as $img){
|
||||
if ($img->alt == $item['title']){
|
||||
$article_image = self::URI.$img->src;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Retrieve article Uri and get that page
|
||||
$article_uri = $element->find('guid', 0)->plaintext;
|
||||
$article_html = $this->getSimpleHTMLDOM($article_uri) or $this->returnServerError('Could not request 9eme Art: '.$article_uri);
|
||||
$article_content='';
|
||||
if($article_image){
|
||||
$article_content = '<p><img src="'.$article_image.'" /></p>';
|
||||
}
|
||||
$article_content .= str_replace(
|
||||
'src="/', 'src="'.self::URI,
|
||||
$article_html->find('div.newsGenerique_con', 0)->innertext
|
||||
);
|
||||
$article_content = $this->StripWithDelimiters($article_content, '<script', '</script>');
|
||||
$article_content = $this->StripWithDelimiters($article_content, '<style', '</style>');
|
||||
$article_content = $this->StripWithDelimiters($article_content, '<link', '>');
|
||||
|
||||
//Build article contents from corresponding elements
|
||||
$article_title = trim($element->find('title', 0)->plaintext);
|
||||
$article_image = $element->find('enclosure', 0)->url;
|
||||
foreach ($article_html->find('img.img_full') as $img)
|
||||
if ($img->alt == $article_title)
|
||||
$article_image = $this->uri.$img->src;
|
||||
$article_content = '<p><img src="'.$article_image.'" /></p>'
|
||||
.str_replace('src="/', 'src="'.$this->uri, $article_html->find('div.newsGenerique_con', 0)->innertext);
|
||||
$article_content = StripWithDelimiters($article_content, '<script', '</script>');
|
||||
$article_content = StripWithDelimiters($article_content, '<style', '</style>');
|
||||
$article_content = StripWithDelimiters($article_content, '<link', '>');
|
||||
$item['content'] = $article_content;
|
||||
|
||||
//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;
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$feedUrl = self::URI.'9emeart.rss';
|
||||
$this->collectExpandableDatas($feedUrl);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,23 @@
|
||||
<?php
|
||||
class NextInpactBridge extends BridgeAbstract {
|
||||
class NextInpactBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "qwertygc";
|
||||
public $name = "NextInpact Bridge";
|
||||
public $uri = "http://www.nextinpact.com/";
|
||||
public $description = "Returns the newest articles.";
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "NextInpact Bridge";
|
||||
const URI = "http://www.nextinpact.com/";
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
private function StripCDATA($string) {
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas(self::URI . 'rss/news.xml', 10);
|
||||
}
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->ExtractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function ExtractContent($url) {
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$html2 = getSimpleHTMLDOMCached($url);
|
||||
$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>'
|
||||
.'<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>';
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
class NextgovBridge extends BridgeAbstract {
|
||||
class NextgovBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = 'ORelio';
|
||||
public $name = 'Nextgov Bridge';
|
||||
public $uri = 'https://www.nextgov.com/';
|
||||
public $description = 'USA Federal technology news, best practices, and web 2.0 tools.';
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'Nextgov Bridge';
|
||||
const URI = 'https://www.nextgov.com/';
|
||||
const DESCRIPTION = 'USA Federal technology news, best practices, and web 2.0 tools.';
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'category'=>array(
|
||||
'name'=>'Category',
|
||||
'type'=>'list',
|
||||
@ -26,57 +26,45 @@ class NextgovBridge extends BridgeAbstract {
|
||||
));
|
||||
|
||||
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;
|
||||
}
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
|
||||
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;
|
||||
}
|
||||
$item['content'] = '';
|
||||
|
||||
$category = $this->getInput('category');
|
||||
$url = $this->getURI().'rss/'.$category.'/';
|
||||
$html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Nextgov: '.$url);
|
||||
$limit = 0;
|
||||
|
||||
foreach ($html->find('item') as $element) {
|
||||
if ($limit >= 10) {
|
||||
break;
|
||||
$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'] . '">';
|
||||
}
|
||||
|
||||
$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 = StripWithDelimiters($contents, '<div class="ad-container">', '</div>');
|
||||
$contents = StripWithDelimiters($contents, '<div', '</div>'); //ad outer div
|
||||
$contents = StripWithDelimiters($contents, '<script', '</script>');
|
||||
$contents = ($article_thumbnail == '' ? '' : '<p><img src="'.$article_thumbnail.'" /></p>')
|
||||
.'<p><b>'.$article_subtitle.'</b></p>'
|
||||
.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++;
|
||||
}
|
||||
|
||||
$item['content'] .= $this->ExtractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private 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;
|
||||
}
|
||||
|
||||
private function ExtractContent($url){
|
||||
$article = getSimpleHTMLDOMCached($url)
|
||||
or returnServerError('Could not request Nextgov: ' . $url);
|
||||
|
||||
$contents = $article->find('div.wysiwyg', 0)->innertext;
|
||||
$contents = $this->StripWithDelimiters($contents, '<div class="ad-container">', '</div>');
|
||||
$contents = $this->StripWithDelimiters($contents, '<div', '</div>'); //ad outer div
|
||||
return $this->StripWithDelimiters($contents, '<script', '</script>');
|
||||
$contents = ($article_thumbnail == '' ? '' : '<p><img src="'.$article_thumbnail.'" /></p>')
|
||||
.'<p><b>'.$article_subtitle.'</b></p>'
|
||||
.trim($contents);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,23 @@
|
||||
<?php
|
||||
class NiceMatinBridge extends BridgeAbstract{
|
||||
class NiceMatinBridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "pit-fgfjiudghdf";
|
||||
public $name = "NiceMatin";
|
||||
public $uri = "http://www.nicematin.com/";
|
||||
public $description = "Returns the 10 newest posts from NiceMatin (full text)";
|
||||
const MAINTAINER = "pit-fgfjiudghdf";
|
||||
const NAME = "NiceMatin";
|
||||
const URI = "http://www.nicematin.com/";
|
||||
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) {
|
||||
$html = $this->getSimpleHTMLDOM($url);
|
||||
$html = getSimpleHTMLDOMCached($url);
|
||||
if(!$html)
|
||||
return 'Could not acquire content from url: ' . $url . '!';
|
||||
|
||||
@ -19,29 +29,4 @@ class NiceMatinBridge extends BridgeAbstract{
|
||||
$text = strip_tags($text, '<p><a><img>');
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
<?php
|
||||
class NovelUpdatesBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "albirew";
|
||||
public $name = "Novel Updates";
|
||||
public $uri = "http://www.novelupdates.com/";
|
||||
public $description = "Returns releases from Novel Updates";
|
||||
public $parameters = array( array(
|
||||
const MAINTAINER = "albirew";
|
||||
const NAME = "Novel Updates";
|
||||
const URI = "http://www.novelupdates.com/";
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = "Returns releases from Novel Updates";
|
||||
const PARAMETERS = array( array(
|
||||
'n'=>array(
|
||||
'name'=>'Novel URL',
|
||||
'patterns'=>'http:\/\/www.novelupdates.com\/.*',
|
||||
'required'=>true
|
||||
'name'=>'Novel name as found in the url',
|
||||
'exampleValue'=>'spirit-realm',
|
||||
'required'=>true
|
||||
)
|
||||
));
|
||||
|
||||
private $seriesTitle='';
|
||||
|
||||
public function getURI(){
|
||||
return static::URI.'/series/'.$this->getInput('n').'/';
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$thread = parse_url($this->getInput('n'))
|
||||
or $this->returnClientError('This URL seems malformed, please check it.');
|
||||
if($thread['host'] !== 'www.novelupdates.com')
|
||||
$this->returnClientError('NovelUpdates URL only.');
|
||||
if(strpos($thread['path'], 'series/') === FALSE)
|
||||
$this->returnClientError('You must specify the novel URL.');
|
||||
$url = $this->uri.$thread['path'].'';
|
||||
$fullhtml = $this->getSimpleHTMLDOM($url) or $this->returnServerError("Could not request NovelUpdates, novel not found");
|
||||
$fullhtml = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request NovelUpdates, novel "'.$this->getInput('n').'" not found');
|
||||
|
||||
$this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext;
|
||||
// dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259
|
||||
// forcefully removes tbody
|
||||
@ -37,16 +37,16 @@ class NovelUpdatesBridge extends BridgeAbstract{
|
||||
$item['title'] = $element->find('td', 2)->find('a', 0)->plaintext;
|
||||
$item['team'] = $element->find('td', 1)->innertext;
|
||||
$item['timestamp'] = strtotime($element->find('td', 0)->plaintext);
|
||||
$item['content'] = '<a href="'.$item['uri'].'">'.$this->seriesTitle.' - '.$item['title'].'</a> by '.$item['team'].'<br><a href="'.$item['uri'].'">'.$fullhtml->find('div.seriesimg', 0)->innertext.'</a>';
|
||||
$item['content'] =
|
||||
'<a href="'.$item['uri'].'">'
|
||||
.$this->seriesTitle.' - '.$item['title']
|
||||
.'</a> by '.$item['team'].'<br>'
|
||||
.'<a href="'.$item['uri'].'">'.$fullhtml->find('div.seriesimg', 0)->innertext.'</a>';
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return (!empty($this->seriesTitle) ? $this->seriesTitle.' - ' : '') .'Novel Updates';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
return $this->seriesTitle. ' - ' . static::NAME;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -1,15 +1,17 @@
|
||||
<?php
|
||||
class OpenClassroomsBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "sebsauvage";
|
||||
public $name = "OpenClassrooms Bridge";
|
||||
public $uri = "https://openclassrooms.com/";
|
||||
public $description = "Returns latest tutorials from OpenClassrooms.";
|
||||
const MAINTAINER = "sebsauvage";
|
||||
const NAME = "OpenClassrooms Bridge";
|
||||
const URI = "https://openclassrooms.com/";
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = "Returns latest tutorials from OpenClassrooms.";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'u'=>array(
|
||||
'name'=>'Catégorie',
|
||||
'type'=>'list',
|
||||
'required'=>true,
|
||||
'values'=>array(
|
||||
'Arts & Culture'=>'arts',
|
||||
'Code'=>'code',
|
||||
@ -24,28 +26,21 @@ class OpenClassroomsBridge extends BridgeAbstract{
|
||||
)
|
||||
));
|
||||
|
||||
public function getURI(){
|
||||
return self::URI.'/courses?categories='.$this->getInput('u').'&'
|
||||
.'title=&sort=updatedAt+desc';
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
if (empty($this->getInput('u')))
|
||||
{
|
||||
$this->returnServerError('Error: You must chose a category.');
|
||||
}
|
||||
|
||||
$html = '';
|
||||
$link = 'https://openclassrooms.com/courses?categories='.$this->getInput('u').'&title=&sort=updatedAt+desc';
|
||||
|
||||
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request OpenClassrooms.');
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request OpenClassrooms.');
|
||||
|
||||
foreach($html->find('.courseListItem') as $element) {
|
||||
$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['content'] = $element->find('slidingItem__descriptionContent', 0)->plaintext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?php
|
||||
class ParuVenduImmoBridge extends BridgeAbstract
|
||||
{
|
||||
public $maintainer = "polo2ro";
|
||||
public $name = "Paru Vendu Immobilier";
|
||||
public $uri = "http://www.paruvendu.fr";
|
||||
public $description = "Returns the ads from the first page of search result.";
|
||||
const MAINTAINER = "polo2ro";
|
||||
const NAME = "Paru Vendu Immobilier";
|
||||
const URI = "http://www.paruvendu.fr";
|
||||
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(
|
||||
'name'=>'Minimal surface m²',
|
||||
'type'=>'number'
|
||||
@ -25,30 +26,8 @@ class ParuVenduImmoBridge extends BridgeAbstract
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$html = '';
|
||||
$num = 20;
|
||||
$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.');
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request paruvendu.');
|
||||
|
||||
foreach($html->find('div.annonce a') as $element) {
|
||||
|
||||
@ -71,7 +50,7 @@ class ParuVenduImmoBridge extends BridgeAbstract
|
||||
list($href) = explode('#', $element->href);
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $this->uri.$href;
|
||||
$item['uri'] = self::URI.$href;
|
||||
$item['title'] = $element->title;
|
||||
$item['content'] = $img.$desc.$price;
|
||||
$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(){
|
||||
$request='';
|
||||
if($this->getInput('minarea') &&
|
||||
!empty($this->getInput('minarea'))
|
||||
){
|
||||
$request .= ' '.$this->getInput('minarea').' m2';
|
||||
$minarea=$this->getInput('minarea');
|
||||
if(!empty($minarea)){
|
||||
$request .= ' '.$minarea.' m2';
|
||||
}
|
||||
if($this->getInput('lo') &&
|
||||
!empty($this->getInput('lo'))){
|
||||
$request .= ' In: '.$this->getInput('lo');
|
||||
$location=$this->getInput('lo');
|
||||
if(!empty($location)){
|
||||
$request .= ' In: '.$location;
|
||||
}
|
||||
return 'Paru Vendu Immobilier'.$request;
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 10800; // 3 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,76 +1,73 @@
|
||||
<?php
|
||||
class PickyWallpapersBridge extends BridgeAbstract {
|
||||
|
||||
private $category;
|
||||
private $subcategory;
|
||||
private $resolution;
|
||||
const MAINTAINER = "nel50n";
|
||||
const NAME = "PickyWallpapers Bridge";
|
||||
const URI = "http://www.pickywallpapers.com/";
|
||||
const CACHE_TIMEOUT = 43200; // 12h
|
||||
const DESCRIPTION = "Returns the latests wallpapers from PickyWallpapers";
|
||||
|
||||
public $maintainer = "nel50n";
|
||||
public $name = "PickyWallpapers Bridge";
|
||||
public $uri = "http://www.pickywallpapers.com/";
|
||||
public $description = "Returns the latests wallpapers from PickyWallpapers";
|
||||
|
||||
public $parameters = array( array(
|
||||
'c'=>array('name'=>'category'),
|
||||
const PARAMETERS = array( array(
|
||||
'c'=>array(
|
||||
'name'=>'category',
|
||||
'required'=>true
|
||||
),
|
||||
's'=>array('name'=>'subcategory'),
|
||||
'm'=>array(
|
||||
'name'=>'Max number of wallpapers',
|
||||
'defaultValue'=>12,
|
||||
'type'=>'number'
|
||||
),
|
||||
'r'=>array(
|
||||
'name'=>'resolution',
|
||||
'exampleValue'=>'1920x1200, 1680x1050,…',
|
||||
'defaultValue'=>'1920x1200',
|
||||
'pattern'=>'[0-9]{3,4}x[0-9]{3,4}'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
public function collectData(){
|
||||
$html = '';
|
||||
if (!$this->getInput('c')) {
|
||||
$this->returnClientError('You must specify at least a category (?c=...).');
|
||||
} else {
|
||||
$baseUri = 'http://www.pickywallpapers.com';
|
||||
$lastpage = 1;
|
||||
$num = 0;
|
||||
$max = $this->getInput('m');
|
||||
$resolution = $this->getInput('r'); // Wide wallpaper default
|
||||
|
||||
$this->category = $this->getInput('c');
|
||||
$this->subcategory = $this->getInput('s') ?: '';
|
||||
$this->resolution = $this->getInput('r') ?: '1920x1200'; // Wide wallpaper default
|
||||
for ($page = 1; $page <= $lastpage; $page++) {
|
||||
$html = getSimpleHTMLDOM($this->getURI().'/page-'.$page.'/')
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
$num = 0;
|
||||
$max = $this->getInput('m') ?: 12;
|
||||
$lastpage = 1;
|
||||
if ($page === 1) {
|
||||
preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches);
|
||||
$lastpage = min($matches[1], ceil($max/12));
|
||||
}
|
||||
|
||||
for ($page = 1; $page <= $lastpage; $page++) {
|
||||
$link = $baseUri.'/'.$this->resolution.'/'.$this->category.'/'.(!empty($this->subcategory)?$this->subcategory.'/':'').'page-'.$page.'/';
|
||||
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.');
|
||||
foreach($html->find('.items li img') as $element) {
|
||||
|
||||
if ($page === 1) {
|
||||
preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches);
|
||||
$lastpage = min($matches[1], ceil($max/12));
|
||||
}
|
||||
$item = array();
|
||||
$item['uri'] = str_replace('www', 'wallpaper', self::URI).'/'.$resolution.'/'.basename($element->src);
|
||||
$item['timestamp'] = time();
|
||||
$item['title'] = $element->alt;
|
||||
$item['content'] = $item['title'].'<br><a href="'.$item['uri'].'">'.$element.'</a>';
|
||||
$this->items[] = $item;
|
||||
|
||||
foreach($html->find('.items li img') as $element) {
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = str_replace('www', 'wallpaper', $baseUri).'/'.$this->resolution.'/'.basename($element->src);
|
||||
$item['timestamp'] = time();
|
||||
$item['title'] = $element->alt;
|
||||
$item['content'] = $item['title'].'<br><a href="'.$item['uri'].'">'.$element.'</a>';
|
||||
$this->items[] = $item;
|
||||
|
||||
$num++;
|
||||
if ($num >= $max)
|
||||
break 2;
|
||||
}
|
||||
$num++;
|
||||
if ($num >= $max)
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return 'PickyWallpapers - '.$this->category.(!empty($this->subcategory) ? ' > '.$this->subcategory : '').' ['.$this->resolution.']';
|
||||
public function getURI(){
|
||||
$subcategory = $this->getInput('s');
|
||||
$link = self::URI.$this->getInput('r').'/'.$this->getInput('c').'/'.$subcategory;
|
||||
return $link;
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 43200; // 12 hours
|
||||
public function getName(){
|
||||
$subcategory = $this->getInput('s');
|
||||
return 'PickyWallpapers - '.$this->getInput('c')
|
||||
.($subcategory? ' > '.$subcategory : '')
|
||||
.' ['.$this->getInput('r').']';
|
||||
}
|
||||
}
|
||||
|
@ -1,98 +1,121 @@
|
||||
<?php
|
||||
class PinterestBridge extends BridgeAbstract{
|
||||
class PinterestBridge extends BridgeAbstract {
|
||||
|
||||
private $username;
|
||||
private $board;
|
||||
private $query;
|
||||
const MAINTAINER = "pauder";
|
||||
const NAME = "Pinterest Bridge";
|
||||
const URI = "http://www.pinterest.com/";
|
||||
const DESCRIPTION = "Returns the newest images on a board";
|
||||
|
||||
public $maintainer = "pauder";
|
||||
public $name = "Pinterest Bridge";
|
||||
public $uri = "http://www.pinterest.com";
|
||||
public $description = "Returns the newest images on a board";
|
||||
const PARAMETERS = array(
|
||||
'By username and board' => array(
|
||||
'u' => array(
|
||||
'name' => 'username',
|
||||
'required' => true
|
||||
),
|
||||
'b' => array(
|
||||
'name' => 'board',
|
||||
'required' => true
|
||||
)
|
||||
),
|
||||
'From search' => array(
|
||||
'q' => array(
|
||||
'name' => 'Keyword',
|
||||
'required' => true
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public $parameters = array(
|
||||
'By username and board' => array(
|
||||
'u'=>array('name'=>'username'),
|
||||
'b'=>array('name'=>'board')
|
||||
),
|
||||
'From search' => array(
|
||||
'q'=>array('name'=>'Keyword')
|
||||
)
|
||||
);
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM($this->getURI());
|
||||
if(!$html){
|
||||
switch($this->queriedContext){
|
||||
case 'By username and board':
|
||||
returnServerError('Username and/or board not found');
|
||||
case 'From search':
|
||||
returnServerError('Could not request Pinterest.');
|
||||
}
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$html = '';
|
||||
if ($this->getInput('u') || $this->getInput('b')) {
|
||||
if($this->queriedContext === 'From search'){
|
||||
foreach($html->find('div.pinWrapper') as $div){
|
||||
$item = array();
|
||||
|
||||
if (empty($this->getInput('u')))
|
||||
{
|
||||
$this->returnClientError('You must specify a Pinterest username (?u=...).');
|
||||
}
|
||||
$a = $div->find('a.pinImageWrapper', 0);
|
||||
$img = $a->find('img', 0);
|
||||
|
||||
if (empty($this->getInput('b')))
|
||||
{
|
||||
$this->returnClientError('You must specify a Pinterest board for this username (?b=...).');
|
||||
}
|
||||
$item['uri'] = $this->getURI() . $a->getAttribute('href');
|
||||
$item['content'] = '<img src="'
|
||||
. htmlentities(str_replace('/236x/', '/736x/', $img->getAttribute('src')))
|
||||
. '" alt="" />';
|
||||
|
||||
$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);
|
||||
|
||||
$img = $a->find('img', 0);
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $this->getURI().$a->getAttribute('href');
|
||||
$item['content'] = '<img src="' . 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 = str_replace("\\", "", $avatar);
|
||||
|
||||
$username = $div->find('div.creditName', 0);
|
||||
$board = $div->find('div.creditTitle', 0);
|
||||
|
||||
$username = $div->find('div.creditName', 0);
|
||||
$board = $div->find('div.creditTitle', 0);
|
||||
$item['username'] = $username->innertext;
|
||||
$item['fullname'] = $board->innertext;
|
||||
$item['avatar'] = $avatar;
|
||||
|
||||
$item['username'] =$username->innertext;
|
||||
$item['fullname'] = $board->innertext;
|
||||
$item['avatar'] = $avatar;
|
||||
$item['content'] .= '<br /><img align="left" style="margin: 2px 4px;" src="'
|
||||
. htmlentities($item['avatar'])
|
||||
. '" /> <strong>'
|
||||
. $item['username']
|
||||
. '</strong>'
|
||||
. '<br />'
|
||||
. $item['fullname'];
|
||||
|
||||
$item['content'] .= '<br /><img align="left" style="margin: 2px 4px;" src="'.htmlentities($item['avatar']).'" /> <strong>'.$item['username'].'</strong>';
|
||||
$item['content'] .= '<br />'.$item['fullname'];
|
||||
}
|
||||
$item['title'] = $img->getAttribute('alt');
|
||||
$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!');
|
||||
|
||||
$item['title'] = $img->getAttribute('alt');
|
||||
$json = json_decode($container->innertext, true);
|
||||
|
||||
//$item['timestamp'] = $media->created_time;
|
||||
$this->items[] = $item;
|
||||
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;
|
||||
|
||||
public function getName(){
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->query))
|
||||
{
|
||||
return $this->query .' - Pinterest';
|
||||
} else {
|
||||
return $this->username .' - '. $this->board.' - Pinterest';
|
||||
}
|
||||
}
|
||||
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(){
|
||||
switch($this->queriedContext){
|
||||
case 'By username and board':
|
||||
$specific = $this->getInput('u') . '-' . $this->getInput('b');
|
||||
break;
|
||||
case 'From search':
|
||||
$specific = $this->getInput('q');
|
||||
break;
|
||||
}
|
||||
return $specific . ' - ' . self::NAME;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
<?php
|
||||
class PlanetLibreBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "pit-fgfjiudghdf";
|
||||
public $name = "PlanetLibre";
|
||||
public $uri = "http://www.planet-libre.org";
|
||||
public $description = "Returns the 5 newest posts from PlanetLibre (full text)";
|
||||
const MAINTAINER = "pit-fgfjiudghdf";
|
||||
const NAME = "PlanetLibre";
|
||||
const URI = "http://www.planet-libre.org";
|
||||
const DESCRIPTION = "Returns the 5 newest posts from PlanetLibre (full text)";
|
||||
|
||||
private function PlanetLibreExtractContent($url){
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$html2 = getSimpleHTMLDOM($url);
|
||||
$text = $html2->find('div[class="post-text"]', 0)->innertext;
|
||||
return $text;
|
||||
}
|
||||
|
||||
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;
|
||||
foreach($html->find('div.post') as $element) {
|
||||
if($limit < 5) {
|
||||
@ -27,8 +28,4 @@ class PlanetLibreBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 3600*2; // 1 hour
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class RTBFBridge extends BridgeAbstract {
|
||||
public $name = "RTBF Bridge";
|
||||
public $uri = "http://www.rtbf.be/auvio/emissions";
|
||||
public $description = "Returns the newest RTBF videos by series ID";
|
||||
public $maintainer = "Frenzie";
|
||||
const NAME = "RTBF Bridge";
|
||||
const URI = "http://www.rtbf.be/auvio/emissions/";
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns the newest RTBF videos by series ID";
|
||||
const MAINTAINER = "Frenzie";
|
||||
|
||||
public $parameters = array( array(
|
||||
const PARAMETERS = array( array(
|
||||
'c'=>array(
|
||||
'name'=>'series id',
|
||||
'exampleValue'=>9500,
|
||||
@ -18,35 +19,32 @@ class RTBFBridge extends BridgeAbstract {
|
||||
$limit = 10;
|
||||
$count = 0;
|
||||
|
||||
if ($this->getInput('c')) {
|
||||
$html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$this->getInput('c')) or $this->returnServerError('Could not request RTBF.');
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request RTBF.');
|
||||
|
||||
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
|
||||
if($count < $limit) {
|
||||
$item = array();
|
||||
$item['id'] = $element->getAttribute('data-id');
|
||||
$item['uri'] = 'http://www.rtbf.be/auvio/detail?id='.$item['id'];
|
||||
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
|
||||
$thumbnailUriLastSrc = end($thumbnailUriSrcSet);
|
||||
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
|
||||
$item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext);
|
||||
$item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
|
||||
$this->items[] = $item;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->returnClientError('You must specify a series id.');
|
||||
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
|
||||
if($count >= $limit) {
|
||||
break;
|
||||
}
|
||||
$item = array();
|
||||
$item['id'] = $element->getAttribute('data-id');
|
||||
$item['uri'] = self::URI.'detail?id='.$item['id'];
|
||||
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
|
||||
$thumbnailUriLastSrc = end($thumbnailUriSrcSet);
|
||||
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
|
||||
$item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext);
|
||||
$item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
|
||||
$this->items[] = $item;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
return self::URI.'detail?id='.$this->getInput('c');
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return (!empty($this->request) ? $this->request .' - ' : '') .'RTBF Bridge';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 21600; // 6 hours
|
||||
return $this->getInput('c') .' - RTBF Bridge';
|
||||
}
|
||||
}
|
||||
|
43
bridges/ReadComicsBridge.php
Normal file
43
bridges/ReadComicsBridge.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
class Releases3DSBridge extends BridgeAbstract {
|
||||
|
||||
public $maintainer = "ORelio";
|
||||
public $name = "3DS Scene Releases";
|
||||
public $uri = "http://www.3dsdb.com/";
|
||||
public $description = "Returns the newest scene releases.";
|
||||
const MAINTAINER = "ORelio";
|
||||
const NAME = "3DS Scene Releases";
|
||||
const URI = "http://www.3dsdb.com/";
|
||||
const CACHE_TIMEOUT = 10800; // 3h
|
||||
const DESCRIPTION = "Returns the newest scene releases.";
|
||||
|
||||
public function collectData(){
|
||||
|
||||
@ -32,88 +33,88 @@ class Releases3DSBridge extends BridgeAbstract {
|
||||
}
|
||||
}
|
||||
|
||||
$dataUrl = 'http://3dsdb.com/xml.php';
|
||||
$xml = $this->getContents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl);
|
||||
$dataUrl = self::URI.'xml.php';
|
||||
$xml = getContents($dataUrl) or returnServerError('Could not request 3dsdb: '.$dataUrl);
|
||||
$limit = 0;
|
||||
|
||||
foreach (array_reverse(explode('<release>', $xml)) as $element) {
|
||||
if ($limit < 5) {
|
||||
if (strpos($element, '</release>') !== false) {
|
||||
|
||||
$id = ExtractFromDelimiters($element, '<id>', '</id>');
|
||||
$name = ExtractFromDelimiters($element, '<name>', '</name>');
|
||||
$publisher = ExtractFromDelimiters($element, '<publisher>', '</publisher>');
|
||||
$region = ExtractFromDelimiters($element, '<region>', '</region>');
|
||||
$group = ExtractFromDelimiters($element, '<group>', '</group>');
|
||||
$imagesize = ExtractFromDelimiters($element, '<imagesize>', '</imagesize>');
|
||||
$serial = ExtractFromDelimiters($element, '<serial>', '</serial>');
|
||||
$titleid = ExtractFromDelimiters($element, '<titleid>', '</titleid>');
|
||||
$imgcrc = ExtractFromDelimiters($element, '<imgcrc>', '</imgcrc>');
|
||||
$filename = ExtractFromDelimiters($element, '<filename>', '</filename>');
|
||||
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
|
||||
$trimmedsize = ExtractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>');
|
||||
$firmware = ExtractFromDelimiters($element, '<firmware>', '</firmware>');
|
||||
$type = ExtractFromDelimiters($element, '<type>', '</type>');
|
||||
$card = ExtractFromDelimiters($element, '<card>', '</card>');
|
||||
|
||||
if (!empty($releasename)) {
|
||||
|
||||
//Retrieve cover art and short desc from IGN?
|
||||
$ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = '';
|
||||
$ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name);
|
||||
if ($ignResult = $this->getSimpleHTMLDOM($ignSearchUrl)) {
|
||||
$ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src;
|
||||
$ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext;
|
||||
$ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href;
|
||||
$ignDate = strtotime(trim($ignResult->find('span.publish-date', 0)->plaintext));
|
||||
$ignDescription = '<div><img src="'.$ignCoverArt.'" /></div><div>'.$ignDesc.' <a href="'.$ignLink.'">More at IGN</a></div>';
|
||||
}
|
||||
|
||||
//Main section : Release description from 3DS database
|
||||
$releaseDescription = '<h3>Release Details</h3>'
|
||||
.'<b>Release ID: </b>'.$id.'<br />'
|
||||
.'<b>Game Name: </b>'.$name.'<br />'
|
||||
.'<b>Publisher: </b>'.$publisher.'<br />'
|
||||
.'<b>Region: </b>'.$region.'<br />'
|
||||
.'<b>Group: </b>'.$group.'<br />'
|
||||
.'<b>Image size: </b>'.(intval($imagesize)/8).'MB<br />'
|
||||
.'<b>Serial: </b>'.$serial.'<br />'
|
||||
.'<b>Title ID: </b>'.$titleid.'<br />'
|
||||
.'<b>Image CRC: </b>'.$imgcrc.'<br />'
|
||||
.'<b>File Name: </b>'.$filename.'<br />'
|
||||
.'<b>Release Name: </b>'.$releasename.'<br />'
|
||||
.'<b>Trimmed size: </b>'.intval(intval($trimmedsize)/1048576).'MB<br />'
|
||||
.'<b>Firmware: </b>'.$firmware.'<br />'
|
||||
.'<b>Type: </b>'.TypeToString($type).'<br />'
|
||||
.'<b>Card: </b>'.CardToString($card).'<br />';
|
||||
|
||||
//Build search links section to facilitate release search using search engines
|
||||
$releaseNameEncoded = urlencode(str_replace(' ', '+', $releasename));
|
||||
$searchLinkGoogle = 'https://google.com/?q='.$releaseNameEncoded;
|
||||
$searchLinkDuckDuckGo = 'https://duckduckgo.com/?q='.$releaseNameEncoded;
|
||||
$searchLinkQwant = 'https://lite.qwant.com/?q='.$releaseNameEncoded.'&t=web';
|
||||
$releaseSearchLinks = '<h3>Search this release</h3><ul>'
|
||||
.'<li><a href="'.$searchLinkGoogle.'">Search using Google</a></li>'
|
||||
.'<li><a href="'.$searchLinkDuckDuckGo.'">Search using DuckDuckGo</a></li>'
|
||||
.'<li><a href="'.$searchLinkQwant.'">Search using Qwant</a></li>'
|
||||
.'</ul>';
|
||||
|
||||
//Build and add final item with the above three sections
|
||||
$item = array();
|
||||
$item['title'] = $name;
|
||||
$item['author'] = $publisher;
|
||||
$item['timestamp'] = $ignDate;
|
||||
$item['uri'] = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink;
|
||||
$item['content'] = $ignDescription.$releaseDescription.$releaseSearchLinks;
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
if ($limit >= 5) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (strpos($element, '</release>') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
|
||||
if (empty($releasename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = ExtractFromDelimiters($element, '<id>', '</id>');
|
||||
$name = ExtractFromDelimiters($element, '<name>', '</name>');
|
||||
$publisher = ExtractFromDelimiters($element, '<publisher>', '</publisher>');
|
||||
$region = ExtractFromDelimiters($element, '<region>', '</region>');
|
||||
$group = ExtractFromDelimiters($element, '<group>', '</group>');
|
||||
$imagesize = ExtractFromDelimiters($element, '<imagesize>', '</imagesize>');
|
||||
$serial = ExtractFromDelimiters($element, '<serial>', '</serial>');
|
||||
$titleid = ExtractFromDelimiters($element, '<titleid>', '</titleid>');
|
||||
$imgcrc = ExtractFromDelimiters($element, '<imgcrc>', '</imgcrc>');
|
||||
$filename = ExtractFromDelimiters($element, '<filename>', '</filename>');
|
||||
$trimmedsize = ExtractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>');
|
||||
$firmware = ExtractFromDelimiters($element, '<firmware>', '</firmware>');
|
||||
$type = ExtractFromDelimiters($element, '<type>', '</type>');
|
||||
$card = ExtractFromDelimiters($element, '<card>', '</card>');
|
||||
|
||||
//Retrieve cover art and short desc from IGN?
|
||||
$ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = '';
|
||||
$ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name);
|
||||
if ($ignResult = getSimpleHTMLDOM($ignSearchUrl)) {
|
||||
$ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src;
|
||||
$ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext;
|
||||
$ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href;
|
||||
$ignDate = strtotime(trim($ignResult->find('span.publish-date', 0)->plaintext));
|
||||
$ignDescription = '<div><img src="'.$ignCoverArt.'" /></div><div>'.$ignDesc.' <a href="'.$ignLink.'">More at IGN</a></div>';
|
||||
}
|
||||
|
||||
//Main section : Release description from 3DS database
|
||||
$releaseDescription = '<h3>Release Details</h3>'
|
||||
.'<b>Release ID: </b>'.$id.'<br />'
|
||||
.'<b>Game Name: </b>'.$name.'<br />'
|
||||
.'<b>Publisher: </b>'.$publisher.'<br />'
|
||||
.'<b>Region: </b>'.$region.'<br />'
|
||||
.'<b>Group: </b>'.$group.'<br />'
|
||||
.'<b>Image size: </b>'.(intval($imagesize)/8).'MB<br />'
|
||||
.'<b>Serial: </b>'.$serial.'<br />'
|
||||
.'<b>Title ID: </b>'.$titleid.'<br />'
|
||||
.'<b>Image CRC: </b>'.$imgcrc.'<br />'
|
||||
.'<b>File Name: </b>'.$filename.'<br />'
|
||||
.'<b>Release Name: </b>'.$releasename.'<br />'
|
||||
.'<b>Trimmed size: </b>'.intval(intval($trimmedsize)/1048576).'MB<br />'
|
||||
.'<b>Firmware: </b>'.$firmware.'<br />'
|
||||
.'<b>Type: </b>'.TypeToString($type).'<br />'
|
||||
.'<b>Card: </b>'.CardToString($card).'<br />';
|
||||
|
||||
//Build search links section to facilitate release search using search engines
|
||||
$releaseNameEncoded = urlencode(str_replace(' ', '+', $releasename));
|
||||
$searchLinkGoogle = 'https://google.com/?q='.$releaseNameEncoded;
|
||||
$searchLinkDuckDuckGo = 'https://duckduckgo.com/?q='.$releaseNameEncoded;
|
||||
$searchLinkQwant = 'https://lite.qwant.com/?q='.$releaseNameEncoded.'&t=web';
|
||||
$releaseSearchLinks = '<h3>Search this release</h3><ul>'
|
||||
.'<li><a href="'.$searchLinkGoogle.'">Search using Google</a></li>'
|
||||
.'<li><a href="'.$searchLinkDuckDuckGo.'">Search using DuckDuckGo</a></li>'
|
||||
.'<li><a href="'.$searchLinkQwant.'">Search using Qwant</a></li>'
|
||||
.'</ul>';
|
||||
|
||||
//Build and add final item with the above three sections
|
||||
$item = array();
|
||||
$item['title'] = $name;
|
||||
$item['author'] = $publisher;
|
||||
$item['timestamp'] = $ignDate;
|
||||
$item['uri'] = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink;
|
||||
$item['content'] = $ignDescription.$releaseDescription.$releaseSearchLinks;
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
return 10800; //3 hours
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
class ReporterreBridge extends BridgeAbstract{
|
||||
|
||||
public $maintainer = "nyutag";
|
||||
public $name = "Reporterre Bridge";
|
||||
public $uri = "http://www.reporterre.net/";
|
||||
public $description = "Returns the newest articles.";
|
||||
const MAINTAINER = "nyutag";
|
||||
const NAME = "Reporterre Bridge";
|
||||
const URI = "http://www.reporterre.net/";
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
private function ExtractContentReporterre($url) {
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$html2 = getSimpleHTMLDOM($url);
|
||||
|
||||
foreach($html2->find('div[style=text-align:justify]') as $e) {
|
||||
$text = $e->outertext;
|
||||
@ -17,14 +17,14 @@ class ReporterreBridge extends BridgeAbstract{
|
||||
unset ($html2);
|
||||
|
||||
// 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>');
|
||||
return $text;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
foreach($html->find('item') as $element) {
|
||||
|
@ -1,42 +1,22 @@
|
||||
<?php
|
||||
class Rue89Bridge extends BridgeAbstract{
|
||||
class Rue89Bridge extends FeedExpander {
|
||||
|
||||
public $maintainer = "pit-fgfjiudghdf";
|
||||
public $name = "Rue89";
|
||||
public $uri = "http://rue89.nouvelobs.com/";
|
||||
public $description = "Returns the 5 newest posts from Rue89 (full text)";
|
||||
const MAINTAINER = "pit-fgfjiudghdf";
|
||||
const NAME = "Rue89";
|
||||
const URI = "http://rue89.nouvelobs.com/";
|
||||
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";
|
||||
$datas = json_decode($this->getContents($url), true);
|
||||
|
||||
return $datas["node"];
|
||||
$url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($item['uri'], -8)) . "/full";
|
||||
$datas = json_decode(getContents($url), true);
|
||||
$item['content'] = $datas['node']['body'];
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->collectExpandableDatas('http://api.rue89.nouvelobs.com/feed');
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +1,12 @@
|
||||
<?php
|
||||
class Rule34Bridge extends BridgeAbstract{
|
||||
require_once('GelbooruBridge.php');
|
||||
|
||||
public $maintainer = "mitsukarenai";
|
||||
public $name = "Rule34";
|
||||
public $uri = "http://rule34.xxx/";
|
||||
public $description = "Returns images from given page";
|
||||
class Rule34Bridge extends GelbooruBridge{
|
||||
|
||||
public $parameters = array( array(
|
||||
'p'=>array(
|
||||
'name'=>'page',
|
||||
'type'=>'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
));
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Rule34";
|
||||
const URI = "http://rule34.xxx/";
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
|
||||
public function collectData(){
|
||||
$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
|
||||
}
|
||||
const PIDBYPAGE=50;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user