bridges: Fix coding styles

This commit is a squash of all commits that fix coding styles
for the new coding style policy.

[ABCTabsBridge] Fix coding style
[AcrimedBridge] Fix coding style
[AllocineFRBridge] Fix coding style
[AnimeUltimeBridge] Fix coding style
[Arte7Bridge] Fix coding style
[AskfmBridge] Fix coding style
[BandcampBridge] Fix coding style
[BastaBridge] Fix coding style
[BlaguesDeMerdeBridge] Fix coding style
[BooruprojectBridge] Fix coding style
[CADBridge] Fix coding style
[CNETBridge] Fix coding style
[CastorusBridge] Fix coding style
[CollegeDeFranceBridge] Fix coding style
[CommonDreamsBridge] Fix coding style
[CopieDoubleBridge] Fix coding style
[CourrierInternationalBridge] Fix coding style
[CpasbienBridge] Fix coding style
[CryptomeBridge] Fix coding style
[DailymotionBridge] Fix coding style
[DanbooruBridge] Fix coding style
[DansTonChatBridge] Fix coding style
[DauphineLibereBridge] Fix coding style
[DeveloppezDotComBridge] Fix coding style
[DemoBridge] Fix coding style
[DilbertBridge] Fix coding style
[DuckDuckGoBridge] Fix coding style
[DollbooruBridge] Fix coding style
[EliteDangerousGalnetBridge] Fix coding style
[ElsevierBridge] Fix coding style
[EstCeQuonMetEnProdBridge] Fix coding style
[EZTVBridge] Fix coding style
[FacebookBridge] Fix coding style
[FeedExpanderExampleBridge] Fix coding style
[FB2Bridge] Fix coding style
[FierPandaBridge] Fix coding style
[FlickrBridge] Fix coding style
[FootitoBridge] Fix coding style
[FourchanBridge] Fix coding style
[FuturaSciencesBridge] Fix coding style
[GBAtempBridge] Fix coding style
[GelbooruBridge] Fix coding style
[GiphyBridge] Fix coding style
[GithubIssueBridge] Fix coding style
[GizmodoBridge] Fix coding style
[GoComicsBridge] Fix coding style
[GooglePlusPostBridge] Fix coding style
[GoogleSearchBridge] Fix coding style
[HDWallpapersBridge] Fix coding style
[HentaiHavenBridge] Fix coding style
[IdenticaBridge] Fix coding style
[InstagramBridge] Fix coding style
[IsoHuntBridge] Fix coding style
[JapanExpoBridge] Fix coding style
[KonachanBridge] Fix coding style
[KoreusBridge] Fix coding style
[KununuBridge] Fix coding style
[LeBonCoinBridge] Fix coding style
[LegifranceJOBBridge] Fix coding style
[LeMondeInformatiqueBridge] Fix coding style
[LesJoiesDuCodeBridge] Fix coding style
[LichessBridge] Fix coding style
[LinkedInCompanyBridge] Fix coding style
[LolibooruBridge] Fix coding style
[LWNprevBridge] Fix coding style
[MangareaderBridge] Fix coding style
[MilbooruBridge] Fix coding style
[MixCloudBridge] Fix coding style
[MoebooruBridge] Fix coding style
[MondeDiploBridge] Fix coding style
[MsnMondeBridge] Fix coding style
[MspabooruBridge] Fix coding style
[NasaApodBridge] Fix coding style
[NeuviemeArtBridge] Fix coding style
[NextgovBridge] Fix coding style
[NextInpactBridge] Fix coding style
[NiceMatinBridge] Fix coding style
[NovelUpdatesBridge] Fix coding style
[OpenClassroomsBridge] Fix coding style
[ParuVenduImmoBridge] Fix coding style
[PickyWallpapersBridge] Fix coding style
[PinterestBridge] Fix coding style
[PlanetLibreBridge] Fix coding style
[ReadComicsBridge] Fix coding style
[Releases3DSBridge] Fix coding style
[ReporterreBridge] Fix coding style
[RTBFBridge] Fix coding style
[Rue89Bridge] Fix coding style
[Rule34Bridge] Fix coding style
[Rule34pahealBridge] Fix coding style
[SafebooruBridge] Fix coding style
[SakugabooruBridge] Fix coding style
[ScmbBridge] Fix coding style
[ScoopItBridge] Fix coding style
[SensCritiqueBridge] Fix coding style
[SexactuBridge] Fix coding style
[ShanaprojectBridge] Fix coding style
[Shimmie2Bridge] Fix coding style
[SoundcloudBridge] Fix coding style
[StripeAPIChangeLogBridge] Fix coding style
[SuperbWallpapersBridge] Fix coding style
[T411Bridge] Fix coding style
[TagBoardBridge] Fix coding style
[TbibBridge] Fix coding style
[TheCodingLoveBridge] Fix coding style
[TheHackerNewsBridge] Fix coding style
[ThePirateBayBridge] Fix coding style
[TheTVDBBridge] Fix coding style
[Torrent9Bridge] Fix coding style
[TwitterBridge] Fix coding style
[UnsplashBridge] Fix coding style
[ViadeoCompanyBridge] Fix coding style
[VineBridge] Fix coding style
[VkBridge] Fix coding style
[WallpaperStopBridge] Fix coding style
[WebfailBridge] Fix coding style
[WeLiveSecurityBridge] Fix coding style
[WhydBridge] Fix coding style
[WikipediaBridge] Fix coding style
[WordPressBridge] Fix coding style
[WorldOfTanksBridge] Fix coding style
[XbooruBridge] Fix coding style
[YandereBridge] Fix coding style
[YoutubeBridge] Fix coding style
[ZDNetBridge] Fix coding style
This commit is contained in:
logmanoriginal 2017-02-11 16:16:56 +01:00
parent 22a7666d2b
commit 6f24858124
125 changed files with 6689 additions and 5961 deletions

View file

@ -1,25 +1,43 @@
<?php <?php
class ABCTabsBridge extends BridgeAbstract{ class ABCTabsBridge extends BridgeAbstract {
const MAINTAINER = "kranack"; const MAINTAINER = 'kranack';
const NAME = "ABC Tabs Bridge"; const NAME = 'ABC Tabs Bridge';
const URI = "http://www.abc-tabs.com/"; const URI = 'http://www.abc-tabs.com/';
const DESCRIPTION = "Returns 22 newest tabs"; const DESCRIPTION = 'Returns 22 newest tabs';
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$html = getSimpleHTMLDOM(static::URI.'tablatures/nouveautes.html') or returnClientError('No results for this query.'); $html = getSimpleHTMLDOM(static::URI.'tablatures/nouveautes.html')
or returnClientError('No results for this query.');
$table = $html->find('table#myTable', 0)->children(1); $table = $html->find('table#myTable', 0)->children(1);
foreach ($table->find('tr') as $tab) foreach ($table->find('tr') as $tab)
{ {
$item = array(); $item = array();
$item['author'] = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext; $item['author'] = $tab->find('td', 1)->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; . $tab->find('td', 2)->plaintext;
$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'); $item['title'] = $tab->find('td', 1)->plaintext
$this->items[] = $item; . ' - '
. $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'] = 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;
} }
} }
} }

View file

@ -1,25 +1,25 @@
<?php <?php
class AcrimedBridge extends FeedExpander { class AcrimedBridge extends FeedExpander {
const MAINTAINER = "qwertygc"; const MAINTAINER = 'qwertygc';
const NAME = "Acrimed Bridge"; const NAME = 'Acrimed Bridge';
const URI = "http://www.acrimed.org/"; const URI = 'http://www.acrimed.org/';
const CACHE_TIMEOUT = 4800; //2hours const CACHE_TIMEOUT = 4800; //2hours
const DESCRIPTION = "Returns the newest articles."; const DESCRIPTION = 'Returns the newest articles';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(static::URI.'spip.php?page=backend'); $this->collectExpandableDatas(static::URI . 'spip.php?page=backend');
} }
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$articlePage = getSimpleHTMLDOM($newsItem->link); $articlePage = getSimpleHTMLDOM($newsItem->link);
$article = sanitize($articlePage->find('article.article1', 0)->innertext); $article = sanitize($articlePage->find('article.article1', 0)->innertext);
$article = defaultImageSrcTo($article, static::URI); $article = defaultImageSrcTo($article, static::URI);
$item['content'] = $article; $item['content'] = $article;
return $item; return $item;
} }
} }

View file

@ -1,91 +1,88 @@
<?php <?php
class AllocineFRBridge extends BridgeAbstract{ class AllocineFRBridge extends BridgeAbstract {
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',
'required' => true,
'exampleValue' => 'Faux Raccord',
'title' => 'Select your category',
'values' => array(
'Faux Raccord' => 'faux-raccord',
'Top 5' => 'top-5',
'Tueurs en Séries' => 'tueurs-en-serie'
)
)
));
const MAINTAINER = "superbaillot.net"; public function getURI(){
const NAME = "Allo Cine Bridge"; if(!is_null($this->getInput('category'))){
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',
'required'=>true,
'exampleValue'=>'Faux Raccord',
'title'=>'Select your category',
'values'=>array(
'Faux Raccord'=>'faux-raccord',
'Top 5'=>'top-5',
'Tueurs en Séries'=>'tueurs-en-serie'
)
)
));
public function getURI(){ switch($this->getInput('category')){
if(!is_null($this->getInput('category'))){ case 'faux-raccord':
$uri = static::URI . 'video/programme-12284/saison-27129/';
break;
case 'top-5':
$uri = static::URI . 'video/programme-12299/saison-29561/';
break;
case 'tueurs-en-serie':
$uri = static::URI . 'video/programme-12286/saison-22938/';
break;
}
switch($this->getInput('category')){ return $uri;
case 'faux-raccord': }
$uri = static::URI.'video/programme-12284/saison-27129/';
break;
case 'top-5':
$uri = static::URI.'video/programme-12299/saison-29561/';
break;
case 'tueurs-en-serie':
$uri = static::URI.'video/programme-12286/saison-22938/';
break;
}
return $uri; return parent::getURI();
} }
return parent::getURI(); public function getName(){
} if(!is_null($this->getInput('category'))){
return self::NAME . ' : '
.array_search(
$this->getInput('category'),
self::PARAMETERS[$this->queriedContext]['category']['values']
);
}
public function getName(){ return parent::getName();
if(!is_null($this->getInput('category'))){ }
return self::NAME.' : '
.array_search(
$this->getInput('category'),
self::PARAMETERS[$this->queriedContext]['category']['values']
);
}
return parent::getName(); public function collectData(){
}
public function collectData(){ $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request ' . $this->getURI() . ' !');
$html = getSimpleHTMLDOM($this->getURI()) $category = array_search(
or returnServerError("Could not request ".$this->getURI()." !"); $this->getInput('category'),
self::PARAMETERS[$this->queriedContext]['category']['values']
);
$category=array_search( foreach($html->find('figure.media-meta-fig') as $element){
$this->getInput('category'), $item = array();
self::PARAMETERS[$this->queriedContext]['category']['values']
);
$title = $element->find('div.titlebar h3.title a', 0);
$content = trim($element->innertext);
$figCaption = strpos($content, $category);
foreach($html->find('figure.media-meta-fig') as $element) if($figCaption !== false)
{ {
$item = array(); $content = str_replace('src="/', 'src="' . static::URI, $content);
$content = str_replace('href="/', 'href="' . static::URI, $content);
$title = $element->find('div.titlebar h3.title a', 0); $content = str_replace('src=\'/', 'src=\'' . static::URI, $content);
$content = trim($element->innertext); $content = str_replace('href=\'/', 'href=\'' . static::URI, $content);
$figCaption = strpos($content, $category); $item['content'] = $content;
$item['title'] = trim($title->innertext);
if($figCaption !== false) $item['uri'] = static::URI . $title->href;
{ $this->items[] = $item;
$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'] = static::URI . $title->href;
$this->items[] = $item;
}
}
}
} }

View file

@ -1,123 +1,135 @@
<?php <?php
class AnimeUltimeBridge extends BridgeAbstract { class AnimeUltimeBridge extends BridgeAbstract {
const MAINTAINER = 'ORelio'; const MAINTAINER = 'ORelio';
const NAME = 'Anime-Ultime'; const NAME = 'Anime-Ultime';
const URI = 'http://www.anime-ultime.net/'; const URI = 'http://www.anime-ultime.net/';
const CACHE_TIMEOUT = 10800; // 3h const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = 'Returns the 10 newest releases posted on Anime-Ultime'; const DESCRIPTION = 'Returns the 10 newest releases posted on Anime-Ultime';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'type'=>array( 'type' => array(
'name'=>'Type', 'name' => 'Type',
'type'=>'list', 'type' => 'list',
'values'=>array( 'values' => array(
'Everything'=>'', 'Everything' => '',
'Anime'=>'A', 'Anime' => 'A',
'Drama'=>'D', 'Drama' => 'D',
'Tokusatsu'=>'T' 'Tokusatsu' => 'T'
) )
) )
)); ));
private $filter = 'Releases'; private $filter = 'Releases';
public function collectData(){ public function collectData(){
//Add type filter if provided //Add type filter if provided
$typeFilter = array_search( $typeFilter = array_search(
$this->getInput('type'), $this->getInput('type'),
self::PARAMETERS[$this->queriedContext]['type']['values'] self::PARAMETERS[$this->queriedContext]['type']['values']
); );
//Build date and filters for making requests //Build date and filters for making requests
$thismonth = date('mY').$typeFilter; $thismonth = date('mY') . $typeFilter;
$lastmonth = date('mY', mktime(0, 0, 0, date('n') - 1, 1, date('Y'))).$typeFilter; $lastmonth = date('mY', mktime(0, 0, 0, date('n') - 1, 1, date('Y'))) . $typeFilter;
//Process each HTML page until having 10 releases //Process each HTML page until having 10 releases
$processedOK = 0; $processedOK = 0;
foreach (array($thismonth, $lastmonth) as $requestFilter) { foreach (array($thismonth, $lastmonth) as $requestFilter) {
//Retrive page contents //Retrive page contents
$url = self::URI.'history-0-1/'.$requestFilter; $url = self::URI . 'history-0-1/' . $requestFilter;
$html = getSimpleHTMLDOM($url) $html = getSimpleHTMLDOM($url)
or returnServerError('Could not request Anime-Ultime: '.$url); or returnServerError('Could not request Anime-Ultime: ' . $url);
//Relases are sorted by day : process each day individually //Relases are sorted by day : process each day individually
foreach ($html->find('div.history', 0)->find('h3') as $daySection) { foreach($html->find('div.history', 0)->find('h3') as $daySection) {
//Retrieve day and build date information //Retrieve day and build date information
$dateString = $daySection->plaintext; $dateString = $daySection->plaintext;
$day = intval(substr($dateString, strpos($dateString, ' ') + 1, 2)); $day = intval(substr($dateString, strpos($dateString, ' ') + 1, 2));
$item_date = strtotime(str_pad($day, 2, '0', STR_PAD_LEFT).'-' $item_date = strtotime(str_pad($day, 2, '0', STR_PAD_LEFT)
.substr($requestFilter, 0, 2).'-' . '-'
.substr($requestFilter, 2, 4)); . substr($requestFilter, 0, 2)
$release = $daySection->next_sibling()->next_sibling()->first_child(); //<h3>day</h3><br /><table><tr> <-- useful data in table rows . '-'
. substr($requestFilter, 2, 4));
//Process each release of that day, ignoring first table row: contains table headers //<h3>day</h3><br /><table><tr> <-- useful data in table rows
while (!is_null($release = $release->next_sibling())) { $release = $daySection->next_sibling()->next_sibling()->first_child();
if (count($release->find('td')) > 0) {
//Retrieve metadata from table columns //Process each release of that day, ignoring first table row: contains table headers
$item_link_element = $release->find('td', 0)->find('a', 0); while(!is_null($release = $release->next_sibling())) {
$item_uri = self::URI.$item_link_element->href; if(count($release->find('td')) > 0) {
$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;
$item_type = $release->find('td', 4)->plaintext;
if (!empty($item_uri)) { //Retrieve metadata from table columns
$item_link_element = $release->find('td', 0)->find('a', 0);
$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
)
);
//Retrieve description from description page and convert relative image src info absolute image src $item_fansub = $release->find('td', 2)->plaintext;
$html_item = getContents($item_uri) $item_type = $release->find('td', 4)->plaintext;
or returnServerError('Could not request Anime-Ultime: '.$item_uri);
$item_description = substr(
$html_item,
strpos($html_item, 'class="principal_contain" align="center">')
+ 41
);
$item_description = substr($item_description,
0,
strpos($item_description, '<div id="table">')
);
$item_description = str_replace(
'src="images', 'src="'.self::URI.'images',
$item_description
);
$item_description = str_replace("\r", '', $item_description);
$item_description = str_replace("\n", '', $item_description);
$item_description = utf8_encode($item_description);
//Build and add final item if(!empty($item_uri)) {
$item = array();
$item['uri'] = $item_uri;
$item['title'] = $item_name.' '.$item_type.' '.$item_episode;
$item['author'] = $item_fansub;
$item['timestamp'] = $item_date;
$item['content'] = $item_description;
$this->items[] = $item;
$processedOK++;
//Stop processing once limit is reached // Retrieve description from description page and
if ($processedOK >= 10) // convert relative image src info absolute image src
return; $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">') + 41
} );
} $item_description = substr($item_description,
0,
strpos($item_description, '<div id="table">')
);
$item_description = str_replace(
'src="images', 'src="' . self::URI . 'images',
$item_description
);
$item_description = str_replace("\r", '', $item_description);
$item_description = str_replace("\n", '', $item_description);
$item_description = utf8_encode($item_description);
public function getName() { //Build and add final item
if(!is_null($this->getInput('type'))){ $item = array();
$typeFilter = array_search( $item['uri'] = $item_uri;
$this->getInput('type'), $item['title'] = $item_name . ' ' . $item_type . ' ' . $item_episode;
self::PARAMETERS[$this->queriedContext]['type']['values'] $item['author'] = $item_fansub;
); $item['timestamp'] = $item_date;
$item['content'] = $item_description;
$this->items[] = $item;
$processedOK++;
return 'Latest '.$typeFilter.' - Anime-Ultime Bridge'; //Stop processing once limit is reached
} if ($processedOK >= 10)
return;
}
}
}
}
}
}
return parent::getName(); public function getName() {
} if(!is_null($this->getInput('type'))){
$typeFilter = array_search(
$this->getInput('type'),
self::PARAMETERS[$this->queriedContext]['type']['values']
);
return 'Latest ' . $typeFilter . ' - Anime-Ultime Bridge';
}
return parent::getName();
}
} }

View file

@ -1,91 +1,102 @@
<?php <?php
class Arte7Bridge extends BridgeAbstract{ class Arte7Bridge extends BridgeAbstract {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Arte +7"; const NAME = 'Arte +7';
const URI = "http://www.arte.tv/"; const URI = 'http://www.arte.tv/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns newest videos from ARTE +7"; const DESCRIPTION = 'Returns newest videos from ARTE +7';
const PARAMETERS = array( const PARAMETERS = array(
'Catégorie (Français)' => array( 'Catégorie (Français)' => array(
'catfr'=>array( 'catfr' => array(
'type'=>'list', 'type' => 'list',
'name'=>'Catégorie', 'name' => 'Catégorie',
'values'=>array( 'values' => array(
'Toutes les vidéos (français)'=>'toutes-les-videos', 'Toutes les vidéos (français)' => 'toutes-les-videos',
'Actu & société'=>'actu-société', 'Actu & société' => 'actu-société',
'Séries & fiction'=>'séries-fiction', 'Séries & fiction' => 'séries-fiction',
'Cinéma'=>'cinéma', 'Cinéma' => 'cinéma',
'Arts & spectacles classiques'=>'arts-spectacles-classiques', 'Arts & spectacles classiques' => 'arts-spectacles-classiques',
'Culture pop'=>'culture-pop', 'Culture pop' => 'culture-pop',
'Découverte'=>'découverte', 'Découverte' => 'découverte',
'Histoire'=>'histoire', 'Histoire' => 'histoire',
'Junior'=>'junior' 'Junior' => 'junior'
)
)
),
'Catégorie (Allemand)' => array(
'catde' => array(
'type' => 'list',
'name' => 'Catégorie',
'values' => array(
'Alle Videos (deutsch)' => 'alle-videos',
'Aktuelles & Gesellschaft' => 'aktuelles-gesellschaft',
'Fernsehfilme & Serien' => 'fernsehfilme-serien',
'Kino' => 'kino',
'Kunst & Kultur' => 'kunst-kultur',
'Popkultur & Alternativ' => 'popkultur-alternativ',
'Entdeckung' => 'entdeckung',
'Geschichte' => 'geschichte',
'Junior' => 'junior'
)
)
)
);
) public function collectData(){
) switch($this->queriedContext){
), case 'Catégorie (Français)':
'Catégorie (Allemand)' => array( $category = $this->getInput('catfr');
'catde'=>array( $lang = 'fr';
'type'=>'list', break;
'name'=>'Catégorie', case 'Catégorie (Allemand)':
'values'=>array( $category = $this->getInput('catde');
'Alle Videos (deutsch)'=>'alle-videos', $lang = 'de';
'Aktuelles & Gesellschaft'=>'aktuelles-gesellschaft', break;
'Fernsehfilme & Serien'=>'fernsehfilme-serien', }
'Kino'=>'kino',
'Kunst & Kultur'=>'kunst-kultur',
'Popkultur & Alternativ'=>'popkultur-alternativ',
'Entdeckung'=>'entdeckung',
'Geschichte'=>'geschichte',
'Junior'=>'junior'
)
)
)
);
public function collectData(){ $url = self::URI . 'guide/' . $lang . '/plus7/' . $category;
$input = getContents($url) or die('Could not request ARTE.');
switch($this->queriedContext){ if(strpos($input, 'categoryVideoSet') !== false){
case 'Catégorie (Français)': $input = explode('categoryVideoSet="', $input);
$category=$this->getInput('catfr'); $input = explode('}}', $input[1]);
$lang='fr'; $input = $input[0] . '}}';
break; } else {
case 'Catégorie (Allemand)': $input = explode('videoSet="', $input);
$category=$this->getInput('catde'); $input = explode('}]}', $input[1]);
$lang='de'; $input = $input[0] . '}]}';
break; }
}
$url = self::URI.'guide/'.$lang.'/plus7/'.$category; $input_json = json_decode(html_entity_decode($input, ENT_QUOTES), true);
$input = getContents($url) or die('Could not request ARTE.');
if(strpos($input, 'categoryVideoSet') !== FALSE){
$input = explode('categoryVideoSet="', $input);
$input = explode('}}', $input[1]);
$input = $input[0].'}}';
}else{
$input = explode('videoSet="', $input);
$input = explode('}]}', $input[1]);
$input = $input[0].'}]}';
}
$input_json = json_decode(html_entity_decode($input, ENT_QUOTES), TRUE); foreach($input_json['videos'] as $element) {
$item = array();
$item['uri'] = str_replace("autoplay=1", "", $element['url']);
$item['id'] = $element['id'];
foreach($input_json['videos'] as $element) { $hack_broadcast_time = $element['rights_end'];
$item = array(); $hack_broadcast_time = strtok($hack_broadcast_time, 'T');
$item['uri'] = str_replace("autoplay=1", "", $element['url']); $hack_broadcast_time = strtok('T');
$item['id'] = $element['id'];
$hack_broadcast_time = $element['rights_end']; $item['timestamp'] = strtotime($element['scheduled_on'] . 'T' . $hack_broadcast_time);
$hack_broadcast_time = strtok($hack_broadcast_time, 'T'); $item['title'] = $element['title'];
$hack_broadcast_time = strtok('T');
$item['timestamp'] = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time); if(!empty($element['subtitle']))
$item['title'] = $element['title']; $item['title'] = $element['title'] . ' | ' . $element['subtitle'];
if (!empty($element['subtitle']))
$item['title'] = $element['title'].' | '.$element['subtitle']; $item['duration'] = round((int)$element['duration'] / 60);
$item['duration'] = round((int)$element['duration']/60); $item['content'] = $element['teaser']
$item['content'] = $element['teaser'].'<br><br>'.$item['duration'].'min<br><a href="'.$item['uri'].'"><img src="' . $element['thumbnail_url'] . '" /></a>'; . '<br><br>'
$this->items[] = $item; . $item['duration']
} . 'min<br><a href="'
} . $item['uri']
. '"><img src="'
. $element['thumbnail_url']
. '" /></a>';
$this->items[] = $item;
}
}
} }

View file

@ -1,52 +1,66 @@
<?php <?php
class AskfmBridge extends BridgeAbstract{ class AskfmBridge extends BridgeAbstract {
const MAINTAINER = "az5he6ch"; const MAINTAINER = 'az5he6ch';
const NAME = "Ask.fm Answers"; const NAME = 'Ask.fm Answers';
const URI = "http://ask.fm/"; const URI = 'http://ask.fm/';
const CACHE_TIMEOUT = 300; //5 min const CACHE_TIMEOUT = 300; //5 min
const DESCRIPTION = "Returns answers from an Ask.fm user"; const DESCRIPTION = 'Returns answers from an Ask.fm user';
const PARAMETERS = array( const PARAMETERS = array(
'Ask.fm username'=>array( 'Ask.fm username' => array(
'u'=>array( 'u' => array(
'name'=>'Username', 'name' => 'Username',
'required'=>true 'required' => true
) )
) )
); );
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
foreach($html->find('div.streamItem-answer') as $element) { foreach($html->find('div.streamItem-answer') as $element){
$item = array(); $item = array();
$item['uri'] = self::URI.$element->find('a.streamItemsAge',0)->href; $item['uri'] = self::URI . $element->find('a.streamItemsAge', 0)->href;
$question = trim($element->find('h1.streamItemContent-question',0)->innertext); $question = trim($element->find('h1.streamItemContent-question', 0)->innertext);
$item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES));
$answer = trim($element->find('p.streamItemContent-answer',0)->innertext);
#$item['update'] = $element->find('a.streamitemsage',0)->data-hint; // Doesn't work, DOM parser doesn't seem to like data-hint, dunno why
$visual = $element->find('div.streamItemContent-visual',0)->innertext; // This probably should be cleaned up, especially for YouTube embeds
//Fix tracking links, also doesn't work
foreach($element->find('a') as $link) {
if (strpos($link->href, 'l.ask.fm') !== false) {
#$link->href = str_replace('#_=_', '', get_headers($link->href, 1)['Location']); // Too slow
$link->href = $link->plaintext;
}
}
$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="'.self::URI,$content);
$item['content'] = $content;
$this->items[] = $item;
}
}
public function getName(){ $item['title'] = trim(
return self::NAME.' : '.$this->getInput('u'); htmlspecialchars_decode($element->find('h1.streamItemContent-question', 0)->plaintext,
} ENT_QUOTES
)
);
public function getURI(){ $answer = trim($element->find('p.streamItemContent-answer', 0)->innertext);
return self::URI.urlencode($this->getInput('u')).'/answers/more?page=0';
} // Doesn't work, DOM parser doesn't seem to like data-hint, dunno why
#$item['update'] = $element->find('a.streamitemsage',0)->data-hint;
// This probably should be cleaned up, especially for YouTube embeds
$visual = $element->find('div.streamItemContent-visual', 0)->innertext;
//Fix tracking links, also doesn't work
foreach($element->find('a') as $link){
if(strpos($link->href, 'l.ask.fm') !== false) {
// Too slow
#$link->href = str_replace('#_=_', '', get_headers($link->href, 1)['Location']);
$link->href = $link->plaintext;
}
}
$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="' . self::URI, $content);
$item['content'] = $content;
$this->items[] = $item;
}
}
public function getName(){
return self::NAME . ' : ' . $this->getInput('u');
}
public function getURI(){
return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0';
}
} }

View file

@ -1,43 +1,55 @@
<?php <?php
class BandcampBridge extends BridgeAbstract{ class BandcampBridge extends BridgeAbstract {
const MAINTAINER = "sebsauvage"; const MAINTAINER = 'sebsauvage';
const NAME = "Bandcamp Tag"; const NAME = 'Bandcamp Tag';
const URI = "http://bandcamp.com/"; const URI = 'http://bandcamp.com/';
const CACHE_TIMEOUT = 600; // 10min const CACHE_TIMEOUT = 600; // 10min
const DESCRIPTION = "New bandcamp release by tag"; const DESCRIPTION = 'New bandcamp release by tag';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'tag'=>array( 'tag' => array(
'name'=>'tag', 'name' => 'tag',
'type'=>'text', 'type' => 'text',
'required'=>true 'required' => true
) )
)); ));
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach($html->find('li.item') as $release) { foreach($html->find('li.item') as $release){
$script = $release->find('div.art', 0)->getAttribute('onclick'); $script = $release->find('div.art', 0)->getAttribute('onclick');
$uri = ltrim($script, "return 'url("); $uri = ltrim($script, "return 'url(");
$uri = rtrim($uri, "')"); $uri = rtrim($uri, "')");
$item = array(); $item = array();
$item['author'] = $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext; $item['author'] = $release->find('div.itemsubtext', 0)->plaintext
$item['title'] = $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext; . ' - '
$item['content'] = '<img src="' . $uri . '"/><br/>' . $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext; . $release->find('div.itemtext', 0)->plaintext;
$item['id'] = $release->find('a',0)->getAttribute('href');
$item['uri'] = $release->find('a',0)->getAttribute('href');
$this->items[] = $item;
}
}
public function getURI(){ $item['title'] = $release->find('div.itemsubtext', 0)->plaintext
return self::URI.'tag/'.urlencode($this->getInput('tag')).'?sort_field=date'; . ' - '
} . $release->find('div.itemtext', 0)->plaintext;
public function getName(){ $item['content'] = '<img src="'
return $this->getInput('tag') .' - '.'Bandcamp Tag'; . $uri
} . '"/><br/>'
. $release->find('div.itemsubtext', 0)->plaintext
. ' - '
. $release->find('div.itemtext', 0)->plaintext;
$item['id'] = $release->find('a', 0)->getAttribute('href');
$item['uri'] = $release->find('a', 0)->getAttribute('href');
$this->items[] = $item;
}
}
public function getURI(){
return self::URI . 'tag/' . urlencode($this->getInput('tag')) . '?sort_field=date';
}
public function getName(){
return $this->getInput('tag') . ' - Bandcamp Tag';
}
} }

View file

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

View file

@ -1,33 +1,31 @@
<?php <?php
class BlaguesDeMerdeBridge extends BridgeAbstract{ class BlaguesDeMerdeBridge extends BridgeAbstract {
const MAINTAINER = "superbaillot.net"; const MAINTAINER = 'superbaillot.net';
const NAME = "Blagues De Merde"; const NAME = 'Blagues De Merde';
const URI = "http://www.blaguesdemerde.fr/"; const URI = 'http://www.blaguesdemerde.fr/';
const CACHE_TIMEOUT = 7200; // 2h const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "Blagues De Merde"; const DESCRIPTION = 'Blagues De Merde';
public function collectData(){
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request BDM.');
public function collectData(){ foreach($html->find('article.joke_contener') as $element){
$html = getSimpleHTMLDOM(self::URI) $item = array();
or returnServerError('Could not request BDM.'); $temp = $element->find('a');
foreach($html->find('article.joke_contener') as $element) { if(isset($temp[2])){
$item = array(); $item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext);
$temp = $element->find('a'); $uri = $temp[2]->href;
if(isset($temp[2])) $item['uri'] = $uri;
{ $item['title'] = substr($uri, (strrpos($uri, "/") + 1));
$item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext); $date = $element->find('li.bdm_date', 0)->innertext;
$uri = $temp[2]->href; $time = mktime(0, 0, 0, substr($date, 3, 2), substr($date, 0, 2), substr($date, 6, 4));
$item['uri'] = $uri; $item['timestamp'] = $time;
$item['title'] = substr($uri, (strrpos($uri, "/") + 1)); $item['author'] = $element->find('li.bdm_pseudo', 0)->innertext;
$date = $element->find("li.bdm_date",0)->innertext; $this->items[] = $item;
$time = mktime(0, 0, 0, substr($date, 3, 2), substr($date, 0, 2), substr($date, 6, 4)); }
$item['timestamp'] = $time; }
$item['author'] = $element->find("li.bdm_pseudo",0)->innertext;; }
$this->items[] = $item;
}
}
}
} }
?>

View file

@ -1,36 +1,37 @@
<?php <?php
require_once('GelbooruBridge.php'); require_once('GelbooruBridge.php');
class BooruprojectBridge extends GelbooruBridge{ class BooruprojectBridge extends GelbooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Booruproject"; const NAME = 'Booruproject';
const URI = "http://booru.org/"; const URI = 'http://booru.org/';
const DESCRIPTION = "Returns images from given page of booruproject"; const DESCRIPTION = 'Returns images from given page of booruproject';
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 PARAMETERS = array( const PIDBYPAGE = 20;
'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 getURI(){ public function getName(){
return 'http://'.$this->getInput('i').'.booru.org/'; return static::NAME . ' ' . $this->getInput('i');
} }
public function getName(){
return static::NAME . ' ' . $this->getInput('i');
}
} }

View file

@ -1,10 +1,10 @@
<?php <?php
class CADBridge extends FeedExpander { class CADBridge extends FeedExpander {
const MAINTAINER = "nyutag"; const MAINTAINER = 'nyutag';
const NAME = "CAD Bridge"; const NAME = 'CAD Bridge';
const URI = "http://www.cad-comic.com/"; const URI = 'http://www.cad-comic.com/';
const CACHE_TIMEOUT = 7200; //2h const CACHE_TIMEOUT = 7200; //2h
const DESCRIPTION = "Returns the newest articles."; const DESCRIPTION = 'Returns the newest articles.';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas('http://cdn2.cad-comic.com/rss.xml', 10); $this->collectExpandableDatas('http://cdn2.cad-comic.com/rss.xml', 10);
@ -12,11 +12,11 @@ class CADBridge extends FeedExpander {
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = $this->CADExtractContent($item['uri']); $item['content'] = $this->extractCADContent($item['uri']);
return $item; return $item;
} }
private function CADExtractContent($url) { private function extractCADContent($url) {
$html3 = getSimpleHTMLDOMCached($url); $html3 = getSimpleHTMLDOMCached($url);
// The request might fail due to missing https support or wrong URL // The request might fail due to missing https support or wrong URL
@ -35,12 +35,11 @@ class CADBridge extends FeedExpander {
default: default:
return 'Daily comic not released yet'; return 'Daily comic not released yet';
} }
$img = implode ($url2[0]); $img = implode($url2[0]);
$html3->clear(); $html3->clear();
unset ($html3); unset($html3);
if ($img == '') if ($img == '')
return 'Daily comic not released yet'; return 'Daily comic not released yet';
return '<img src="'.$img.'"/>'; return '<img src="' . $img . '"/>';
} }
} }
?>

View file

@ -1,76 +1,89 @@
<?php <?php
class CNETBridge extends BridgeAbstract { class CNETBridge extends BridgeAbstract {
const MAINTAINER = 'ORelio'; const MAINTAINER = 'ORelio';
const NAME = 'CNET News'; const NAME = 'CNET News';
const URI = 'http://www.cnet.com/'; const URI = 'http://www.cnet.com/';
const CACHE_TIMEOUT = 1800; // 30min 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.'; const DESCRIPTION = 'Returns the newest articles. <br /> You may specify a
topic found in some section URLs, else all topics are selected.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'topic'=>array('name'=>'Topic name') 'topic' => array(
)); 'name' => 'Topic name'
)
));
public function collectData(){ public function collectData(){
function ExtractFromDelimiters($string, $start, $end) { function extractFromDelimiters($string, $start, $end){
if (strpos($string, $start) !== false) { if(strpos($string, $start) !== false){
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
} return false; }
}
function StripWithDelimiters($string, $start, $end) { return false;
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) { function stripWithDelimiters($string, $start, $end){
$article_html = '<p>'.substr($article_html, strpos($article_html, '<p>') + 3); while(strpos($string, $start) !== false){
$article_html = StripWithDelimiters($article_html, '<span class="credit">', '</span>'); $section_to_remove = substr($string, strpos($string, $start));
$article_html = StripWithDelimiters($article_html, '<script', '</script>'); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$article_html = StripWithDelimiters($article_html, '<div class="shortcode related-links', '</div>'); $string = str_replace($section_to_remove, '', $string);
$article_html = StripWithDelimiters($article_html, '<a class="clickToEnlarge">', '</a>'); }
return $article_html;
}
$pageUrl = self::URI.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/'); return $string;
$html = getSimpleHTMLDOM($pageUrl) or returnServerError('Could not request CNET: '.$pageUrl); }
$limit = 0;
foreach($html->find('div.assetBody') as $element) { function cleanArticle($article_html){
if ($limit < 8) { $article_html = '<p>' . substr($article_html, strpos($article_html, '<p>') + 3);
$article_html = stripWithDelimiters($article_html, '<span class="credit">', '</span>');
$article_html = stripWithDelimiters($article_html, '<script', '</script>');
$article_html = stripWithDelimiters($article_html, '<div class="shortcode related-links', '</div>');
$article_html = stripWithDelimiters($article_html, '<a class="clickToEnlarge">', '</a>');
return $article_html;
}
$article_title = trim($element->find('h2', 0)->plaintext); $pageUrl = self::URI . (empty($this->getInput('topic')) ? '' : 'topics/' . $this->getInput('topic') . '/');
$article_uri = self::URI.($element->find('a', 0)->href); $html = getSimpleHTMLDOM($pageUrl) or returnServerError('Could not request CNET: ' . $pageUrl);
$article_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext); $limit = 0;
$article_author = trim($element->find('a[rel=author]', 0)->plaintext);
if (!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false) { foreach($html->find('div.assetBody') as $element){
if($limit < 8){
$article_title = trim($element->find('h2', 0)->plaintext);
$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);
$article_html = getSimpleHTMLDOM($article_uri) or returnServerError('Could not request CNET: '.$article_uri); if(!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false){
$article_html = getSimpleHTMLDOM($article_uri)
or returnServerError('Could not request CNET: ' . $article_uri);
$article_content = trim(
cleanArticle(
extractFromDelimiters(
$article_html,
'<div class="articleContent',
'<footer>'
)
)
);
$article_content = trim(CleanArticle(ExtractFromDelimiters($article_html, '<div class="articleContent', '<footer>'))); $item = array();
$item['uri'] = $article_uri;
$item['title'] = $article_title;
$item['author'] = $article_author;
$item['timestamp'] = $article_timestamp;
$item['content'] = $article_content;
$this->items[] = $item;
$limit++;
}
}
}
}
$item = array(); public function getName(){
$item['uri'] = $article_uri; $topic = $this->getInput('topic');
$item['title'] = $article_title; return 'CNET News Bridge' . (empty($topic) ? '' : ' - ' . $topic);
$item['author'] = $article_author; }
$item['timestamp'] = $article_timestamp;
$item['content'] = $article_content;
$this->items[] = $item;
$limit++;
}
}
}
}
public function getName() {
$topic=$this->getInput('topic');
return 'CNET News Bridge'.(empty($topic) ? '' : ' - '.$topic);
}
} }

View file

@ -1,35 +1,35 @@
<?php <?php
class CastorusBridge extends BridgeAbstract { class CastorusBridge extends BridgeAbstract {
const MAINTAINER = "logmanoriginal"; const MAINTAINER = 'logmanoriginal';
const NAME = "Castorus Bridge"; const NAME = 'Castorus Bridge';
const URI = 'http://www.castorus.com'; const URI = 'http://www.castorus.com';
const CACHE_TIMEOUT = 600; // 10min const CACHE_TIMEOUT = 600; // 10min
const DESCRIPTION = "Returns the latest changes"; const DESCRIPTION = 'Returns the latest changes';
const PARAMETERS = array( const PARAMETERS = array(
'Get latest changes' => array(), 'Get latest changes' => array(),
'Get latest changes via ZIP code' => array( 'Get latest changes via ZIP code' => array(
'zip'=>array( 'zip' => array(
'name'=>'ZIP code', 'name' => 'ZIP code',
'type'=>'text', 'type' => 'text',
'required'=>true, 'required' => true,
'exampleValue'=>'74910, 74', 'exampleValue' => '74910, 74',
'title'=>'Insert ZIP code (complete or partial)' 'title' => 'Insert ZIP code (complete or partial)'
) )
), ),
'Get latest changes via city name' => array( 'Get latest changes via city name' => array(
'city'=>array( 'city' => array(
'name'=>'City name', 'name' => 'City name',
'type'=>'text', 'type' => 'text',
'required'=>true, 'required' => true,
'exampleValue'=>'Seyssel, Seys', 'exampleValue' => 'Seyssel, Seys',
'title'=>'Insert city name (complete or partial)' 'title' => 'Insert city name (complete or partial)'
) )
) )
); );
// Extracts the tile from an actitiy // Extracts the title from an actitiy
private function ExtractActivityTitle($activity){ private function extractActivityTitle($activity){
$title = $activity->find('a', 0); $title = $activity->find('a', 0);
if(!$title) if(!$title)
@ -39,7 +39,7 @@ class CastorusBridge extends BridgeAbstract {
} }
// Extracts the url from an actitiy // Extracts the url from an actitiy
private function ExtractActivityUrl($activity){ private function extractActivityUrl($activity){
$url = $activity->find('a', 0); $url = $activity->find('a', 0);
if(!$url) if(!$url)
@ -49,7 +49,7 @@ class CastorusBridge extends BridgeAbstract {
} }
// Extracts the time from an activity // Extracts the time from an activity
private function ExtractActivityTime($activity){ private function extractActivityTime($activity){
// Unfortunately the time is part of the parent node, // Unfortunately the time is part of the parent node,
// so we have to clear all child nodes first // so we have to clear all child nodes first
$nodes = $activity->find('*'); $nodes = $activity->find('*');
@ -65,7 +65,7 @@ class CastorusBridge extends BridgeAbstract {
} }
// Extracts the price change // Extracts the price change
private function ExtractActivityPrice($activity){ private function extractActivityPrice($activity){
$price = $activity->find('span', 1); $price = $activity->find('span', 1);
if(!$price) if(!$price)
@ -75,8 +75,8 @@ class CastorusBridge extends BridgeAbstract {
} }
public function collectData(){ public function collectData(){
$zip_filter = trim($this->getInput('zip')); $zip_filter = trim($this->getInput('zip'));
$city_filter = trim($this->getInput('city')); $city_filter = trim($this->getInput('city'));
$html = getSimpleHTMLDOM(self::URI); $html = getSimpleHTMLDOM(self::URI);
@ -91,17 +91,24 @@ class CastorusBridge extends BridgeAbstract {
foreach($activities as $activity){ foreach($activities as $activity){
$item = array(); $item = array();
$item['title'] = $this->ExtractActivityTitle($activity); $item['title'] = $this->extractActivityTitle($activity);
$item['uri'] = $this->ExtractActivityUrl($activity); $item['uri'] = $this->extractActivityUrl($activity);
$item['timestamp'] = $this->ExtractActivityTime($activity); $item['timestamp'] = $this->extractActivityTime($activity);
$item['content'] = '<a href="' . $item['uri'] . '">' . $item['title'] . '</a><br><p>' $item['content'] = '<a href="'
. $this->ExtractActivityPrice($activity) . '</p>'; . $item['uri']
. '">'
. $item['title']
. '</a><br><p>'
. $this->extractActivityPrice($activity)
. '</p>';
if(isset($zip_filter) && !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)){ if(isset($zip_filter)
&& !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)){
continue; // Skip this item continue; // Skip this item
} }
if(isset($city_filter) && !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)){ if(isset($city_filter)
&& !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)){
continue; // Skip this item continue; // Skip this item
} }

View file

@ -1,11 +1,11 @@
<?php <?php
class CollegeDeFranceBridge extends BridgeAbstract{ class CollegeDeFranceBridge extends BridgeAbstract {
const MAINTAINER = "pit-fgfjiudghdf"; const MAINTAINER = 'pit-fgfjiudghdf';
const NAME = "CollegeDeFrance"; const NAME = 'CollegeDeFrance';
const URI = "http://www.college-de-france.fr/"; const URI = 'http://www.college-de-france.fr/';
const CACHE_TIMEOUT = 10800; // 3h const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the latest audio and video from CollegeDeFrance"; const DESCRIPTION = 'Returns the latest audio and video from CollegeDeFrance';
public function collectData(){ public function collectData(){
$months = array( $months = array(
@ -22,47 +22,61 @@ class CollegeDeFranceBridge extends BridgeAbstract{
'11' => 'nov.', '11' => 'nov.',
'12' => 'déc.' '12' => 'déc.'
); );
// The "API" used by the site returns a list of partial HTML in this form // The "API" used by the site returns a list of partial HTML in this form
/* <li> /* <li>
* <a href="/site/thomas-romer/guestlecturer-2016-04-15-14h30.htm" data-target="after"> * <a href="/site/thomas-romer/guestlecturer-2016-04-15-14h30.htm" data-target="after">
* <span class="date"><span class="list-icon list-icon-video"></span><span class="list-icon list-icon-audio"></span>15 avr. 2016</span> * <span class="date"><span class="list-icon list-icon-video"></span>
* <span class="list-icon list-icon-audio"></span>15 avr. 2016</span>
* <span class="lecturer">Christopher Hays</span> * <span class="lecturer">Christopher Hays</span>
* <span class='title'>Imagery of Divine Suckling in the Hebrew Bible and the Ancient Near East</span> * <span class='title'>Imagery of Divine Suckling in the Hebrew Bible and the Ancient Near East</span>
* </a> * </a>
* </li> * </li>
*/ */
$html = getSimpleHTMLDOM(self::URI.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') $html = getSimpleHTMLDOM(self::URI
or returnServerError('Could not request CollegeDeFrance.'); . 'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
foreach($html->find('a[data-target]') as $element) { or returnServerError('Could not request CollegeDeFrance.');
foreach($html->find('a[data-target]') as $element){
$item = array(); $item = array();
$item['title'] = $element->find('.title', 0)->plaintext; $item['title'] = $element->find('.title', 0)->plaintext;
// Most relative URLs contains an hour in addition to the date, so let's use it // Most relative URLs contains an hour in addition to the date, so let's use it
// <a href="/site/yann-lecun/course-2016-04-08-11h00.htm" data-target="after"> // <a href="/site/yann-lecun/course-2016-04-08-11h00.htm" data-target="after">
// //
// Sometimes there's an __1, perhaps it signifies an update "/site/patrick-boucheron/seminar-2016-05-03-18h00__1.htm" // Sometimes there's an __1, perhaps it signifies an update
// "/site/patrick-boucheron/seminar-2016-05-03-18h00__1.htm"
// //
// But unfortunately some don't have any hours info // But unfortunately some don't have any hours info
// <a href="/site/institut-physique/The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after"> // <a href="/site/institut-physique/
// The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after">
$timezone = new DateTimeZone('Europe/Paris'); $timezone = new DateTimeZone('Europe/Paris');
// strpos($element->href, '201') will break in 2020 but it'll probably break prior to then due to site changes anyway
$d = DateTime::createFromFormat( // strpos($element->href, '201') will break in 2020 but it'll
'!Y-m-d-H\hi', // probably break prior to then due to site changes anyway
substr($element->href, strpos($element->href, '201'), 16), $d = DateTime::createFromFormat(
$timezone '!Y-m-d-H\hi',
); substr($element->href, strpos($element->href, '201'), 16),
if(!$d){ $timezone
$d=DateTime::createFromFormat( );
'!d m Y',
trim(str_replace( if(!$d){
array_values($months), $d = DateTime::createFromFormat(
array_keys($months), '!d m Y',
$element->find('.date', 0)->plaintext trim(str_replace(
)), array_values($months),
$timezone array_keys($months),
); $element->find('.date', 0)->plaintext
} )),
$item['timestamp'] = $d->format('U'); $timezone
$item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext; );
}
$item['timestamp'] = $d->format('U');
$item['content'] = $element->find('.lecturer', 0)->innertext
. ' - '
. $element->find('.title', 0)->innertext;
$item['uri'] = self::URI . $element->href; $item['uri'] = self::URI . $element->href;
$this->items[] = $item; $this->items[] = $item;
} }

View file

@ -1,10 +1,10 @@
<?php <?php
class CommonDreamsBridge extends FeedExpander { class CommonDreamsBridge extends FeedExpander {
const MAINTAINER = "nyutag"; const MAINTAINER = 'nyutag';
const NAME = "CommonDreams Bridge"; const NAME = 'CommonDreams Bridge';
const URI = "http://www.commondreams.org/"; const URI = 'http://www.commondreams.org/';
const DESCRIPTION = "Returns the newest articles."; const DESCRIPTION = 'Returns the newest articles.';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas('http://www.commondreams.org/rss.xml', 10); $this->collectExpandableDatas('http://www.commondreams.org/rss.xml', 10);
@ -12,11 +12,11 @@ class CommonDreamsBridge extends FeedExpander {
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = $this->CommonDreamsExtractContent($item['uri']); $item['content'] = $this->extractContent($item['uri']);
return $item; return $item;
} }
private function CommonDreamsExtractContent($url) { private function extractContent($url){
$html3 = getSimpleHTMLDOMCached($url); $html3 = getSimpleHTMLDOMCached($url);
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext; $text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
$html3->clear(); $html3->clear();

View file

@ -1,39 +1,35 @@
<?php <?php
class CopieDoubleBridge extends BridgeAbstract{ class CopieDoubleBridge extends BridgeAbstract {
const MAINTAINER = "superbaillot.net"; const MAINTAINER = 'superbaillot.net';
const NAME = "CopieDouble"; const NAME = 'CopieDouble';
const URI = "http://www.copie-double.com/"; const URI = 'http://www.copie-double.com/';
const CACHE_TIMEOUT = 14400; // 4h const CACHE_TIMEOUT = 14400; // 4h
const DESCRIPTION = "CopieDouble"; const DESCRIPTION = 'CopieDouble';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request CopieDouble.'); or returnServerError('Could not request CopieDouble.');
$table = $html->find('table table', 2);
foreach($table->find('tr') as $element) $table = $html->find('table table', 2);
{
$td = $element->find('td', 0);
if($td->class == "couleur_1")
{
$item = array();
$title = $td->innertext; foreach($table->find('tr') as $element){
$pos = strpos($title, "<a"); $td = $element->find('td', 0);
$title = substr($title, 0, $pos);
$item['title'] = $title;
}
elseif(strpos($element->innertext, "/images/suivant.gif") === false)
{
$a=$element->find("a", 0);
$item['uri'] = self::URI . $a->href;
$content = str_replace('src="/', 'src="/'.self::URI,$element->find("td", 0)->innertext); if($td->class === 'couleur_1'){
$content = str_replace('href="/', 'href="'.self::URI,$content); $item = array();
$item['content'] = $content; $title = $td->innertext;
$this->items[] = $item; $pos = strpos($title, '<a');
} $title = substr($title, 0, $pos);
} $item['title'] = $title;
} } elseif(strpos($element->innertext, "/images/suivant.gif") === false){
$a = $element->find('a', 0);
$item['uri'] = self::URI . $a->href;
$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;
}
}
}
} }

View file

@ -1,61 +1,55 @@
<?php <?php
class CourrierInternationalBridge extends BridgeAbstract{ class CourrierInternationalBridge extends BridgeAbstract {
const MAINTAINER = "teromene"; const MAINTAINER = 'teromene';
const NAME = "Courrier International Bridge"; const NAME = 'Courrier International Bridge';
const URI = "http://CourrierInternational.com/"; const URI = 'http://CourrierInternational.com/';
const CACHE_TIMEOUT = 300; // 5 min const CACHE_TIMEOUT = 300; // 5 min
const DESCRIPTION = "Courrier International bridge"; const DESCRIPTION = 'Courrier International bridge';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Error.');
$html = getSimpleHTMLDOM(self::URI) $element = $html->find("article");
or returnServerError('Error.'); $article_count = 1;
$element = $html->find("article"); foreach($element as $article){
$item = array();
$article_count = 1; $item['uri'] = $article->parent->getAttribute('href');
foreach($element as $article) { if(strpos($item['uri'], 'http') === false){
$item['uri'] = self::URI . $item['uri'];
}
$item = array(); $page = getSimpleHTMLDOMCached($item['uri']);
$item['uri'] = $article->parent->getAttribute("href"); $content = $page->find('.article-text', 0);
if(strpos($item['uri'], "http") === FALSE) { if(!$content){
$item['uri'] = self::URI.$item['uri']; $content = $page->find('.depeche-text', 0);
} }
$page = getSimpleHTMLDOMCached($item['uri']); $item['content'] = sanitize($content);
$item['title'] = strip_tags($article->find('.title', 0));
$content = $page->find('.article-text',0); $dateTime = date_parse($page->find('time', 0));
if(!$content){
$content = $page->find('.depeche-text',0);
}
$item['content'] = sanitize($content); $item['timestamp'] = mktime(
$item['title'] = strip_tags($article->find(".title",0)); $dateTime['hour'],
$dateTime['minute'],
$dateTime['second'],
$dateTime['month'],
$dateTime['day'],
$dateTime['year']
);
$dateTime = date_parse($page->find("time",0)); $this->items[] = $item;
$article_count ++;
$item['timestamp'] = mktime( if($article_count > 5)
$dateTime['hour'], break;
$dateTime['minute'], }
$dateTime['second'], }
$dateTime['month'],
$dateTime['day'],
$dateTime['year']
);
$this->items[] = $item;
$article_count ++;
if($article_count > 5) break;
}
}
} }
?>

View file

@ -1,71 +1,70 @@
<?php <?php
class CpasbienBridge extends BridgeAbstract { class CpasbienBridge extends BridgeAbstract {
const MAINTAINER = "lagaisse"; const MAINTAINER = 'lagaisse';
const NAME = "Cpasbien Bridge"; const NAME = 'Cpasbien Bridge';
const URI = "http://www.cpasbien.cm"; const URI = 'http://www.cpasbien.cm';
const CACHE_TIMEOUT = 86400; // 24h const CACHE_TIMEOUT = 86400; // 24h
const DESCRIPTION = "Returns latest torrents from a request query"; const DESCRIPTION = 'Returns latest torrents from a request query';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'q'=>array( 'q' => array(
'name'=>'Search', 'name' => 'Search',
'required'=>true, 'required' => true,
'title'=>'Type your search' 'title' => 'Type your search'
) )
)); ));
public function collectData(){ public function collectData(){
$request = str_replace(" ","-",trim($this->getInput('q'))); $request = str_replace(" ", "-", trim($this->getInput('q')));
$html = getSimpleHTMLDOM(self::URI.'/recherche/'.urlencode($request).'.html') $html = getSimpleHTMLDOM(self::URI . '/recherche/' . urlencode($request) . '.html')
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach ($html->find('#gauche',0)->find('div') as $episode) { foreach($html->find('#gauche',0)->find('div') as $episode){
if ($episode->getAttribute('class')=='ligne0' || if($episode->getAttribute('class') == 'ligne0'
$episode->getAttribute('class')=='ligne1') || $episode->getAttribute('class') == 'ligne1'){
{
$urlepisode = $episode->find('a', 0)->getAttribute('href'); $urlepisode = $episode->find('a', 0)->getAttribute('href');
$htmlepisode=getSimpleHTMLDOMCached($urlepisode, 86400*366*30); $htmlepisode = getSimpleHTMLDOMCached($urlepisode, 86400 * 366 * 30);
$item = array(); $item = array();
$item['author'] = $episode->find('a', 0)->text(); $item['author'] = $episode->find('a', 0)->text();
$item['title'] = $episode->find('a', 0)->text(); $item['title'] = $episode->find('a', 0)->text();
$item['pubdate'] = $this->getCachedDate($urlepisode); $item['pubdate'] = $this->getCachedDate($urlepisode);
$textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1); $textefiche = $htmlepisode->find('#textefiche', 0)->find('p', 1);
if (isset($textefiche)) {
$item['content'] = $textefiche->text();
} else {
$p=$htmlepisode->find('#textefiche',0)->find('p');
if(!empty($p)){
$item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text();
}
}
$item['id'] = $episode->find('a', 0)->getAttribute('href'); if(isset($textefiche)){
$item['uri'] = self::URI . $htmlepisode->find('#telecharger',0)->getAttribute('href'); $item['content'] = $textefiche->text();
$this->items[] = $item; } else {
} $p = $htmlepisode->find('#textefiche', 0)->find('p');
} if(!empty($p)){
} $item['content'] = $htmlepisode->find('#textefiche', 0)->find('p', 0)->text();
}
}
$item['id'] = $episode->find('a', 0)->getAttribute('href');
$item['uri'] = self::URI . $htmlepisode->find('#telecharger', 0)->getAttribute('href');
$this->items[] = $item;
}
}
}
public function getName(){ public function getName(){
return $this->getInput('q').' : '.self::NAME; return $this->getInput('q') . ' : ' . self::NAME;
} }
private function getCachedDate($url){ private function getCachedDate($url){
debugMessage('getting pubdate from url ' . $url . ''); debugMessage('getting pubdate from url ' . $url . '');
// Initialize cache // Initialize cache
$cache = Cache::create('FileCache'); $cache = Cache::create('FileCache');
$cache->setPath(CACHE_DIR . '/pages'); $cache->setPath(CACHE_DIR . '/pages');
$params = [$url]; $params = [$url];
$cache->setParameters($params); $cache->setParameters($params);
// Get cachefile timestamp // Get cachefile timestamp
$time = $cache->getTime(); $time = $cache->getTime();
return ($time!==false?$time:time()); return ($time !== false ? $time : time());
} }
} }

View file

@ -1,39 +1,45 @@
<?php <?php
class CryptomeBridge extends BridgeAbstract{ class CryptomeBridge extends BridgeAbstract {
const MAINTAINER = "BoboTiG"; const MAINTAINER = 'BoboTiG';
const NAME = "Cryptome"; const NAME = 'Cryptome';
const URI = "https://cryptome.org/"; const URI = 'https://cryptome.org/';
const CACHE_TIMEOUT = 21600; //6h const CACHE_TIMEOUT = 21600; //6h
const DESCRIPTION = "Returns the N most recent documents."; const DESCRIPTION = 'Returns the N most recent documents.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'n'=>array( 'n' => array(
'name'=>'number of elements', 'name' => 'number of elements',
'type'=>'number', 'type' => 'number',
'defaultValue'=>20, 'defaultValue' => 20,
'exampleValue'=>10 'exampleValue' => 10
) )
)); ));
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Cryptome.'); or returnServerError('Could not request Cryptome.');
$number=$this->getInput('n');
if (!empty($number)) { /* number of documents */
$num = min($number, 20);
}
$number = $this->getInput('n');
foreach($html->find('pre') as $element) { /* number of documents */
for ( $i = 0; $i < $num; ++$i ) { if(!empty($number)){
$item = array(); $num = min($number, 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/#', self::URI, $element->find('b', $i)->innertext); foreach($html->find('pre') as $element){
$this->items[] = $item; for($i = 0; $i < $num; ++$i){
} $item = array();
break; $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/#',
self::URI,
$element->find('b', $i)->innertext
);
$this->items[] = $item;
}
break;
}
}
} }

View file

@ -1,115 +1,122 @@
<?php <?php
class DailymotionBridge extends BridgeAbstract{ class DailymotionBridge extends BridgeAbstract {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Dailymotion Bridge"; const NAME = 'Dailymotion Bridge';
const URI = "https://www.dailymotion.com/"; const URI = 'https://www.dailymotion.com/';
const CACHE_TIMEOUT = 10800; // 3h const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the 5 newest videos by username/playlist or search"; const DESCRIPTION = 'Returns the 5 newest videos by username/playlist or search';
const PARAMETERS = array ( const PARAMETERS = array (
'By username' => array( 'By username' => array(
'u'=>array( 'u' => array(
'name'=>'username', 'name' => 'username',
'required'=>true 'required' => true
) )
), ),
'By playlist id' => array(
'p' => array(
'name' => 'playlist id',
'required' => true
)
),
'From search results' => array(
's' => array(
'name' => 'Search keyword',
'required' => true
),
'pa' => array(
'name' => 'Page',
'type' => 'number'
)
)
);
'By playlist id' => array( protected function getMetadata($id){
'p'=>array( $metadata = array();
'name'=>'playlist id', $html2 = getSimpleHTMLDOM(self::URI . 'video/' . $id);
'required'=>true if(!$html2){
) return $metadata;
), }
'From search results' => array( $metadata['title'] = $html2->find('meta[property=og:title]', 0)->getAttribute('content');
's'=>array( $metadata['timestamp'] = strtotime(
'name'=>'Search keyword', $html2->find('meta[property=video:release_date]', 0)->getAttribute('content')
'required'=>true );
), $metadata['thumbnailUri'] = $html2->find('meta[property=og:image]', 0)->getAttribute('content');
'pa'=>array( $metadata['uri'] = $html2->find('meta[property=og:url]', 0)->getAttribute('content');
'name'=>'Page', return $metadata;
'type'=>'number' }
)
)
);
protected function getMetadata($id) { public function collectData(){
$metadata=array(); $html = '';
$html2 = getSimpleHTMLDOM(self::URI.'video/'.$id); $limit = 5;
if(!$html2){ $count = 0;
return $metadata;
}
$metadata['title'] = $html2->find('meta[property=og:title]', 0)->getAttribute('content'); $html = getSimpleHTMLDOM($this->getURI())
$metadata['timestamp'] = strtotime($html2->find('meta[property=video:release_date]', 0)->getAttribute('content') ); or returnServerError('Could not request Dailymotion.');
$metadata['thumbnailUri'] = $html2->find('meta[property=og:image]', 0)->getAttribute('content');
$metadata['uri'] = $html2->find('meta[property=og:url]', 0)->getAttribute('content');
return $metadata;
}
public function collectData(){ foreach($html->find('div.media a.preview_link') as $element){
$html = ''; if($count < $limit){
$limit = 5; $item = array();
$count = 0; $item['id'] = str_replace('/video/', '', strtok($element->href, '_'));
$metadata = $this->getMetadata($item['id']);
if(empty($metadata)){
continue;
}
$item['uri'] = $metadata['uri'];
$item['title'] = $metadata['title'];
$item['timestamp'] = $metadata['timestamp'];
$html = getSimpleHTMLDOM($this->getURI()) $item['content'] = '<a href="'
or returnServerError('Could not request Dailymotion.'); . $item['uri']
. '"><img src="'
. $metadata['thumbnailUri']
. '" /></a><br><a href="'
. $item['uri']
. '">'
. $item['title']
. '</a>';
foreach($html->find('div.media a.preview_link') as $element) { $this->items[] = $item;
if($count < $limit) { $count++;
$item = array(); }
$item['id'] = str_replace('/video/', '', strtok($element->href, '_')); }
$metadata = $this->getMetadata($item['id']); }
if(empty($metadata)){
continue;
}
$item['uri'] = $metadata['uri'];
$item['title'] = $metadata['title'];
$item['timestamp'] = $metadata['timestamp'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $metadata['thumbnailUri'] . '" /></a><br><a href="' . $item['uri'] . '">' . $item['title'] . '</a>';
$this->items[] = $item;
$count++;
}
}
}
public function getName(){ public function getName(){
switch($this->queriedContext){ switch($this->queriedContext){
case 'By username': case 'By username':
$specific=$this->getInput('u'); $specific = $this->getInput('u');
break; break;
case 'By playlist id': case 'By playlist id':
$specific=strtok($this->getInput('p'), '_'); $specific = strtok($this->getInput('p'), '_');
break; break;
case 'From search results': case 'From search results':
$specific=$this->getInput('s'); $specific = $this->getInput('s');
break; break;
default: return parent::getName(); default: return parent::getName();
} }
return $specific.' : Dailymotion Bridge'; return $specific . ' : Dailymotion Bridge';
} }
public function getURI(){ public function getURI(){
$uri=self::URI; $uri = self::URI;
switch($this->queriedContext){ switch($this->queriedContext){
case 'By username': case 'By username':
$uri.='user/' $uri .= 'user/' . urlencode($this->getInput('u')) . '/1';
.urlencode($this->getInput('u')).'/1'; break;
break; case 'By playlist id':
case 'By playlist id': $uri .= 'playlist/' . urlencode(strtok($this->getInput('p'), '_'));
$uri.='playlist/' break;
.urlencode(strtok($this->getInput('p'), '_')); case 'From search results':
break; $uri .= 'search/' . urlencode($this->getInput('s'));
case 'From search results': if($this->getInput('pa')){
$uri.='search/' $uri .= '/' . $this->getInput('pa');
.urlencode($this->getInput('s')); }
if($this->getInput('pa')){ break;
$uri.='/'.$this->getInput('pa'); }
} return $uri;
break; }
}
return $uri;
}
} }

View file

@ -1,51 +1,59 @@
<?php <?php
class DanbooruBridge extends BridgeAbstract{ class DanbooruBridge extends BridgeAbstract {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Danbooru"; const NAME = 'Danbooru';
const URI = "http://donmai.us/"; const URI = 'http://donmai.us/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
const PARAMETERS = array( const PARAMETERS = array(
'global'=>array( 'global' => array(
'p'=>array( 'p' => array(
'name'=>'page', 'name' => 'page',
'defaultValue'=>1, 'defaultValue' => 1,
'type'=>'number' 'type' => 'number'
), ),
't'=>array('name'=>'tags') 't' => array(
), 'name' => 'tags'
0=>array() )
); ),
0 => array()
);
const PATHTODATA='article'; const PATHTODATA = 'article';
const IDATTRIBUTE='data-id'; const IDATTRIBUTE = 'data-id';
protected function getFullURI(){ protected function getFullURI(){
return $this->getURI().'posts?' return $this->getURI()
.'&page='.$this->getInput('p') . 'posts?&page=' . $this->getInput('p')
.'&tags='.urlencode($this->getInput('t')); . '&tags=' . urlencode($this->getInput('t'));
} }
protected function getItemFromElement($element){ protected function getItemFromElement($element){
$item = array(); $item = array();
$item['uri'] = $this->getURI().$element->find('a', 0)->href; $item['uri'] = $this->getURI() . $element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute(static::IDATTRIBUTE)); $item['postid'] = (int)preg_replace("/[^0-9]/", '', $element->getAttribute(static::IDATTRIBUTE));
$item['timestamp'] = time(); $item['timestamp'] = time();
$thumbnailUri = $this->getURI().$element->find('img', 0)->src; $thumbnailUri = $this->getURI() . $element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt'); $item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = $this->getName().' | '.$item['postid']; $item['title'] = $this->getName() . ' | ' . $item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags']; $item['content'] = '<a href="'
return $item; . $item['uri']
} . '"><img src="'
. $thumbnailUri
. '" /></a><br>Tags: '
. $item['tags'];
public function collectData(){ return $item;
$html = getSimpleHTMLDOM($this->getFullURI()) }
or returnServerError('Could not request '.$this->getName());
foreach($html->find(static::PATHTODATA) as $element) { public function collectData(){
$this->items[] = $this->getItemFromElement($element); $html = getSimpleHTMLDOM($this->getFullURI())
} or returnServerError('Could not request ' . $this->getName());
}
foreach($html->find(static::PATHTODATA) as $element) {
$this->items[] = $this->getItemFromElement($element);
}
}
} }

View file

@ -1,23 +1,23 @@
<?php <?php
class DansTonChatBridge extends BridgeAbstract{ class DansTonChatBridge extends BridgeAbstract {
const MAINTAINER = "Astalaseven"; const MAINTAINER = 'Astalaseven';
const NAME = "DansTonChat Bridge"; const NAME = 'DansTonChat Bridge';
const URI = "http://danstonchat.com/"; const URI = 'http://danstonchat.com/';
const CACHE_TIMEOUT = 21600; //6h const CACHE_TIMEOUT = 21600; //6h
const DESCRIPTION = "Returns latest quotes from DansTonChat."; const DESCRIPTION = 'Returns latest quotes from DansTonChat.';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI.'latest.html') $html = getSimpleHTMLDOM(self::URI . 'latest.html')
or returnServerError('Could not request DansTonChat.'); or returnServerError('Could not request DansTonChat.');
foreach($html->find('div.item') as $element) { foreach($html->find('div.item') as $element){
$item = array(); $item = array();
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;
$item['title'] = 'DansTonChat '.$element->find('a', 1)->plaintext; $item['title'] = 'DansTonChat ' . $element->find('a', 1)->plaintext;
$item['content'] = $element->find('a', 0)->innertext; $item['content'] = $element->find('a', 0)->innertext;
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }

View file

@ -1,57 +1,56 @@
<?php <?php
class DauphineLibereBridge extends FeedExpander { class DauphineLibereBridge extends FeedExpander {
const MAINTAINER = "qwertygc"; const MAINTAINER = 'qwertygc';
const NAME = "Dauphine Bridge"; const NAME = 'Dauphine Bridge';
const URI = "http://www.ledauphine.com/"; const URI = 'http://www.ledauphine.com/';
const CACHE_TIMEOUT = 7200; // 2h const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "Returns the newest articles."; const DESCRIPTION = 'Returns the newest articles.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'Catégorie de l\'article', 'name' => 'Catégorie de l\'article',
'type'=>'list', 'type' => 'list',
'values'=>array( 'values' => array(
'À la une'=>'', 'À la une' => '',
'France Monde'=>'france-monde', 'France Monde' => 'france-monde',
'Faits Divers'=>'faits-divers', 'Faits Divers' => 'faits-divers',
'Économie et Finance'=>'economie-et-finance', 'Économie et Finance' => 'economie-et-finance',
'Politique'=>'politique', 'Politique' => 'politique',
'Sport'=>'sport', 'Sport' => 'sport',
'Ain'=>'ain', 'Ain' => 'ain',
'Alpes-de-Haute-Provence'=>'haute-provence', 'Alpes-de-Haute-Provence' => 'haute-provence',
'Hautes-Alpes'=>'hautes-alpes', 'Hautes-Alpes' => 'hautes-alpes',
'Ardèche'=>'ardeche', 'Ardèche' => 'ardeche',
'Drôme'=>'drome', 'Drôme' => 'drome',
'Isère Sud'=>'isere-sud', 'Isère Sud' => 'isere-sud',
'Savoie'=>'savoie', 'Savoie' => 'savoie',
'Haute-Savoie'=>'haute-savoie', 'Haute-Savoie' => 'haute-savoie',
'Vaucluse'=>'vaucluse' 'Vaucluse' => 'vaucluse'
) )
) )
)); ));
public function collectData(){ public function collectData(){
$url = self::URI . 'rss'; $url = self::URI . 'rss';
if (empty($this->getInput('u'))) { if(empty($this->getInput('u'))){
$url = self::URI . $this->getInput('u') . '/rss'; $url = self::URI . $this->getInput('u') . '/rss';
} }
$this->collectExpandableDatas($url, 10); $this->collectExpandableDatas($url, 10);
} }
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = $this->ExtractContent($item['uri']); $item['content'] = $this->extractContent($item['uri']);
return $item; return $item;
} }
private function ExtractContent($url) { private function extractContent($url){
$html2 = getSimpleHTMLDOMCached($url); $html2 = getSimpleHTMLDOMCached($url);
$text = $html2->find('div.column', 0)->innertext; $text = $html2->find('div.column', 0)->innertext;
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text); $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
return $text; return $text;
} }
} }
?>

View file

@ -1,49 +1,46 @@
<?php <?php
class DemoBridge extends BridgeAbstract{ class DemoBridge extends BridgeAbstract {
const MAINTAINER = "teromene"; const MAINTAINER = 'teromene';
const NAME = "DemoBridge"; const NAME = 'DemoBridge';
const URI = "http://github.com/rss-bridge/rss-bridge"; const URI = 'http://github.com/rss-bridge/rss-bridge';
const DESCRIPTION = "Bridge used for demos"; const DESCRIPTION = 'Bridge used for demos';
const PARAMETERS = array( const PARAMETERS = array(
'testCheckbox' => array( 'testCheckbox' => array(
'testCheckbox'=>array( 'testCheckbox' => array(
'type'=>'checkbox', 'type' => 'checkbox',
'name'=>'test des checkbox' 'name' => 'test des checkbox'
) )
), ),
'testList' => array(
'testList' => array(
'type' => 'list',
'name' => 'test des listes',
'values' => array(
'Test' => 'test',
'Test 2' => 'test2'
)
)
),
'testNumber' => array(
'testNumber' => array(
'type' => 'number',
'name' => 'test des numéros',
'exampleValue' => '1515632'
)
)
);
'testList' => array( public function collectData(){
'testList'=>array(
'type'=>'list',
'name'=>'test des listes',
'values'=>array(
'Test'=>'test',
'Test 2'=>'test2'
)
)
),
'testNumber' => array( $item = array();
'testNumber'=>array( $item['author'] = "Me!";
'type'=>'number', $item['title'] = "Test";
'name'=>'test des numéros', $item['content'] = "Awesome content !";
'exampleValue'=>'1515632' $item['id'] = "Lalala";
) $item['uri'] = "http://example.com/test";
)
);
public function collectData(){ $this->items[] = $item;
}
$item = array();
$item['author'] = "Me!";
$item['title'] = "Test";
$item['content'] = "Awesome content !";
$item['id'] = "Lalala";
$item['uri'] = "http://example.com/test";
$this->items[] = $item;
}
} }

View file

@ -1,11 +1,11 @@
<?php <?php
class DeveloppezDotComBridge extends FeedExpander { class DeveloppezDotComBridge extends FeedExpander {
const MAINTAINER = "polopollo"; const MAINTAINER = 'polopollo';
const NAME = "Developpez.com Actus (FR)"; const NAME = 'Developpez.com Actus (FR)';
const URI = "http://www.developpez.com/"; const URI = 'https://www.developpez.com/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns the 15 newest posts from DeveloppezDotCom (full text)."; const DESCRIPTION = 'Returns the 15 newest posts from DeveloppezDotCom (full text).';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . 'index/rss', 15); $this->collectExpandableDatas(self::URI . 'index/rss', 15);
@ -13,19 +13,13 @@ class DeveloppezDotComBridge extends FeedExpander {
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = $this->DeveloppezDotComExtractContent($item['uri']); $item['content'] = $this->extractContent($item['uri']);
return $item; return $item;
} }
private function DeveloppezDotComStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
return $string;
}
// F***ing quotes from Microsoft Word badly encoded, here was the trick: // F***ing quotes from Microsoft Word badly encoded, here was the trick:
// http://stackoverflow.com/questions/1262038/how-to-replace-microsoft-encoded-quotes-in-php // http://stackoverflow.com/questions/1262038/how-to-replace-microsoft-encoded-quotes-in-php
private function convert_smart_quotes($string) private function convertSmartQuotes($string)
{ {
$search = array(chr(145), $search = array(chr(145),
chr(146), chr(146),
@ -33,18 +27,20 @@ class DeveloppezDotComBridge extends FeedExpander {
chr(148), chr(148),
chr(151)); chr(151));
$replace = array("'", $replace = array(
"'", "'",
'"', "'",
'"', '"',
'-'); '"',
'-'
);
return str_replace($search, $replace, $string); return str_replace($search, $replace, $string);
} }
private function DeveloppezDotComExtractContent($url) { private function extractContent($url){
$articleHTMLContent = getSimpleHTMLDOMCached($url); $articleHTMLContent = getSimpleHTMLDOMCached($url);
$text = $this->convert_smart_quotes($articleHTMLContent->find('div.content', 0)->innertext); $text = $this->convertSmartQuotes($articleHTMLContent->find('div.content', 0)->innertext);
$text = utf8_encode($text); $text = utf8_encode($text);
return trim($text); return trim($text);
} }

View file

@ -1,36 +1,36 @@
<?php <?php
class DilbertBridge extends BridgeAbstract { class DilbertBridge extends BridgeAbstract {
const MAINTAINER = 'kranack'; const MAINTAINER = 'kranack';
const NAME = 'Dilbert Daily Strip'; const NAME = 'Dilbert Daily Strip';
const URI = 'http://dilbert.com'; const URI = 'http://dilbert.com';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = 'The Unofficial Dilbert Daily Comic Strip'; const DESCRIPTION = 'The Unofficial Dilbert Daily Comic Strip';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request Dilbert: '.$this->getURI()); $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request Dilbert: ' . $this->getURI());
foreach ($html->find('section.comic-item') as $element) { foreach($html->find('section.comic-item') as $element){
$img = $element->find('img', 0); $img = $element->find('img', 0);
$link = $element->find('a', 0); $link = $element->find('a', 0);
$comic = $img->src; $comic = $img->src;
$title = $link->alt; $title = $link->alt;
$url = $link->href; $url = $link->href;
$date = substr($url, 25); $date = substr($url, 25);
if (empty($title)) if (empty($title))
$title = 'Dilbert Comic Strip on '.$date; $title = 'Dilbert Comic Strip on ' . $date;
$date = strtotime($date); $date = strtotime($date);
$item = array(); $item = array();
$item['uri'] = $url; $item['uri'] = $url;
$item['title'] = $title; $item['title'] = $title;
$item['author'] = 'Scott Adams'; $item['author'] = 'Scott Adams';
$item['timestamp'] = $date; $item['timestamp'] = $date;
$item['content'] = '<img src="'.$comic.'" alt="'.$img->alt.'" />'; $item['content'] = '<img src="' . $comic . '" alt="' . $img->alt . '" />';
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }
?>

View file

@ -1,11 +1,9 @@
<?php <?php
require_once('Shimmie2Bridge.php'); require_once('Shimmie2Bridge.php');
class DollbooruBridge extends Shimmie2Bridge{ class DollbooruBridge extends Shimmie2Bridge {
const MAINTAINER = 'mitsukarenai';
const MAINTAINER = "mitsukarenai"; const NAME = 'Dollbooru';
const NAME = "Dollbooru"; const URI = 'http://dollbooru.org/';
const URI = "http://dollbooru.org/"; const DESCRIPTION = 'Returns images from given page';
const DESCRIPTION = "Returns images from given page";
} }

View file

@ -1,41 +1,42 @@
<?php <?php
class DuckDuckGoBridge extends BridgeAbstract{ class DuckDuckGoBridge extends BridgeAbstract {
const MAINTAINER = "Astalaseven"; const MAINTAINER = 'Astalaseven';
const NAME = "DuckDuckGo"; const NAME = 'DuckDuckGo';
const URI = "https://duckduckgo.com/"; const URI = 'https://duckduckgo.com/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns results from DuckDuckGo."; const DESCRIPTION = 'Returns results from DuckDuckGo.';
const SORT_DATE = '+sort:date'; const SORT_DATE = '+sort:date';
const SORT_RELEVANCE = ''; const SORT_RELEVANCE = '';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'keyword', 'name' => 'keyword',
'required'=>true), 'required' => true
'sort'=>array( ),
'name'=>'sort by', 'sort' => array(
'type'=>'list', 'name' => 'sort by',
'required'=>false, 'type' => 'list',
'values'=>array( 'required' => false,
'date'=>self::SORT_DATE, 'values' => array(
'relevance'=>self::SORT_RELEVANCE 'date' => self::SORT_DATE,
), 'relevance' => self::SORT_RELEVANCE
'defaultValue'=>self::SORT_DATE ),
) 'defaultValue' => self::SORT_DATE
)); )
));
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI.'html/?kd=-1&q='.$this->getInput('u').$this->getInput('sort')) $html = getSimpleHTMLDOM(self::URI . 'html/?kd=-1&q=' . $this->getInput('u') . $this->getInput('sort'))
or returnServerError('Could not request DuckDuckGo.'); or returnServerError('Could not request DuckDuckGo.');
foreach($html->find('div.results_links') as $element) { foreach($html->find('div.results_links') as $element){
$item = array(); $item = array();
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;
$item['title'] = $element->find('a', 1)->innertext; $item['title'] = $element->find('a', 1)->innertext;
$item['content'] = $element->find('div.snippet', 0)->plaintext; $item['content'] = $element->find('div.snippet', 0)->plaintext;
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }

View file

@ -1,66 +1,67 @@
<?php <?php
class EZTVBridge extends BridgeAbstract{ class EZTVBridge extends BridgeAbstract {
const MAINTAINER = "alexAubin"; const MAINTAINER = "alexAubin";
const NAME = "EZTV"; const NAME = 'EZTV';
const URI = "https://eztv.ch/"; 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."; 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.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'i'=>array( 'i' => array(
'name'=>'Show ids', 'name' => 'Show ids',
'exampleValue'=>'showID1,showID2,…', 'exampleValue' => 'showID1,showID2,…',
'required'=>true 'required' => true
) )
)); ));
public function collectData(){ public function collectData(){
// Make timestamp from relative released time in table // Make timestamp from relative released time in table
function makeTimestamp($relativeReleaseTime){ function makeTimestamp($relativeReleaseTime){
$relativeDays = 0; $relativeDays = 0;
$relativeHours = 0; $relativeHours = 0;
foreach (explode(" ",$relativeReleaseTime) as $relativeTimeElement) { foreach(explode(" ", $relativeReleaseTime) as $relativeTimeElement){
if (substr($relativeTimeElement,-1) == "d") $relativeDays = substr($relativeTimeElement,0,-1); if(substr($relativeTimeElement, -1) == "d") $relativeDays = substr($relativeTimeElement, 0, -1);
if (substr($relativeTimeElement,-1) == "h") $relativeHours = substr($relativeTimeElement,0,-1); if(substr($relativeTimeElement, -1) == "h") $relativeHours = substr($relativeTimeElement, 0, -1);
} }
return mktime(date('h')-$relativeHours,0,0,date('m'),date('d')-$relativeDays,date('Y')); return mktime(date('h') - $relativeHours, 0, 0, date('m'), date('d') - $relativeDays, date('Y'));
} }
// Loop on show ids // Loop on show ids
$showList = explode(",",$this->getInput('i')); $showList = explode(",", $this->getInput('i'));
foreach($showList as $showID){ foreach($showList as $showID){
// Get show page // Get show page
$html = getSimpleHTMLDOM(self::URI.'shows/'.rawurlencode($showID).'/') $html = getSimpleHTMLDOM(self::URI . 'shows/' . rawurlencode($showID) . '/')
or returnServerError('Could not request EZTV for id "'.$showID.'"'); or returnServerError('Could not request EZTV for id "' . $showID . '"');
// Loop on each element that look like an episode entry... // Loop on each element that look like an episode entry...
foreach($html->find('.forum_header_border') as $element) { foreach($html->find('.forum_header_border') as $element){
// Filter entries that are not episode entries // Filter entries that are not episode entries
$ep = $element->find('td',1); $ep = $element->find('td', 1);
if (empty($ep)) continue; if(empty($ep)) continue;
$epinfo = $ep->find('.epinfo',0); $epinfo = $ep->find('.epinfo', 0);
$released = $element->find('td',3); $released = $element->find('td', 3);
if (empty($epinfo)) continue; if(empty($epinfo)) continue;
if (empty($released->plaintext)) continue; if(empty($released->plaintext)) continue;
// Filter entries that are older than 1 week // Filter entries that are older than 1 week
if ($released->plaintext == '&gt;1 week') continue; if($released->plaintext == '&gt;1 week') continue;
// Fill item // Fill item
$item = array(); $item = array();
$item['uri'] = self::URI.$epinfo->href; $item['uri'] = self::URI . $epinfo->href;
$item['id'] = $item['uri']; $item['id'] = $item['uri'];
$item['timestamp'] = makeTimestamp($released->plaintext); $item['timestamp'] = makeTimestamp($released->plaintext);
$item['title'] = $epinfo->plaintext; $item['title'] = $epinfo->plaintext;
$item['content'] = $epinfo->alt; $item['content'] = $epinfo->alt;
if(isset($item['title'])) if(isset($item['title']))
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }
} }

View file

@ -1,21 +1,21 @@
<?php <?php
class EliteDangerousGalnetBridge extends BridgeAbstract class EliteDangerousGalnetBridge extends BridgeAbstract {
{
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() const MAINTAINER = 'corenting';
{ const NAME = 'Elite: Dangerous Galnet';
$html = getSimpleHTMLDOM(self::URI) const URI = 'https://community.elitedangerous.com/galnet/';
or returnServerError('Error while downloading the website content'); const CACHE_TIMEOUT = 7200; // 2h
foreach($html->find('div.article') as $element) { const DESCRIPTION = 'Returns the latest page of news from Galnet';
public function collectData(){
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Error while downloading the website content');
foreach($html->find('div.article') as $element){
$item = array(); $item = array();
$uri = $element->find('h3 a', 0)->href; $uri = $element->find('h3 a', 0)->href;
$uri = self::URI . substr($uri,strlen('/galnet/')); $uri = self::URI . substr($uri, strlen('/galnet/'));
$item['uri'] = $uri; $item['uri'] = $uri;
$title = $element->find('h3 a', 0)->plaintext; $title = $element->find('h3 a', 0)->plaintext;

View file

@ -1,22 +1,23 @@
<?php <?php
class ElsevierBridge extends BridgeAbstract{ class ElsevierBridge extends BridgeAbstract {
const MAINTAINER = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
const NAME = 'Elsevier journals recent articles'; const NAME = 'Elsevier journals recent articles';
const URI = 'http://www.journals.elsevier.com/'; const URI = 'http://www.journals.elsevier.com/';
const CACHE_TIMEOUT = 43200; //12h const CACHE_TIMEOUT = 43200; //12h
const DESCRIPTION = 'Returns the recent articles published in Elsevier journals'; const DESCRIPTION = 'Returns the recent articles published in Elsevier journals';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'j'=>array( 'j' => array(
'name'=>'Journal name', 'name' => 'Journal name',
'required'=>true, 'required' => true,
'exampleValue'=>'academic-pediactrics', 'exampleValue' => 'academic-pediactrics',
'title'=>'Insert html-part of your journal' 'title' => 'Insert html-part of your journal'
) )
)); ));
// Extracts the list of names from an article as string // Extracts the list of names from an article as string
private function ExtractArticleName ($article){ private function extractArticleName($article){
$names = $article->find('small', 0); $names = $article->find('small', 0);
if($names) if($names)
return trim($names->plaintext); return trim($names->plaintext);
@ -24,7 +25,7 @@ class ElsevierBridge extends BridgeAbstract{
} }
// Extracts the timestamp from an article // Extracts the timestamp from an article
private function ExtractArticleTimestamp ($article){ private function extractArticleTimestamp($article){
$time = $article->find('.article-info', 0); $time = $article->find('.article-info', 0);
if($time){ if($time){
$timestring = trim($time->plaintext); $timestring = trim($time->plaintext);
@ -48,7 +49,7 @@ class ElsevierBridge extends BridgeAbstract{
} }
// Extracts the content from an article // Extracts the content from an article
private function ExtractArticleContent ($article){ private function extractArticleContent($article){
$content = $article->find('.article-content', 0); $content = $article->find('.article-content', 0);
if($content){ if($content){
return trim($content->plaintext); return trim($content->plaintext);
@ -58,17 +59,17 @@ class ElsevierBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$uri = self::URI . $this->getInput('j') . '/recent-articles/'; $uri = self::URI . $this->getInput('j') . '/recent-articles/';
$html = getSimpleHTMLDOM($uri) or returnServerError('No results for Elsevier journal '.$this->getInput('j')); $html = getSimpleHTMLDOM($uri)
or returnServerError('No results for Elsevier journal ' . $this->getInput('j'));
foreach($html->find('.pod-listing') as $article){ foreach($html->find('.pod-listing') as $article){
$item = array(); $item = array();
$item['uri'] = $article->find('.pod-listing-header>a',0)->getAttribute('href').'?np=y'; $item['uri'] = $article->find('.pod-listing-header>a', 0)->getAttribute('href') . '?np=y';
$item['title'] = $article->find('.pod-listing-header>a',0)->plaintext; $item['title'] = $article->find('.pod-listing-header>a', 0)->plaintext;
$item['author'] = $this->ExtractArticleName($article); $item['author'] = $this->extractArticleName($article);
$item['timestamp'] = $this->ExtractArticleTimestamp($article); $item['timestamp'] = $this->extractArticleTimestamp($article);
$item['content'] = $this->ExtractArticleContent($article); $item['content'] = $this->extractArticleContent($article);
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }
?>

View file

@ -1,30 +1,37 @@
<?php <?php
class EstCeQuonMetEnProdBridge extends BridgeAbstract { class EstCeQuonMetEnProdBridge extends BridgeAbstract {
const MAINTAINER = 'ORelio'; const MAINTAINER = 'ORelio';
const NAME = 'Est-ce qu\'on met en prod aujourd\'hui ?'; const NAME = 'Est-ce qu\'on met en prod aujourd\'hui ?';
const URI = 'https://www.estcequonmetenprodaujourdhui.info/'; const URI = 'https://www.estcequonmetenprodaujourdhui.info/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = 'Should we put a website in production today? (French)'; const DESCRIPTION = 'Should we put a website in production today? (French)';
public function collectData(){ public function collectData(){
function ExtractFromDelimiters($string, $start, $end) { function extractFromDelimiters($string, $start, $end){
if (strpos($string, $start) !== false) { if(strpos($string, $start) !== false){
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
} return false; }
}
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request EstCeQuonMetEnProd: '.$this->getURI()); return false;
}
$item = array(); $html = getSimpleHTMLDOM($this->getURI())
$item['uri'] = $this->getURI().'#'.date('Y-m-d'); or returnServerError('Could not request EstCeQuonMetEnProd: ' . $this->getURI());
$item['title'] = $this->getName();
$item['author'] = 'Nicolas Hoffmann'; $item = array();
$item['timestamp'] = strtotime('today midnight'); $item['uri'] = $this->getURI() . '#' . date('Y-m-d');
$item['content'] = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />'))); $item['title'] = $this->getName();
$this->items[] = $item; $item['author'] = 'Nicolas Hoffmann';
} $item['timestamp'] = strtotime('today midnight');
$item['content'] = str_replace(
'src="/',
'src="' . $this->getURI(),
trim(extractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />'))
);
$this->items[] = $item;
}
} }
?>

View file

@ -1,44 +1,46 @@
<?php <?php
class FB2Bridge extends BridgeAbstract{ class FB2Bridge extends BridgeAbstract {
const MAINTAINER = "teromene"; const MAINTAINER = 'teromene';
const NAME = "Facebook Alternate"; const NAME = 'Facebook Alternate';
const URI = "https://www.facebook.com/"; const URI = 'https://www.facebook.com/';
const CACHE_TIMEOUT = 1000; const CACHE_TIMEOUT = 1000;
const DESCRIPTION = "Input a page title or a profile log. For a profile log, please insert the parameter as follow : myExamplePage/132621766841117"; const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
please insert the parameter as follow : myExamplePage/132621766841117';
const PARAMETERS =array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'Username', 'name' => 'Username',
'required'=>true 'required' => true
) )
)); ));
public function collectData(){
public function collectData() { function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){
function ExtractFromDelimiters($string, $start, $end) {
if (strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
} return false; }
return false;
} }
//Utility function for cleaning a Facebook link //Utility function for cleaning a Facebook link
$unescape_fb_link = function ($matches) { $unescape_fb_link = function($matches){
if (is_array($matches) && count($matches) > 1) { if(is_array($matches) && count($matches) > 1){
$link = $matches[1]; $link = $matches[1];
if (strpos($link, '/') === 0) if(strpos($link, '/') === 0)
$link = self::URI.$link.'"'; $link = self::URI . $link . '"';
if (strpos($link, 'facebook.com/l.php?u=') !== false) if(strpos($link, 'facebook.com/l.php?u=') !== false)
$link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&')); $link = urldecode(extractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
return ' href="'.$link.'"'; return ' href="' . $link . '"';
} }
}; };
//Utility function for converting facebook emoticons //Utility function for converting facebook emoticons
$unescape_fb_emote = function ($matches) { $unescape_fb_emote = function($matches){
static $facebook_emoticons = array( static $facebook_emoticons = array(
'smile' => ':)', 'smile' => ':)',
'frown' => ':(', 'frown' => ':(',
@ -70,21 +72,23 @@ class FB2Bridge extends BridgeAbstract{
return $matches[0]; return $matches[0];
}; };
if($this->getInput('u') !== NULL) { if($this->getInput('u') !== null){
$page = "https://touch.facebook.com/" . $this->getInput('u'); $page = 'https://touch.facebook.com/' . $this->getInput('u');
$cookies = $this->getCookies($page); $cookies = $this->getCookies($page);
$pageID = $this->getPageID($page, $cookies); $pageID = $this->getPageID($page, $cookies);
if($pageID === null) { if($pageID === null){
echo <<<EOD
echo "Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge"; Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
EOD;
die(); die();
} }
} }
//Build the string for the first request //Build the string for the first request
$requestString = "https://touch.facebook.com/pages_reaction_units/more/?page_id=" . $pageID . "&cursor={\"card_id\"%3A\"videos\"%2C\"has_next_page\"%3Atrue}&surface=mobile_page_home&unit_count=8"; $requestString = 'https://touch.facebook.com/pages_reaction_units/more/?page_id='
. $pageID
. '&cursor={"card_id"%3A"videos"%2C"has_next_page"%3Atrue}&surface=mobile_page_home&unit_count=8';
$fileContent = file_get_contents($requestString); $fileContent = file_get_contents($requestString);
@ -92,79 +96,93 @@ class FB2Bridge extends BridgeAbstract{
$maxArticle = 3; $maxArticle = 3;
$html = $this->buildContent($fileContent); $html = $this->buildContent($fileContent);
$author = $this->getInput('u'); $author = $this->getInput('u');
foreach($html->find("article") as $content) { foreach($html->find("article") as $content){
$item = array(); $item = array();
$item['uri'] = "http://touch.facebook.com"
$item['uri'] = "http://touch.facebook.com" . $content->find("div._52jc", 0)->find("a", 0)->getAttribute("href"); . $content->find("div._52jc", 0)->find("a", 0)->getAttribute("href");
$content->find("header", 0)->innertext = ""; $content->find("header", 0)->innertext = "";
$content->find("footer", 0)->innertext = ""; $content->find("footer", 0)->innertext = "";
//Remove html nodes, keep only img, links, basic formatting //Remove html nodes, keep only img, links, basic formatting
$content = strip_tags($content,'<a><img><i><u><br><p>'); $content = strip_tags($content, '<a><img><i><u><br><p>');
//Adapt link hrefs: convert relative links into absolute links and bypass external link redirection //Adapt link hrefs: convert relative links into absolute links and bypass external link redirection
$content = preg_replace_callback('/ href=\"([^"]+)\"/i', $unescape_fb_link, $content); $content = preg_replace_callback('/ href=\"([^"]+)\"/i', $unescape_fb_link, $content);
//Clean useless html tag properties and fix link closing tags //Clean useless html tag properties and fix link closing tags
foreach (array('onmouseover', 'onclick', 'target', 'ajaxify', 'tabindex', foreach (array(
'class', 'style', 'data-[^=]*', 'aria-[^=]*', 'role', 'rel', 'id') as $property_name) 'onmouseover',
$content = preg_replace('/ '.$property_name.'=\"[^"]*\"/i', '', $content); 'onclick',
'target',
'ajaxify',
'tabindex',
'class',
'style',
'data-[^=]*',
'aria-[^=]*',
'role',
'rel',
'id') as $property_name)
$content = preg_replace('/ ' . $property_name . '=\"[^"]*\"/i', '', $content);
$content = preg_replace('/<\/a [^>]+>/i', '</a>', $content); $content = preg_replace('/<\/a [^>]+>/i', '</a>', $content);
//Convert textual representation of emoticons eg "<i><u>smile emoticon</u></i>" back to ASCII emoticons eg ":)" //Convert textual representation of emoticons eg
// "<i><u>smile emoticon</u></i>" back to ASCII emoticons eg ":)"
$content = preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', $unescape_fb_emote, $content); $content = preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', $unescape_fb_emote, $content);
$item['content'] = $content; $item['content'] = $content;
$title = $author; $title = $author;
if (strlen($title) > 24) if (strlen($title) > 24)
$title = substr($title, 0, strpos(wordwrap($title, 24), "\n")).'...'; $title = substr($title, 0, strpos(wordwrap($title, 24), "\n")) . '...';
$title = $title.' | '.strip_tags($content); $title = $title . ' | ' . strip_tags($content);
if (strlen($title) > 64) if (strlen($title) > 64)
$title = substr($title, 0, strpos(wordwrap($title, 64), "\n")).'...'; $title = substr($title, 0, strpos(wordwrap($title, 64), "\n")) . '...';
$item['title'] = $title; $item['title'] = $title;
$item['author'] = $author; $item['author'] = $author;
array_push($this->items, $item); array_push($this->items, $item);
} }
} }
// Currently not used. Is used to get more than only 3 elements, as they appear on another page. // Currently not used. Is used to get more than only 3 elements, as they appear on another page.
private function computeNextLink($string, $pageID) { private function computeNextLink($string, $pageID){
$regex = "/timeline_unit\\\\\\\\u00253A1\\\\\\\\u00253A([0-9]*)\\\\\\\\u00253A([0-9]*)\\\\\\\\u00253A([0-9]*)\\\\\\\\u00253A([0-9]*)/"; $regex = "/timeline_unit\\\\\\\\u00253A1\\\\\\\\u00253A([0-9]*)\\\\\\\\u00253A([0-9]*)\\\\\\\\u00253A([0-9]*)\\\\\\\\u00253A([0-9]*)/";
preg_match($regex, $string, $result); preg_match($regex, $string, $result);
return "https://touch.facebook.com/pages_reaction_units/more/?page_id=".$pageID."&cursor=%7B%22timeline_cursor%22%3A%22timeline_unit%3A1%3A".$result[1]."%3A".$result[2]."%3A".$result[3]."%3A".$result[4]."%22%2C%22timeline_section_cursor%22%3A%7B%7D%2C%22has_next_page%22%3Atrue%7D&surface=mobile_page_home&unit_count=3"; return "https://touch.facebook.com/pages_reaction_units/more/?page_id="
. $pageID
. "&cursor=%7B%22timeline_cursor%22%3A%22timeline_unit%3A1%3A"
. $result[1]
. "%3A"
. $result[2]
. "%3A"
. $result[3]
. "%3A"
. $result[4]
. "%22%2C%22timeline_section_cursor%22%3A%7B%7D%2C%22has_next_page%22%3Atrue%7D&surface=mobile_page_home&unit_count=3";
} }
//Builds the HTML from the encoded JS that Facebook provides. //Builds the HTML from the encoded JS that Facebook provides.
private function buildContent($pageContent) { private function buildContent($pageContent){
$regex = "/\\\"html\\\":\\\"(.*?)\\\",\\\"replace/"; $regex = "/\\\"html\\\":\\\"(.*?)\\\",\\\"replace/";
preg_match($regex, $pageContent, $result); preg_match($regex, $pageContent, $result);
return str_get_html(html_entity_decode(json_decode('"' . $result[1] . '"'))); return str_get_html(html_entity_decode(json_decode('"' . $result[1] . '"')));
} }
//Builds the cookie from the page, as Facebook sometimes refuses to give the page if no cookie is provided. //Builds the cookie from the page, as Facebook sometimes refuses to give
private function getCookies($pageURL) { //the page if no cookie is provided.
private function getCookies($pageURL){
$ctx = stream_context_create(array( $ctx = stream_context_create(array(
'http' => array( 'http' => array(
@ -177,25 +195,24 @@ class FB2Bridge extends BridgeAbstract{
//First request to get the cookie //First request to get the cookie
$cookies = ""; $cookies = "";
foreach ($http_response_header as $hdr) { foreach($http_response_header as $hdr){
if(strpos($hdr, "Set-Cookie") !== false) { if(strpos($hdr, "Set-Cookie") !== false){
$cLine = explode(":", $hdr)[1]; $cLine = explode(":", $hdr)[1];
$cLine = explode(";", $cLine)[0]; $cLine = explode(";", $cLine)[0];
$cookies .= ";".$cLine; $cookies .= ";" . $cLine;
} }
} }
return substr($cookies, 1); return substr($cookies, 1);
} }
//Get the page ID from the Facebook page. //Get the page ID from the Facebook page.
private function getPageID($page, $cookies) { private function getPageID($page, $cookies){
$context = stream_context_create(array( $context = stream_context_create(array(
'http' => array( 'http' => array(
'user_agent' => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0", 'user_agent' => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0",
'header' => 'Cookie: ' .$cookies 'header' => 'Cookie: ' . $cookies
) )
) )
); );
@ -206,10 +223,8 @@ class FB2Bridge extends BridgeAbstract{
$regex = "/page_id=([0-9]*)&/"; $regex = "/page_id=([0-9]*)&/";
preg_match($regex, $pageContent, $matches); preg_match($regex, $pageContent, $matches);
if(count($matches) > 0) { if(count($matches) > 0){
return $matches[1]; return $matches[1];
} }
//Get the page ID if we do have a captcha //Get the page ID if we do have a captcha
@ -220,15 +235,15 @@ class FB2Bridge extends BridgeAbstract{
} }
public function getName() { public function getName(){
return (isset($this->name) ? $this->name.' - ' : '').'Facebook Bridge'; return (isset($this->name) ? $this->name . ' - ' : '') . 'Facebook Bridge';
} }
public function getURI() { public function getURI(){
return 'http://facebook.com'; return 'http://facebook.com';
} }
public function getCacheDuration() { public function getCacheDuration(){
return 60 * 60 * 3; // 5 minutes return 60 * 60 * 3; // 5 minutes
} }
} }

View file

@ -1,46 +1,49 @@
<?php <?php
class FacebookBridge extends BridgeAbstract{ class FacebookBridge extends BridgeAbstract {
const MAINTAINER = "teromene"; const MAINTAINER = 'teromene';
const NAME = "Facebook"; const NAME = 'Facebook';
const URI = "https://www.facebook.com/"; const URI = 'https://www.facebook.com/';
const CACHE_TIMEOUT = 300; // 5min 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"; const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
please insert the parameter as follow : myExamplePage/132621766841117';
const PARAMETERS =array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'Username', 'name' => 'Username',
'required'=>true 'required' => true
) )
)); ));
private $authorName=''; private $authorName = '';
public function collectData(){ public function collectData(){
//Extract a string using start and end delimiters //Extract a string using start and end delimiters
function ExtractFromDelimiters($string, $start, $end) { function extractFromDelimiters($string, $start, $end){
if (strpos($string, $start) !== false) { if(strpos($string, $start) !== false){
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
} return false; }
return false;
} }
//Utility function for cleaning a Facebook link //Utility function for cleaning a Facebook link
$unescape_fb_link = function ($matches) { $unescape_fb_link = function($matches){
if (is_array($matches) && count($matches) > 1) { if(is_array($matches) && count($matches) > 1){
$link = $matches[1]; $link = $matches[1];
if (strpos($link, '/') === 0) if(strpos($link, '/') === 0)
$link = self::URI.$link.'"'; $link = self::URI . $link . '"';
if (strpos($link, 'facebook.com/l.php?u=') !== false) if(strpos($link, 'facebook.com/l.php?u=') !== false)
$link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&')); $link = urldecode(extractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
return ' href="'.$link.'"'; return ' href="' . $link . '"';
} }
}; };
//Utility function for converting facebook emoticons //Utility function for converting facebook emoticons
$unescape_fb_emote = function ($matches) { $unescape_fb_emote = function($matches){
static $facebook_emoticons = array( static $facebook_emoticons = array(
'smile' => ':)', 'smile' => ':)',
'frown' => ':(', 'frown' => ':(',
@ -87,14 +90,18 @@ class FacebookBridge extends BridgeAbstract{
$http_options = array( $http_options = array(
'http' => array( 'http' => array(
'method' => 'POST', 'method' => 'POST',
'user_agent'=> ini_get('user_agent'), 'user_agent' => ini_get('user_agent'),
'header'=>array("Content-type: application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n"), 'header' => array("Content-type:
'content' => http_build_query($captcha_fields), application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n"),
'content' => http_build_query($captcha_fields)
), ),
); );
$context = stream_context_create($http_options); $context = stream_context_create($http_options);
$html = getContents($captcha_action, false, $context); $html = getContents($captcha_action, false, $context);
if ($html === FALSE) { returnServerError('Failed to submit captcha response back to Facebook'); }
if($html === false){
returnServerError('Failed to submit captcha response back to Facebook');
}
unset($_SESSION['captcha_fields']); unset($_SESSION['captcha_fields']);
$html = str_get_html($html); $html = str_get_html($html);
} }
@ -103,13 +110,13 @@ class FacebookBridge extends BridgeAbstract{
} }
//Retrieve page contents //Retrieve page contents
if (is_null($html)) { if(is_null($html)){
if (!strpos($this->getInput('u'), "/")) { if(!strpos($this->getInput('u'), "/")){
$html = getSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1') $html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1')
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
} else { } else {
$html = getSimpleHTMLDOM(self::URI.'pages/'.$this->getInput('u').'?_fb_noscript=1') $html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1')
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
} }
} }
@ -128,59 +135,102 @@ class FacebookBridge extends BridgeAbstract{
//Show captcha filling form to the viewer, proxying the captcha image //Show captcha filling form to the viewer, proxying the captcha image
$img = base64_encode(getContents($captcha->find('img', 0)->src)); $img = base64_encode(getContents($captcha->find('img', 0)->src));
header('HTTP/1.1 500 '.Http::getMessageForCode(500)); header('HTTP/1.1 500 ' . Http::getMessageForCode(500));
header('Content-Type: text/html'); header('Content-Type: text/html');
die('<form method="post" action="?'.$_SERVER['QUERY_STRING'].'">' $message = <<<EOD
.'<h2>Facebook captcha challenge</h2>' <form method="post" action="?{$_SERVER['QUERY_STRING']}">
.'<p>Unfortunately, rss-bridge cannot fetch the requested page.<br />' <h2>Facebook captcha challenge</h2>
.'Facebook wants rss-bridge to resolve the following captcha:</p>' <p>Unfortunately, rss-bridge cannot fetch the requested page.<br />
.'<p><img src="data:image/png;base64,'.$img.'" /></p>' Facebook wants rss-bridge to resolve the following captcha:</p>
.'<p><b>Response:</b> <input name="captcha_response" placeholder="please fill in" />' <p><img src="data:image/png;base64,{$img}" /></p>
.'<input type="submit" value="Submit!" /></p>' <p><b>Response:</b> <input name="captcha_response" placeholder="please fill in" />
.'</form>'); <input type="submit" value="Submit!" /></p>
</form>
EOD;
die($message);
} }
//No captcha? We can carry on retrieving page contents :) //No captcha? We can carry on retrieving page contents :)
$element = $html->find('#pagelet_timeline_main_column')[0]->children(0)->children(0)->children(0)->next_sibling()->children(0); $element = $html
->find('#pagelet_timeline_main_column')[0]
->children(0)
->children(0)
->children(0)
->next_sibling()
->children(0);
if(isset($element)) { if(isset($element)){
$author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext); $author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext);
$profilePic = 'https://graph.facebook.com/'.$this->getInput('u').'/picture?width=200&amp;height=200'; $profilePic = 'https://graph.facebook.com/'
. $this->getInput('u')
. '/picture?width=200&amp;height=200';
$this->authorName = $author; $this->authorName = $author;
foreach($element->children() as $post) { foreach($element->children() as $post){
// Ignore summary posts // Ignore summary posts
if ( strpos($post->class, '_3xaf') !== false ) continue; if(strpos($post->class, '_3xaf') !== false) continue;
$item = array(); $item = array();
if (count($post->find('abbr')) > 0) { if(count($post->find('abbr')) > 0){
//Retrieve post contents //Retrieve post contents
$content = preg_replace('/(?i)><div class=\"clearfix([^>]+)>(.+?)div\ class=\"userContent\"/i', '', $post); $content = preg_replace(
$content = preg_replace('/(?i)><div class=\"_59tj([^>]+)>(.+?)<\/div><\/div><a/i', '', $content); '/(?i)><div class=\"clearfix([^>]+)>(.+?)div\ class=\"userContent\"/i',
$content = preg_replace('/(?i)><div class=\"_3dp([^>]+)>(.+?)div\ class=\"[^u]+userContent\"/i', '', $content); '',
$content = preg_replace('/(?i)><div class=\"_4l5([^>]+)>(.+?)<\/div>/i', '', $content); $post);
$content = preg_replace(
'/(?i)><div class=\"_59tj([^>]+)>(.+?)<\/div><\/div><a/i',
'',
$content);
$content = preg_replace(
'/(?i)><div class=\"_3dp([^>]+)>(.+?)div\ class=\"[^u]+userContent\"/i',
'',
$content);
$content = preg_replace(
'/(?i)><div class=\"_4l5([^>]+)>(.+?)<\/div>/i',
'',
$content);
//Remove html nodes, keep only img, links, basic formatting //Remove html nodes, keep only img, links, basic formatting
$content = strip_tags($content,'<a><img><i><u><br><p>'); $content = strip_tags($content, '<a><img><i><u><br><p>');
//Adapt link hrefs: convert relative links into absolute links and bypass external link redirection //Adapt link hrefs: convert relative links into absolute links and bypass external link redirection
$content = preg_replace_callback('/ href=\"([^"]+)\"/i', $unescape_fb_link, $content); $content = preg_replace_callback('/ href=\"([^"]+)\"/i', $unescape_fb_link, $content);
//Clean useless html tag properties and fix link closing tags //Clean useless html tag properties and fix link closing tags
foreach (array('onmouseover', 'onclick', 'target', 'ajaxify', 'tabindex', foreach (array(
'class', 'style', 'data-[^=]*', 'aria-[^=]*', 'role', 'rel', 'id') as $property_name) 'onmouseover',
$content = preg_replace('/ '.$property_name.'=\"[^"]*\"/i', '', $content); 'onclick',
'target',
'ajaxify',
'tabindex',
'class',
'style',
'data-[^=]*',
'aria-[^=]*',
'role',
'rel',
'id') as $property_name)
$content = preg_replace('/ ' . $property_name . '=\"[^"]*\"/i', '', $content);
$content = preg_replace('/<\/a [^>]+>/i', '</a>', $content); $content = preg_replace('/<\/a [^>]+>/i', '</a>', $content);
//Convert textual representation of emoticons eg "<i><u>smile emoticon</u></i>" back to ASCII emoticons eg ":)" //Convert textual representation of emoticons eg
$content = preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', $unescape_fb_emote, $content); //"<i><u>smile emoticon</u></i>" back to ASCII emoticons eg ":)"
$content = preg_replace_callback(
'/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i',
$unescape_fb_emote,
$content
);
//Retrieve date of the post //Retrieve date of the post
$date = $post->find("abbr")[0]; $date = $post->find("abbr")[0];
if(isset($date) && $date->hasAttribute('data-utime')) { if(isset($date) && $date->hasAttribute('data-utime')){
$date = $date->getAttribute('data-utime'); $date = $date->getAttribute('data-utime');
} else { } else {
$date = 0; $date = 0;
@ -188,14 +238,14 @@ class FacebookBridge extends BridgeAbstract{
//Build title from username and content //Build title from username and content
$title = $author; $title = $author;
if (strlen($title) > 24) if(strlen($title) > 24)
$title = substr($title, 0, strpos(wordwrap($title, 24), "\n")).'...'; $title = substr($title, 0, strpos(wordwrap($title, 24), "\n")) . '...';
$title = $title.' | '.strip_tags($content); $title = $title . ' | ' . strip_tags($content);
if (strlen($title) > 64) if(strlen($title) > 64)
$title = substr($title, 0, strpos(wordwrap($title, 64), "\n")).'...'; $title = substr($title, 0, strpos(wordwrap($title, 64), "\n")) . '...';
//Build and add final item //Build and add final item
$item['uri'] = self::URI.$post->find('abbr')[0]->parent()->getAttribute('href'); $item['uri'] = self::URI . $post->find('abbr')[0]->parent()->getAttribute('href');
$item['content'] = $content; $item['content'] = $content;
$item['title'] = $title; $item['title'] = $title;
$item['author'] = $author; $item['author'] = $author;
@ -206,7 +256,7 @@ class FacebookBridge extends BridgeAbstract{
} }
} }
public function getName() { public function getName(){
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName.' - Facebook Bridge'; return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName . ' - Facebook Bridge';
} }
} }

View file

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

View file

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

View file

@ -5,117 +5,116 @@
*/ */
class FlickrBridge extends BridgeAbstract { class FlickrBridge extends BridgeAbstract {
const MAINTAINER = "logmanoriginal"; const MAINTAINER = 'logmanoriginal';
const NAME = "Flickr Bridge"; const NAME = 'Flickr Bridge';
const URI = "https://www.flickr.com/"; const URI = 'https://www.flickr.com/';
const CACHE_TIMEOUT = 21600; // 6 hours const CACHE_TIMEOUT = 21600; // 6 hours
const DESCRIPTION = "Returns images from Flickr"; const DESCRIPTION = 'Returns images from Flickr';
const PARAMETERS = array( const PARAMETERS = array(
'Explore' => array(), 'Explore' => array(),
'By keyword' => array( 'By keyword' => array(
'q' => array( 'q' => array(
'name' => 'Keyword', 'name' => 'Keyword',
'type' => 'text', 'type' => 'text',
'required' => true, 'required' => true,
'title' => 'Insert keyword', 'title' => 'Insert keyword',
'exampleValue' => 'bird' 'exampleValue' => 'bird'
) )
), ),
'By username' => array( 'By username' => array(
'u' => array( 'u' => array(
'name' => 'Username', 'name' => 'Username',
'type' => 'text', 'type' => 'text',
'required' => true, 'required' => true,
'title' => 'Insert username (as shown in the address bar)', 'title' => 'Insert username (as shown in the address bar)',
'exampleValue' => 'flickr' 'exampleValue' => 'flickr'
) )
), ),
); );
public function collectData(){ public function collectData(){
switch($this->queriedContext){ switch($this->queriedContext){
case 'Explore': case 'Explore':
$key = 'photos'; $key = 'photos';
$html = getSimpleHTMLDOM(self::URI . 'explore') $html = getSimpleHTMLDOM(self::URI . 'explore')
or returnServerError('Could not request Flickr.'); or returnServerError('Could not request Flickr.');
break; break;
case 'By keyword': case 'By keyword':
$key = 'photos'; $key = 'photos';
$html = getSimpleHTMLDOM(self::URI . 'search/?q=' . urlencode($this->getInput('q')) . '&s=rec') $html = getSimpleHTMLDOM(self::URI . 'search/?q=' . urlencode($this->getInput('q')) . '&s=rec')
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
break; break;
case 'By username': case 'By username':
$key = 'photoPageList'; $key = 'photoPageList';
$html = getSimpleHTMLDOM(self::URI . 'photos/' . urlencode($this->getInput('u'))) $html = getSimpleHTMLDOM(self::URI . 'photos/' . urlencode($this->getInput('u')))
or returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
break; break;
default: default:
returnClientError('Invalid context: ' . $this->queriedContext); returnClientError('Invalid context: ' . $this->queriedContext);
} }
// Find SCRIPT containing JSON data // Find SCRIPT containing JSON data
$model = $html->find('.modelExport', 0); $model = $html->find('.modelExport', 0);
$model_text = $model->innertext; $model_text = $model->innertext;
// Find start and end of JSON data // Find start and end of JSON data
$start = strpos($model_text, 'modelExport:') + strlen('modelExport:'); $start = strpos($model_text, 'modelExport:') + strlen('modelExport:');
$end = strpos($model_text, 'auth:') - strlen('auth:'); $end = strpos($model_text, 'auth:') - strlen('auth:');
// Dissect JSON data and remove trailing comma // Dissect JSON data and remove trailing comma
$model_text = trim(substr($model_text, $start, $end - $start)); $model_text = trim(substr($model_text, $start, $end - $start));
$model_text = substr($model_text, 0, strlen($model_text) - 1); $model_text = substr($model_text, 0, strlen($model_text) - 1);
$model_json = json_decode($model_text, true); $model_json = json_decode($model_text, true);
foreach($html->find('.photo-list-photo-view') as $element){ foreach($html->find('.photo-list-photo-view') as $element){
// Get the styles // Get the styles
$style = explode(';', $element->style); $style = explode(';', $element->style);
// Get the background-image style // Get the background-image style
$backgroundImage = explode(':', end($style)); $backgroundImage = explode(':', end($style));
// URI type : url(//cX.staticflickr.com/X/XXXXX/XXXXXXXXX.jpg) // URI type : url(//cX.staticflickr.com/X/XXXXX/XXXXXXXXX.jpg)
$imageURI = trim(str_replace(['url(', ')'], '', end($backgroundImage))); $imageURI = trim(str_replace(['url(', ')'], '', end($backgroundImage)));
// Get the image ID // Get the image ID
$imageURIs = explode('_', basename($imageURI)); $imageURIs = explode('_', basename($imageURI));
$imageID = reset($imageURIs); $imageID = reset($imageURIs);
// Use JSON data to build items // Use JSON data to build items
foreach(reset($model_json)[0][$key]['_data'] as $element){ foreach(reset($model_json)[0][$key]['_data'] as $element){
if($element['id'] === $imageID){ if($element['id'] === $imageID){
$item = array(); $item = array();
/* Author name depends on scope. On a keyword search the /* Author name depends on scope. On a keyword search the
* author is part of the picture data. On a username search * author is part of the picture data. On a username search
* the author is part of the owner data. * the author is part of the owner data.
*/ */
if(array_key_exists('username', $element)){ if(array_key_exists('username', $element)){
$item['author'] = $element['username']; $item['author'] = $element['username'];
} elseif (array_key_exists('owner', reset($model_json)[0])){ } elseif (array_key_exists('owner', reset($model_json)[0])){
$item['author'] = reset($model_json)[0]['owner']['username']; $item['author'] = reset($model_json)[0]['owner']['username'];
} }
$item['title'] = (array_key_exists('title', $element) ? $element['title'] : 'Untitled'); $item['title'] = (array_key_exists('title', $element) ? $element['title'] : 'Untitled');
$item['uri'] = self::URI . 'photo.gne?id=' . $imageID; $item['uri'] = self::URI . 'photo.gne?id=' . $imageID;
$description = (array_key_exists('description', $element) ? $element['description'] : ''); $description = (array_key_exists('description', $element) ? $element['description'] : '');
$item['content'] = '<a href="' $item['content'] = '<a href="'
. $item['uri'] . $item['uri']
. '"><img src="' . '"><img src="'
. $imageURI . '" /></a>' . $imageURI
. '<br>' . '" /></a><br><p>'
. '<p>' . $description
. $description . '</p>';
. '</p>';
$this->items[] = $item; $this->items[] = $item;
break; break;
} }
} }
} }
} }
} }

View file

@ -1,40 +1,75 @@
<?php <?php
class FootitoBridge extends BridgeAbstract{ class FootitoBridge extends BridgeAbstract {
const MAINTAINER = "superbaillot.net"; const MAINTAINER = 'superbaillot.net';
const NAME = "Footito"; const NAME = 'Footito';
const URI = "http://www.footito.fr/"; const URI = 'http://www.footito.fr/';
const DESCRIPTION = "Footito"; const DESCRIPTION = 'Footito';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Footito.'); or returnServerError('Could not request Footito.');
foreach($html->find('div.post') as $element) { foreach($html->find('div.post') as $element){
$item = array(); $item = array();
$content = trim($element->innertext); $content = trim($element->innertext);
$content = str_replace("<img", "<img style='float : left;'", $content ); $content = str_replace(
$content = str_replace("class=\"logo\"", "style='float : left;'", $content ); "<img",
$content = str_replace("class=\"contenu\"", "style='margin-left : 60px;'", $content ); "<img style='float : left;'",
$content = str_replace("class=\"responsive-comment\"", "style='border-top : 1px #DDD solid; background-color : white; padding : 10px;'", $content ); $content );
$content = str_replace("class=\"jaime\"", "style='display : none;'", $content );
$content = str_replace("class=\"auteur-event responsive\"", "style='display : none;'", $content );
$content = str_replace("class=\"report-abuse-button\"", "style='display : none;'", $content );
$content = str_replace("class=\"reaction clearfix\"", "style='margin : 10px 0px; padding : 5px; border-bottom : 1px #DDD solid;'", $content );
$content = str_replace("class=\"infos\"", "style='font-size : 0.7em;'", $content );
$item['content'] = $content; $content = str_replace(
"class=\"logo\"",
"style='float : left;'",
$content );
$title = $element->find('.contenu .texte ', 0)->plaintext; $content = str_replace(
$item['title'] = $title; "class=\"contenu\"",
"style='margin-left : 60px;'",
$content );
$info = $element->find('div.infos', 0); $content = str_replace(
"class=\"responsive-comment\"",
"style='border-top : 1px #DDD solid; background-color : white; padding : 10px;'",
$content );
$item['timestamp'] = strtotime($info->find('time', 0)->datetime); $content = str_replace(
$item['author'] = $info->find('a.auteur', 0)->plaintext; "class=\"jaime\"",
"style='display : none;'",
$content );
$this->items[] = $item; $content = str_replace(
} "class=\"auteur-event responsive\"",
} "style='display : none;'",
$content );
$content = str_replace(
"class=\"report-abuse-button\"",
"style='display : none;'",
$content );
$content = str_replace(
"class=\"reaction clearfix\"",
"style='margin : 10px 0px; padding : 5px; border-bottom : 1px #DDD solid;'",
$content );
$content = str_replace(
"class=\"infos\"",
"style='font-size : 0.7em;'",
$content );
$item['content'] = $content;
$title = $element->find('.contenu .texte ', 0)->plaintext;
$item['title'] = $title;
$info = $element->find('div.infos', 0);
$item['timestamp'] = strtotime($info->find('time', 0)->datetime);
$item['author'] = $info->find('a.auteur', 0)->plaintext;
$this->items[] = $item;
}
}
} }

View file

@ -1,68 +1,74 @@
<?php <?php
class FourchanBridge extends BridgeAbstract{ class FourchanBridge extends BridgeAbstract {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "4chan"; const NAME = '4chan';
const URI = "https://boards.4chan.org/"; const URI = 'https://boards.4chan.org/';
const CACHE_TIMEOUT = 300; // 5min const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = "Returns posts from the specified thread"; const DESCRIPTION = 'Returns posts from the specified thread';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'c'=>array( 'c' => array(
'name'=>'Thread category', 'name' => 'Thread category',
'required'=>true 'required' => true
), ),
't'=>array( 't' => array(
'name'=>'Thread number', 'name' => 'Thread number',
'type'=>'number', 'type' => 'number',
'required'=>true 'required' => true
) )
)); ));
public function getURI(){ public function getURI(){
return static::URI.$this->getInput('c').'/thread/'.$this->getInput('t'); return static::URI . $this->getInput('c') . '/thread/' . $this->getInput('t');
}
}
public function collectData(){
public function collectData(){
$html = getSimpleHTMLDOM($this->getURI())
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError("Could not request 4chan, thread not found");
or returnServerError("Could not request 4chan, thread not found");
foreach($html->find('div.postContainer') as $element){
foreach($html->find('div.postContainer') as $element) { $item = array();
$item = array(); $item['id'] = $element->find('.post', 0)->getAttribute('id');
$item['id'] = $element->find('.post', 0)->getAttribute('id'); $item['uri'] = $this->getURI() . '#' . $item['id'];
$item['uri'] = $this->getURI().'#'.$item['id']; $item['timestamp'] = $element->find('span.dateTime', 0)->getAttribute('data-utc');
$item['timestamp'] = $element->find('span.dateTime', 0)->getAttribute('data-utc'); $item['author'] = $element->find('span.name', 0)->plaintext;
$item['author'] = $element->find('span.name', 0)->plaintext;
$file = $element->find('.file', 0);
$file=$element->find('.file', 0);
if(!empty($file) ) { if(!empty($file)){
$item['image'] = $element->find('.file a', 0)->href; $item['image'] = $element->find('.file a', 0)->href;
$item['imageThumb'] = $element->find('.file img', 0)->src; $item['imageThumb'] = $element->find('.file img', 0)->src;
if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== FALSE) if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== false)
$item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg'; $item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg';
} }
if(!empty($element->find('span.subject', 0)->innertext )) {
$item['subject'] = $element->find('span.subject', 0)->innertext; if(!empty($element->find('span.subject', 0)->innertext)){
} $item['subject'] = $element->find('span.subject', 0)->innertext;
}
$item['title'] = 'reply '.$item['id'].' | '.$item['author'];
if(isset($item['subject'])){ $item['title'] = 'reply ' . $item['id'] . ' | ' . $item['author'];
$item['title'] = $item['subject'].' - '.$item['title']; if(isset($item['subject'])){
} $item['title'] = $item['subject'] . ' - ' . $item['title'];
}
$content = $element->find('.postMessage', 0)->innertext;
$content = str_replace('href="#p','href="'.$this->getURI().'#p',$content); $content = $element->find('.postMessage', 0)->innertext;
$item['content'] = '<span id="'.$item['id'].'">'.$content.'</span>'; $content = str_replace('href="#p','href="' . $this->getURI() . '#p', $content);
if(isset($item['image'])){ $item['content'] = '<span id="' . $item['id'] . '">' . $content . '</span>';
$item['content'] = '<a href="'.$item['image'].'">'
.'<img alt="'.$item['id'].'" src="'.$item['imageThumb'].'" />' if(isset($item['image'])){
.'</a><br>' $item['content'] = '<a href="'
.$item['content']; . $item['image']
} . '"><img alt="'
$this->items[] = $item; . $item['id']
. '" src="'
. $item['imageThumb']
. '" /></a><br>'
.$item['content'];
}
$this->items[] = $item;
}
$this->items = array_reverse($this->items);
} }
$this->items = array_reverse($this->items);
}
} }

View file

@ -1,173 +1,173 @@
<?php <?php
class FuturaSciencesBridge extends FeedExpander { class FuturaSciencesBridge extends FeedExpander {
const MAINTAINER = 'ORelio'; const MAINTAINER = 'ORelio';
const NAME = 'Futura-Sciences Bridge'; const NAME = 'Futura-Sciences Bridge';
const URI = 'http://www.futura-sciences.com/'; const URI = 'http://www.futura-sciences.com/';
const DESCRIPTION = 'Returns the newest articles.'; const DESCRIPTION = 'Returns the newest articles.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'feed'=> array( 'feed' => array(
'name'=>'Feed', 'name' => 'Feed',
'type'=>'list', 'type' => 'list',
'values'=>array( 'values' => array(
'Les flux multi-magazines'=>array( 'Les flux multi-magazines' => array(
'Les dernières actualités de Futura-Sciences'=>'actualites', 'Les dernières actualités de Futura-Sciences' => 'actualites',
'Les dernières définitions de Futura-Sciences'=>'definitions', 'Les dernières définitions de Futura-Sciences' => 'definitions',
'Les dernières photos de Futura-Sciences'=>'photos', 'Les dernières photos de Futura-Sciences' => 'photos',
'Les dernières questions - réponses de Futura-Sciences'=>'questions-reponses', 'Les dernières questions - réponses de Futura-Sciences' => 'questions-reponses',
'Les derniers dossiers de Futura-Sciences'=>'dossiers' 'Les derniers dossiers de Futura-Sciences' => 'dossiers'
), ),
'Les flux Services'=> array( 'Les flux Services' => array(
'Les cartes virtuelles de Futura-Sciences'=>'services/cartes-virtuelles', 'Les cartes virtuelles de Futura-Sciences' => 'services/cartes-virtuelles',
'Les fonds d\'écran de Futura-Sciences'=>'services/fonds-ecran' 'Les fonds d\'écran de Futura-Sciences' => 'services/fonds-ecran'
), ),
'Les flux Santé'=>array( 'Les flux Santé' => array(
'Les dernières actualités de Futura-Santé'=>'sante/actualites', 'Les dernières actualités de Futura-Santé' => 'sante/actualites',
'Les dernières définitions de Futura-Santé'=>'sante/definitions', 'Les dernières définitions de Futura-Santé' => 'sante/definitions',
'Les dernières questions-réponses de Futura-Santé'=>'sante/question-reponses', 'Les dernières questions-réponses de Futura-Santé' => 'sante/question-reponses',
'Les derniers dossiers de Futura-Santé'=>'sante/dossiers' 'Les derniers dossiers de Futura-Santé' => 'sante/dossiers'
), ),
'Les flux High-Tech'=>array( 'Les flux High-Tech' => array(
'Les dernières actualités de Futura-High-Tech'=>'high-tech/actualites', 'Les dernières actualités de Futura-High-Tech' => 'high-tech/actualites',
'Les dernières astuces de Futura-High-Tech'=>'high-tech/question-reponses', 'Les dernières astuces de Futura-High-Tech' => 'high-tech/question-reponses',
'Les dernières définitions de Futura-High-Tech'=>'high-tech/definitions', 'Les dernières définitions de Futura-High-Tech' => 'high-tech/definitions',
'Les derniers dossiers de Futura-High-Tech'=>'high-tech/dossiers' 'Les derniers dossiers de Futura-High-Tech' => 'high-tech/dossiers'
), ),
'Les flux Espace'=>array( 'Les flux Espace' => array(
'Les dernières actualités de Futura-Espace'=>'espace/actualites', 'Les dernières actualités de Futura-Espace' => 'espace/actualites',
'Les dernières définitions de Futura-Espace'=>'espace/definitions', 'Les dernières définitions de Futura-Espace' => 'espace/definitions',
'Les dernières questions-réponses de Futura-Espace'=>'espace/question-reponses', 'Les dernières questions-réponses de Futura-Espace' => 'espace/question-reponses',
'Les derniers dossiers de Futura-Espace'=>'espace/dossiers' 'Les derniers dossiers de Futura-Espace' => 'espace/dossiers'
), ),
'Les flux Environnement'=>array( 'Les flux Environnement' => array(
'Les dernières actualités de Futura-Environnement'=>'environnement/actualites', 'Les dernières actualités de Futura-Environnement' => 'environnement/actualites',
'Les dernières définitions de Futura-Environnement'=>'environnement/definitions', 'Les dernières définitions de Futura-Environnement' => 'environnement/definitions',
'Les dernières questions-réponses de Futura-Environnement'=>'environnement/question-reponses', 'Les dernières questions-réponses de Futura-Environnement' => 'environnement/question-reponses',
'Les derniers dossiers de Futura-Environnement'=>'environnement/dossiers' 'Les derniers dossiers de Futura-Environnement' => 'environnement/dossiers'
), ),
'Les flux Maison'=>array( 'Les flux Maison' => array(
'Les dernières actualités de Futura-Maison'=>'maison/actualites', 'Les dernières actualités de Futura-Maison' => 'maison/actualites',
'Les dernières astuces de Futura-Maison'=>'maison/question-reponses', 'Les dernières astuces de Futura-Maison' => 'maison/question-reponses',
'Les dernières définitions de Futura-Maison'=>'maison/definitions', 'Les dernières définitions de Futura-Maison' => 'maison/definitions',
'Les derniers dossiers de Futura-Maison'=>'maison/dossiers' 'Les derniers dossiers de Futura-Maison' => 'maison/dossiers'
), ),
'Les flux Nature'=>array( 'Les flux Nature' => array(
'Les dernières actualités de Futura-Nature'=>'nature/actualites', 'Les dernières actualités de Futura-Nature' => 'nature/actualites',
'Les dernières définitions de Futura-Nature'=>'nature/definitions', 'Les dernières définitions de Futura-Nature' => 'nature/definitions',
'Les dernières questions-réponses de Futura-Nature'=>'nature/question-reponses', 'Les dernières questions-réponses de Futura-Nature' => 'nature/question-reponses',
'Les derniers dossiers de Futura-Nature'=>'nature/dossiers' 'Les derniers dossiers de Futura-Nature' => 'nature/dossiers'
), ),
'Les flux Terre'=>array( 'Les flux Terre' => array(
'Les dernières actualités de Futura-Terre'=>'terre/actualites', 'Les dernières actualités de Futura-Terre' => 'terre/actualites',
'Les dernières définitions de Futura-Terre'=>'terre/definitions', 'Les dernières définitions de Futura-Terre' => 'terre/definitions',
'Les dernières questions-réponses de Futura-Terre'=>'terre/question-reponses', 'Les dernières questions-réponses de Futura-Terre' => 'terre/question-reponses',
'Les derniers dossiers de Futura-Terre'=>'terre/dossiers' 'Les derniers dossiers de Futura-Terre' => 'terre/dossiers'
), ),
'Les flux Matière'=>array( 'Les flux Matière' => array(
'Les dernières actualités de Futura-Matière'=>'matiere/actualites', 'Les dernières actualités de Futura-Matière' => 'matiere/actualites',
'Les dernières définitions de Futura-Matière'=>'matiere/definitions', 'Les dernières définitions de Futura-Matière' => 'matiere/definitions',
'Les dernières questions-réponses de Futura-Matière'=>'matiere/question-reponses', 'Les dernières questions-réponses de Futura-Matière' => 'matiere/question-reponses',
'Les derniers dossiers de Futura-Matière'=>'matiere/dossiers' 'Les derniers dossiers de Futura-Matière' => 'matiere/dossiers'
), ),
'Les flux Mathématiques'=>array( 'Les flux Mathématiques' => array(
'Les dernières actualités de Futura-Mathématiques'=>'mathematiques/actualites', 'Les dernières actualités de Futura-Mathématiques' => 'mathematiques/actualites',
'Les derniers dossiers de Futura-Mathématiques'=>'mathematiques/dossiers' 'Les derniers dossiers de Futura-Mathématiques' => 'mathematiques/dossiers'
) )
) )
) )
)); ));
public function collectData(){ public function collectData(){
$url = self::URI . 'rss/' . $this->getInput('feed') . '.xml'; $url = self::URI . 'rss/' . $this->getInput('feed') . '.xml';
$this->collectExpandableDatas($url, 10); $this->collectExpandableDatas($url, 10);
} }
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['uri'] = str_replace('#xtor=RSS-8', '', $item['uri']); $item['uri'] = str_replace('#xtor=RSS-8', '', $item['uri']);
$article = getSimpleHTMLDOMCached($item['uri']) $article = getSimpleHTMLDOMCached($item['uri'])
or returnServerError('Could not request Futura-Sciences: ' . $item['uri']); or returnServerError('Could not request Futura-Sciences: ' . $item['uri']);
$item['content'] = $this->ExtractArticleContent($article); $item['content'] = $this->extractArticleContent($article);
$author = $this->ExtractAuthor($article); $author = $this->extractAuthor($article);
$item['author'] = empty($author) ? $item['author'] : $author; $item['author'] = empty($author) ? $item['author'] : $author;
return $item; return $item;
} }
private function StripWithDelimiters($string, $start, $end) { private function stripWithDelimiters($string, $start, $end){
while (strpos($string, $start) !== false) { while(strpos($string, $start) !== false){
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
} return $string; } return $string;
} }
private function StripRecursiveHTMLSection($string, $tag_name, $tag_start) { private function stripRecursiveHTMLSection($string, $tag_name, $tag_start){
$open_tag = '<'.$tag_name; $open_tag = '<' . $tag_name;
$close_tag = '</'.$tag_name.'>'; $close_tag = '</' . $tag_name . '>';
$close_tag_length = strlen($close_tag); $close_tag_length = strlen($close_tag);
if (strpos($tag_start, $open_tag) === 0) { if(strpos($tag_start, $open_tag) === 0){
while (strpos($string, $tag_start) !== false) { while(strpos($string, $tag_start) !== false){
$max_recursion = 100; $max_recursion = 100;
$section_to_remove = null; $section_to_remove = null;
$section_start = strpos($string, $tag_start); $section_start = strpos($string, $tag_start);
$search_offset = $section_start; $search_offset = $section_start;
do { do {
$max_recursion--; $max_recursion--;
$section_end = strpos($string, $close_tag, $search_offset); $section_end = strpos($string, $close_tag, $search_offset);
$search_offset = $section_end + $close_tag_length; $search_offset = $section_end + $close_tag_length;
$section_to_remove = substr($string, $section_start, $section_end - $section_start + $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); $open_tag_count = substr_count($section_to_remove, $open_tag);
$close_tag_count = substr_count($section_to_remove, $close_tag); $close_tag_count = substr_count($section_to_remove, $close_tag);
} while ($open_tag_count > $close_tag_count && $max_recursion > 0); } while ($open_tag_count > $close_tag_count && $max_recursion > 0);
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
} }
} }
return $string; return $string;
} }
private function ExtractArticleContent($article){ private function extractArticleContent($article){
$contents = $article->find('section.article-text-classic', 0)->innertext; $contents = $article->find('section.article-text-classic', 0)->innertext;
$headline = trim($article->find('p.description', 0)->plaintext); $headline = trim($article->find('p.description', 0)->plaintext);
if (!empty($headline)) if(!empty($headline))
$headline = '<p><b>'.$headline.'</b></p>'; $headline = '<p><b>' . $headline . '</b></p>';
foreach (array( foreach (array(
'<div class="clear', '<div class="clear',
'<div class="sharebar2', '<div class="sharebar2',
'<div class="diaporamafullscreen"', '<div class="diaporamafullscreen"',
'<div class="module social-button', '<div class="module social-button',
'<div style="margin-bottom:10px;" class="noprint"', '<div style="margin-bottom:10px;" class="noprint"',
'<div class="ficheprevnext', '<div class="ficheprevnext',
'<div class="bar noprint', '<div class="bar noprint',
'<div class="toolbar noprint', '<div class="toolbar noprint',
'<div class="addthis_toolbox', '<div class="addthis_toolbox',
'<div class="noprint', '<div class="noprint',
'<div class="bg bglight border border-full noprint', '<div class="bg bglight border border-full noprint',
'<div class="httplogbar-wrapper noprint', '<div class="httplogbar-wrapper noprint',
'<div id="forumcomments', '<div id="forumcomments',
'<div ng-if="active"' '<div ng-if="active"'
) as $div_start) { ) as $div_start) {
$contents = $this->StripRecursiveHTMLSection($contents , 'div', $div_start); $contents = $this->stripRecursiveHTMLSection($contents , 'div', $div_start);
} }
$contents = $this->StripWithDelimiters($contents, '<hr ', '/>'); $contents = $this->stripWithDelimiters($contents, '<hr ', '/>');
$contents = $this->StripWithDelimiters($contents, '<p class="content-date', '</p>'); $contents = $this->stripWithDelimiters($contents, '<p class="content-date', '</p>');
$contents = $this->StripWithDelimiters($contents, '<h1 class="content-title', '</h1>'); $contents = $this->stripWithDelimiters($contents, '<h1 class="content-title', '</h1>');
$contents = $this->StripWithDelimiters($contents, 'fs:definition="', '"'); $contents = $this->stripWithDelimiters($contents, 'fs:definition="', '"');
$contents = $this->StripWithDelimiters($contents, 'fs:xt:clicktype="', '"'); $contents = $this->stripWithDelimiters($contents, 'fs:xt:clicktype="', '"');
$contents = $this->StripWithDelimiters($contents, 'fs:xt:clickname="', '"'); $contents = $this->stripWithDelimiters($contents, 'fs:xt:clickname="', '"');
$contents = $this->StripWithDelimiters($contents, '<script ', '</script>'); $contents = $this->stripWithDelimiters($contents, '<script ', '</script>');
return $headline.trim($contents); return $headline . trim($contents);
} }
// Extracts the author from an article or element // Extracts the author from an article or element
private function ExtractAuthor($article){ private function extractAuthor($article){
$article_author = $article->find('h3.epsilon', 0); $article_author = $article->find('h3.epsilon', 0);
if($article_author){ if($article_author){
return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext)); return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext));
} }
return ''; return '';
} }
} }

View file

@ -1,128 +1,157 @@
<?php <?php
class GBAtempBridge extends BridgeAbstract { class GBAtempBridge extends BridgeAbstract {
const MAINTAINER = 'ORelio'; const MAINTAINER = 'ORelio';
const NAME = 'GBAtemp'; const NAME = 'GBAtemp';
const URI = 'http://gbatemp.net/'; const URI = 'http://gbatemp.net/';
const DESCRIPTION = 'GBAtemp is a user friendly underground video game community.'; const DESCRIPTION = 'GBAtemp is a user friendly underground video game community.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'type'=>array( 'type' => array(
'name'=>'Type', 'name' => 'Type',
'type'=>'list', 'type' => 'list',
'required'=>true, 'required' => true,
'values'=>array( 'values' => array(
'News'=>'N', 'News' => 'N',
'Reviews'=>'R', 'Reviews' => 'R',
'Tutorials'=>'T', 'Tutorials' => 'T',
'Forum'=>'F' 'Forum' => 'F'
) )
) )
)); ));
private function ExtractFromDelimiters($string, $start, $end) { private function extractFromDelimiters($string, $start, $end){
if (strpos($string, $start) !== false) { if(strpos($string, $start) !== false){
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
} return false; }
}
private function StripWithDelimiters($string, $start, $end) { return false;
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 build_item($uri, $title, $author, $timestamp, $content) { private function stripWithDelimiters($string, $start, $end){
$item = array(); while(strpos($string, $start) !== false){
$item['uri'] = $uri; $section_to_remove = substr($string, strpos($string, $start));
$item['title'] = $title; $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$item['author'] = $author; $string = str_replace($section_to_remove, '', $string);
$item['timestamp'] = $timestamp; }
$item['content'] = $content;
return $item;
}
private function cleanup_post_content($content, $site_url) { return $string;
$content = str_replace(':arrow:', '&#x27a4;', $content); }
$content = str_replace('href="attachments/', 'href="'.$site_url.'attachments/', $content);
$content = $this->StripWithDelimiters($content, '<script', '</script>');
return $content;
}
private function fetch_post_content($uri, $site_url) { private function buildItem($uri, $title, $author, $timestamp, $content){
$html = getSimpleHTMLDOM($uri); $item = array();
if(!$html){ $item['uri'] = $uri;
return 'Could not request GBAtemp '.$uri; $item['title'] = $title;
} $item['author'] = $author;
$item['timestamp'] = $timestamp;
$item['content'] = $content;
return $item;
}
$content = $html->find('div.messageContent', 0)->innertext; private function cleanupPostContent($content, $site_url){
return $this->cleanup_post_content($content, $site_url); $content = str_replace(':arrow:', '&#x27a4;', $content);
} $content = str_replace('href="attachments/', 'href="'.$site_url.'attachments/', $content);
$content = $this->stripWithDelimiters($content, '<script', '</script>');
return $content;
}
public function collectData(){ private function fetchPostContent($uri, $site_url){
$html = getSimpleHTMLDOM($uri);
if(!$html){
return 'Could not request GBAtemp ' . $uri;
}
$html = getSimpleHTMLDOM(self::URI) $content = $html->find('div.messageContent', 0)->innertext;
or returnServerError('Could not request GBAtemp.'); return $this->cleanupPostContent($content, $site_url);
}
switch($this->getInput('type')){ public function collectData(){
case 'N':
foreach ($html->find('li[class=news_item full]') as $newsItem) {
$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, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
}
case 'R':
foreach ($html->find('li.portal_review') as $reviewItem) {
$url = self::URI.$reviewItem->find('a', 0)->href;
$title = $reviewItem->find('span.review_title', 0)->plaintext;
$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>';
$review = $content->find('div#review_main', 0)->innertext;
$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, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
}
case 'T':
foreach ($html->find('li.portal-tutorial') as $tutorialItem) {
$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, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
}
case 'F':
foreach ($html->find('li.rc_item') as $postItem) {
$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, self::URI);
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
}
}
}
public function getName() { $html = getSimpleHTMLDOM(self::URI)
if(!is_null($this->getInput('type'))){ or returnServerError('Could not request GBAtemp.');
$type=array_search(
$this->getInput('type'),
self::PARAMETERS[$this->queriedContext]['type']['values']
);
return 'GBAtemp '.$type.' Bridge';
}
return parent::getName(); switch($this->getInput('type')){
} case 'N':
foreach($html->find('li[class=news_item full]') as $newsItem){
$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->fetchPostContent($url, self::URI);
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
}
case 'R':
foreach($html->find('li.portal_review') as $reviewItem){
$url = self::URI . $reviewItem->find('a', 0)->href;
$title = $reviewItem->find('span.review_title', 0)->plaintext;
$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>';
$review = $content->find('div#review_main', 0)->innertext;
$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->cleanupPostContent($intro . $review . $subheader . $procons . $scores, self::URI);
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
}
case 'T':
foreach($html->find('li.portal-tutorial') as $tutorialItem){
$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->fetchPostContent($url, self::URI);
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
}
case 'F':
foreach($html->find('li.rc_item') as $postItem){
$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->fetchPostContent($url, self::URI);
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
}
}
}
public function getName() {
if(!is_null($this->getInput('type'))){
$type = array_search(
$this->getInput('type'),
self::PARAMETERS[$this->queriedContext]['type']['values']
);
return 'GBAtemp ' . $type . ' Bridge';
}
return parent::getName();
}
} }

View file

@ -1,21 +1,22 @@
<?php <?php
require_once('DanbooruBridge.php'); require_once('DanbooruBridge.php');
class GelbooruBridge extends DanbooruBridge{ class GelbooruBridge extends DanbooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Gelbooru"; const NAME = 'Gelbooru';
const URI = "http://gelbooru.com/"; const URI = 'http://gelbooru.com/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
const PATHTODATA='.thumb'; const PATHTODATA = '.thumb';
const IDATTRIBUTE='id'; const IDATTRIBUTE = 'id';
const PIDBYPAGE=63; const PIDBYPAGE = 63;
protected function getFullURI(){ protected function getFullURI(){
return $this->getURI().'index.php?page=post&s=list&' return $this->getURI()
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*static::PIDBYPAGE:'') . 'index.php?page=post&s=list&pid='
.'&tags='.urlencode($this->getInput('t')); . ($this->getInput('p') ? ($this->getInput('p') - 1) * static::PIDBYPAGE : '')
} . '&tags=' . urlencode($this->getInput('t'));
}
} }

View file

@ -1,71 +1,76 @@
<?php <?php
define('GIPHY_LIMIT', 10); define('GIPHY_LIMIT', 10);
class GiphyBridge extends BridgeAbstract{ class GiphyBridge extends BridgeAbstract {
const MAINTAINER = "kraoc"; const MAINTAINER = 'kraoc';
const NAME = "Giphy Bridge"; const NAME = 'Giphy Bridge';
const URI = "http://giphy.com/"; const URI = 'http://giphy.com/';
const CACHE_TIMEOUT = 300; //5min const CACHE_TIMEOUT = 300; //5min
const DESCRIPTION = "Bridge for giphy.com"; const DESCRIPTION = 'Bridge for giphy.com';
const PARAMETERS = array( array( const PARAMETERS = array( array(
's'=>array( 's' => array(
'name'=>'search tag', 'name' => 'search tag',
'required'=>true 'required' => true
), ),
'n'=>array( 'n' => array(
'name'=>'max number of returned items', 'name' => 'max number of returned items',
'type'=>'number' 'type' => 'number'
) )
)); ));
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$base_url = 'http://giphy.com'; $base_url = 'http://giphy.com';
$html = getSimpleHTMLDOM(self::URI.'/search/'.urlencode($this->getInput('s').'/')) $html = getSimpleHTMLDOM(self::URI . '/search/' . urlencode($this->getInput('s') . '/'))
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
$max = GIPHY_LIMIT; $max = GIPHY_LIMIT;
if ($this->getInput('n')) { if($this->getInput('n')){
$max = $this->getInput('n'); $max = $this->getInput('n');
} }
$limit = 0; $limit = 0;
$kw = urlencode($this->getInput('s')); $kw = urlencode($this->getInput('s'));
foreach($html->find('div.hoverable-gif') as $entry) { foreach($html->find('div.hoverable-gif') as $entry){
if($limit < $max) { if($limit < $max){
$node = $entry->first_child(); $node = $entry->first_child();
$href = $node->getAttribute('href'); $href = $node->getAttribute('href');
$html2 = getSimpleHTMLDOM(self::URI . $href) $html2 = getSimpleHTMLDOM(self::URI . $href)
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
$figure = $html2->getElementByTagName('figure'); $figure = $html2->getElementByTagName('figure');
$img = $figure->firstChild(); $img = $figure->firstChild();
$caption = $figure->lastChild(); $caption = $figure->lastChild();
$item = array(); $item = array();
$item['id'] = $img->getAttribute('data-gif_id'); $item['id'] = $img->getAttribute('data-gif_id');
$item['uri'] = $img->getAttribute('data-bitly_gif_url'); $item['uri'] = $img->getAttribute('data-bitly_gif_url');
$item['username'] = 'Giphy - '.ucfirst($kw); $item['username'] = 'Giphy - ' . ucfirst($kw);
$title = $caption->innertext(); $title = $caption->innertext();
$title = preg_replace('/\s+/', ' ',$title); $title = preg_replace('/\s+/', ' ', $title);
$title = str_replace('animated GIF', '', $title); $title = str_replace('animated GIF', '', $title);
$title = str_replace($kw, '', $title); $title = str_replace($kw, '', $title);
$title = preg_replace('/\s+/', ' ',$title); $title = preg_replace('/\s+/', ' ',$title);
$title = trim($title); $title = trim($title);
if (strlen($title) <= 0) { if(strlen($title) <= 0){
$title = $item['id']; $title = $item['id'];
} }
$item['title'] = trim($title); $item['title'] = trim($title);
$item['content'] = $item['content'] = '<a href="'
'<a href="'.$item['uri'].'">' . $item['uri']
.'<img src="'.$img->getAttribute('src').'" width="'.$img->getAttribute('data-original-width').'" height="'.$img->getAttribute('data-original-height').'" />' . '"><img src="'
.'</a>'; . $img->getAttribute('src')
. '" width="'
. $img->getAttribute('data-original-width')
. '" height="'
. $img->getAttribute('data-original-height')
. '" /></a>';
$this->items[] = $item; $this->items[] = $item;
$limit++; $limit++;
} }
} }
} }
} }

View file

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

View file

@ -1,22 +1,26 @@
<?php <?php
class GizmodoBridge extends FeedExpander { class GizmodoBridge extends FeedExpander {
const MAINTAINER = "polopollo"; const MAINTAINER = 'polopollo';
const NAME = "Gizmodo"; const NAME = 'Gizmodo';
const URI = "http://gizmodo.com/"; const URI = 'http://gizmodo.com/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns the newest posts from Gizmodo (full text)."; const DESCRIPTION = 'Returns the newest posts from Gizmodo (full text).';
protected function parseItem($item){ protected function parseItem($item){
$item = parent::parseItem($item); $item = parent::parseItem($item);
$articleHTMLContent = getSimpleHTMLDOMCached($item['uri']); $articleHTMLContent = getSimpleHTMLDOMCached($item['uri']);
if(!$articleHTMLContent){ if(!$articleHTMLContent){
$text = 'Could not load '.$item['uri']; $text = 'Could not load ' . $item['uri'];
}else{ } else {
$text = $articleHTMLContent->find('div.entry-content', 0)->innertext; $text = $articleHTMLContent->find('div.entry-content', 0)->innertext;
foreach($articleHTMLContent->find('pagespeed_iframe') as $element) { 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 .= '<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>'); $text = strip_tags($text, '<p><b><a><blockquote><img><em>');

View file

@ -1,51 +1,51 @@
<?php <?php
class GoComicsBridge extends BridgeAbstract { class GoComicsBridge extends BridgeAbstract {
const MAINTAINER = 'sky'; const MAINTAINER = 'sky';
const NAME = 'GoComics Unofficial RSS'; const NAME = 'GoComics Unofficial RSS';
const URI = 'http://www.gocomics.com/'; const URI = 'http://www.gocomics.com/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = 'The Unofficial GoComics RSS'; const DESCRIPTION = 'The Unofficial GoComics RSS';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'comicname' => array( 'comicname' => array(
'name' => 'comicname', 'name' => 'comicname',
'type' => 'text', 'type' => 'text',
'required' => true 'required' => true
) )
)); ));
public function collectData() { public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request GoComics: '.$this->getURI()); $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request GoComics: ' . $this->getURI());
foreach ($html->find('div.item-comic-container') as $element) { foreach($html->find('div.item-comic-container') as $element){
$img = $element->find('img', 0); $img = $element->find('img', 0);
$link = $element->find('a.item-comic-link', 0); $link = $element->find('a.item-comic-link', 0);
$comic = $img->src; $comic = $img->src;
$title = $link->title; $title = $link->title;
$url = $html->find('input.js-copy-link', 0)->value; $url = $html->find('input.js-copy-link', 0)->value;
$date = substr($title, -10); $date = substr($title, -10);
if (empty($title)) if (empty($title))
$title = 'GoComics '.$this->getInput('comicname').' on '.$date; $title = 'GoComics ' . $this->getInput('comicname') . ' on ' . $date;
$date = strtotime($date); $date = strtotime($date);
$item = array(); $item = array();
$item['id'] = $url; $item['id'] = $url;
$item['uri'] = $url; $item['uri'] = $url;
$item['title'] = $title; $item['title'] = $title;
$item['author'] = preg_replace('/by /', '', $element->find('a.link-blended small', 0)->plaintext); $item['author'] = preg_replace('/by /', '', $element->find('a.link-blended small', 0)->plaintext);
$item['timestamp'] = $date; $item['timestamp'] = $date;
$item['content'] = '<img src="'.$comic.'" alt="'.$title.'" />'; $item['content'] = '<img src="' . $comic . '" alt="' . $title . '" />';
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getURI() { public function getURI(){
return self::URI.urlencode($this->getInput('comicname')); return self::URI . urlencode($this->getInput('comicname'));
} }
public function getName() { public function getName(){
return $this->getInput('comicname') .' - '.'GoComics'; return $this->getInput('comicname') . ' - GoComics';
} }
} }
?>

View file

@ -1,39 +1,40 @@
<?php <?php
class GooglePlusPostBridge extends BridgeAbstract class GooglePlusPostBridge extends BridgeAbstract{
{
protected $_title; protected $_title;
protected $_url; protected $_url;
const MAINTAINER = "Grummfy"; const MAINTAINER = 'Grummfy';
const NAME = "Google Plus Post Bridge"; const NAME = 'Google Plus Post Bridge';
const URI = "https://plus.google.com/"; const URI = 'https://plus.google.com/';
const CACHE_TIMEOUT = 600; //10min const CACHE_TIMEOUT = 600; //10min
const DESCRIPTION = "Returns user public post (without API)."; const DESCRIPTION = 'Returns user public post (without API).';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'username'=>array( 'username' => array(
'name'=>'username or Id', 'name' => 'username or Id',
'required'=>true 'required' => true
) )
)); ));
public function collectData() public function collectData(){
{
// get content parsed // get content parsed
$html = getSimpleHTMLDOMCached(self::URI . urlencode($this->getInput('username')) . '/posts' $html = getSimpleHTMLDOMCached(self::URI . urlencode($this->getInput('username')) . '/posts'
// force language // force language
, 84600, false, stream_context_create(array('http'=> array( , 84600
'header' => 'Accept-Language: fr,fr-be,fr-fr;q=0.8,en;q=0.4,en-us;q=0.2;*' . "\r\n" , 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 returnServerError('No results for this query.'); ) or returnServerError('No results for this query.');
// get title, url, ... there is a lot of intresting stuff in meta // get title, url, ... there is a lot of intresting stuff in meta
$this->_title = $html->find('meta[property]', 0)->getAttribute('content'); $this->_title = $html->find('meta[property]', 0)->getAttribute('content');
$this->_url = $html->find('meta[itemprop=url]', 0)->getAttribute('content'); $this->_url = $html->find('meta[itemprop=url]', 0)->getAttribute('content');
// div[jsmodel=XNmfOc] // div[jsmodel=XNmfOc]
foreach($html->find('div.yt') as $post) foreach($html->find('div.yt') as $post){
{
$item = array(); $item = array();
// $item['content'] = $post->find('div.Al', 0)->innertext; // $item['content'] = $post->find('div.Al', 0)->innertext;
$item['author'] = $item['fullname'] = $post->find('header.lea h3 a', 0)->innertext; $item['author'] = $item['fullname'] = $post->find('header.lea h3 a', 0)->innertext;
@ -45,34 +46,39 @@ class GooglePlusPostBridge extends BridgeAbstract
// hashtag to treat : https://plus.google.com/explore/tag // hashtag to treat : https://plus.google.com/explore/tag
$hashtags = array(); $hashtags = array();
foreach($post->find('a.d-s') as $hashtag) foreach($post->find('a.d-s') as $hashtag){
{ $hashtags[trim($hashtag->plaintext)] = self::URI . $hashtag->href;
$hashtags[ trim($hashtag->plaintext) ] = self::URI . $hashtag->href;
} }
$item['content'] = ''; $item['content'] = '';
// avatar display // avatar display
$item['content'] .= '<div style="float:left; margin: 0 0.5em 0.5em 0;"><a href="' . self::URI . urlencode($this->getInput('username')); $item['content'] .= '<div style="float:left; margin: 0 0.5em 0.5em 0;"><a href="'
$item['content'] .= '"><img align="top" alt="' . $item['author'] . '" src="' . $item['avatar'].'" /></a></div>'; . self::URI
. urlencode($this->getInput('username'));
$item['content'] .= '"><img align="top" alt="'
. $item['author']
. '" src="'
. $item['avatar']
. '" /></a></div>';
$content = $post->find('div.Al', 0); $content = $post->find('div.Al', 0);
// XXX ugly but I don't have any idea how to do a better stuff, str_replace on link doesn't work as expected and ask too many checks // XXX ugly but I don't have any idea how to do a better stuff,
foreach($content->find('a') as $link) // str_replace on link doesn't work as expected and ask too many checks
{ foreach($content->find('a') as $link){
$hasHttp = strpos($link->href, 'http'); $hasHttp = strpos($link->href, 'http');
$hasDoubleSlash = strpos($link->href, '//'); $hasDoubleSlash = strpos($link->href, '//');
if ((!$hasHttp && !$hasDoubleSlash) if((!$hasHttp && !$hasDoubleSlash)
|| (false !== $hasHttp && strpos($link->href, 'http') != 0) || (false !== $hasHttp && strpos($link->href, 'http') != 0)
|| (false === $hasHttp && false !== $hasDoubleSlash && $hasDoubleSlash != 0)) || (false === $hasHttp && false !== $hasDoubleSlash && $hasDoubleSlash != 0)){
{
// skipp bad link, for some hashtag or other stuff // skipp bad link, for some hashtag or other stuff
if (strpos($link->href, '/') == 0) if(strpos($link->href, '/') == 0){
{
$link->href = substr($link->href, 1); $link->href = substr($link->href, 1);
} }
$link->href = self::URI . $link->href; $link->href = self::URI . $link->href;
} }
} }
@ -86,13 +92,11 @@ class GooglePlusPostBridge extends BridgeAbstract
} }
} }
public function getName() public function getName(){
{
return $this->_title ?: 'Google Plus Post Bridge'; return $this->_title ?: 'Google Plus Post Bridge';
} }
public function getURI() public function getURI(){
{
return $this->_url ?: self::URI; return $this->_url ?: self::URI;
} }
} }

View file

@ -9,11 +9,11 @@
*/ */
class GoogleSearchBridge extends BridgeAbstract { class GoogleSearchBridge extends BridgeAbstract {
const MAINTAINER = "sebsauvage"; const MAINTAINER = 'sebsauvage';
const NAME = "Google search"; const NAME = 'Google search';
const URI = "https://www.google.com/"; const URI = 'https://www.google.com/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns most recent results from Google search."; const DESCRIPTION = 'Returns most recent results from Google search.';
const PARAMETERS = array(array( const PARAMETERS = array(array(
'q' => array( 'q' => array(
@ -22,30 +22,31 @@ class GoogleSearchBridge extends BridgeAbstract {
) )
)); ));
public function collectData(){
public function collectData() {
$html = ''; $html = '';
$html = getSimpleHTMLDOM(self::URI.'search?q='.urlencode($this->getInput('q')) $html = getSimpleHTMLDOM(self::URI
.'&num=100&complete=0&tbs=qdr:y,sbd:1') . 'search?q='
or returnServerError('No results for this query.'); . urlencode($this->getInput('q'))
.'&num=100&complete=0&tbs=qdr:y,sbd:1')
or returnServerError('No results for this query.');
$emIsRes = $html->find('div[id=ires]', 0); $emIsRes = $html->find('div[id=ires]', 0);
if( !is_null($emIsRes) ) { if(!is_null($emIsRes)){
foreach($emIsRes->find('div[class=g]') as $element){
foreach($emIsRes->find('div[class=g]') as $element) {
$item = array(); $item = array();
// Extract direct URL from google href (eg. /url?q=...) // Extract direct URL from google href (eg. /url?q=...)
$t = $element->find('a[href]', 0)->href; $t = $element->find('a[href]', 0)->href;
$item['uri'] = ''.$t; $item['uri'] = '' . $t;
parse_str(parse_url($t, PHP_URL_QUERY), $parameters); parse_str(parse_url($t, PHP_URL_QUERY), $parameters);
if (isset($parameters['q'])) { $item['uri'] = $parameters['q']; } if(isset($parameters['q'])){
$item['uri'] = $parameters['q'];
}
$item['title'] = $element->find('h3', 0)->plaintext; $item['title'] = $element->find('h3', 0)->plaintext;
$item['content'] = $element->find('span[class=st]', 0)->plaintext; $item['content'] = $element->find('span[class=st]', 0)->plaintext;
$this->items[] = $item; $this->items[] = $item;
@ -54,7 +55,6 @@ class GoogleSearchBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
return $this->getInput('q') . ' - Google search';
return $this->getInput('q') .' - Google search';
} }
} }

View file

@ -1,62 +1,79 @@
<?php <?php
class HDWallpapersBridge extends BridgeAbstract { class HDWallpapersBridge extends BridgeAbstract {
const MAINTAINER = "nel50n"; const MAINTAINER = 'nel50n';
const NAME = "HD Wallpapers Bridge"; const NAME = 'HD Wallpapers Bridge';
const URI = "http://www.hdwallpapers.in/"; const URI = 'http://www.hdwallpapers.in/';
const CACHE_TIMEOUT = 43200; //12h const CACHE_TIMEOUT = 43200; //12h
const DESCRIPTION = "Returns the latests wallpapers from HDWallpapers"; const DESCRIPTION = 'Returns the latests wallpapers from HDWallpapers';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'c'=>array( 'c' => array(
'name'=>'category', 'name' => 'category',
'defaultValue'=>'latest_wallpapers' 'defaultValue' => 'latest_wallpapers'
), ),
'm'=>array('name'=>'max number of wallpapers'), 'm' => array(
'r'=>array( 'name' => 'max number of wallpapers'
'name'=>'resolution', ),
'defaultValue'=>'1920x1200', 'r' => array(
'exampleValue'=>'1920x1200, 1680x1050,…' 'name' => 'resolution',
) 'defaultValue' => '1920x1200',
)); 'exampleValue' => '1920x1200, 1680x1050,…'
)
));
public function collectData(){ public function collectData(){
$category = $this->category; $category = $this->category;
if (strrpos($category, 'wallpapers') !== strlen($category)-strlen('wallpapers')) { if(strrpos($category, 'wallpapers') !== strlen($category) - strlen('wallpapers')){
$category .= '-desktop-wallpapers'; $category .= '-desktop-wallpapers';
} }
$num = 0; $num = 0;
$max = $this->getInput('m') ?: 14; $max = $this->getInput('m') ?: 14;
$lastpage = 1; $lastpage = 1;
for ($page = 1; $page <= $lastpage; $page++) { for($page = 1; $page <= $lastpage; $page++){
$link = self::URI.'/'.$category.'/page/'.$page; $link = self::URI . '/' . $category . '/page/' . $page;
$html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.'); $html = getSimpleHTMLDOM($link)
or returnServerError('No results for this query.');
if ($page === 1) { if($page === 1){
preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches); preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches);
$lastpage = min($matches[1], ceil($max/14)); $lastpage = min($matches[1], ceil($max / 14));
} }
foreach($html->find('.wallpapers .wall a') as $element) { foreach($html->find('.wallpapers .wall a') as $element){
$thumbnail = $element->find('img', 0); $thumbnail = $element->find('img', 0);
$item = array(); $item = array();
// http://www.hdwallpapers.in/download/yosemite_reflections-1680x1050.jpg // http://www.hdwallpapers.in/download/yosemite_reflections-1680x1050.jpg
$item['uri'] = self::URI.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href); $item['uri'] = self::URI
$item['timestamp'] = time(); . '/download'
$item['title'] = $element->find('p', 0)->text(); . str_replace('wallpapers.html', $this->getInput('r') . '.jpg', $element->href);
$item['content'] = $item['title'].'<br><a href="'.$item['uri'].'"><img src="'.self::URI.$thumbnail->src.'" /></a>';
$this->items[] = $item;
$num++; $item['timestamp'] = time();
if ($num >= $max) $item['title'] = $element->find('p', 0)->text();
break 2; $item['content'] = $item['title']
} . '<br><a href="'
} . $item['uri']
} . '"><img src="'
. self::URI
. $thumbnail->src
. '" /></a>';
public function getName(){ $this->items[] = $item;
return 'HDWallpapers - '.str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')).' ['.$this->getInput('r').']';
} $num++;
if ($num >= $max)
break 2;
}
}
}
public function getName(){
return 'HDWallpapers - '
. str_replace(['__', '_'], [' & ', ' '], $this->getInput('c'))
. ' ['
. $this->getInput('r')
. ']';
}
} }

View file

@ -1,23 +1,37 @@
<?php <?php
class HentaiHavenBridge extends BridgeAbstract{ class HentaiHavenBridge extends BridgeAbstract {
const MAINTAINER = "albirew"; const MAINTAINER = 'albirew';
const NAME = "Hentai Haven"; const NAME = 'Hentai Haven';
const URI = "http://hentaihaven.org/"; const URI = 'http://hentaihaven.org/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns releases from Hentai Haven"; const DESCRIPTION = 'Returns releases from Hentai Haven';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Hentai Haven.'); or returnServerError('Could not request Hentai Haven.');
foreach($html->find('div.zoe-grid') as $element) {
$item = array(); foreach($html->find('div.zoe-grid') as $element){
$item['uri'] = $element->find('div.brick-content h3 a', 0)->href; $item = array();
$thumbnailUri = $element->find('a.thumbnail-image img', 0)->getAttribute('data-src'); $item['uri'] = $element->find('div.brick-content h3 a', 0)->href;
$item['title'] = mb_convert_encoding(trim($element->find('div.brick-content h3 a', 0)->innertext), 'UTF-8', 'HTML-ENTITIES'); $thumbnailUri = $element->find('a.thumbnail-image img', 0)->getAttribute('data-src');
$item['tags'] = $element->find('div.oFlyout_bg div.oFlyout div.flyoutContent span.tags', 0)->plaintext; $item['title'] = mb_convert_encoding(
$item['content'] = 'Tags: ' . $item['tags'].'<br><br><a href="' . $item['uri'] . '"><img width="300" height="169" src="' . $thumbnailUri . '" /></a><br>' . $element->find('div.oFlyout_bg div.oFlyout div.flyoutContent p.description', 0)->innertext; trim($element->find('div.brick-content h3 a', 0)->innertext),
$this->items[] = $item; 'UTF-8',
} 'HTML-ENTITIES'
} );
$item['tags'] = $element->find('div.oFlyout_bg div.oFlyout div.flyoutContent span.tags', 0)->plaintext;
$item['content'] = 'Tags: '
. $item['tags']
. '<br><br><a href="'
. $item['uri']
. '"><img width="300" height="169" src="'
. $thumbnailUri
. '" /></a><br>'
. $element->find('div.oFlyout_bg div.oFlyout div.flyoutContent p.description', 0)->innertext;
$this->items[] = $item;
}
}
} }

View file

@ -1,38 +1,44 @@
<?php <?php
class IdenticaBridge extends BridgeAbstract{ class IdenticaBridge extends BridgeAbstract {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Identica Bridge"; const NAME = 'Identica Bridge';
const URI = "https://identi.ca/"; const URI = 'https://identi.ca/';
const CACHE_TIMEOUT = 300; // 5min const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = "Returns user timelines"; const DESCRIPTION = 'Returns user timelines';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'username', 'name' => 'username',
'required'=>true 'required' => true
) )
)); ));
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
foreach($html->find('li.major') as $dent) { foreach($html->find('li.major') as $dent){
$item = array(); $item = array();
$item['uri'] = html_entity_decode($dent->find('a', 0)->href); // get dent link
$item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext); // extract dent timestamp
$item['content'] = trim($dent->find('div.activity-content', 0)->innertext); // extract dent text
$item['title'] = $this->getInput('u') . ' | ' . $item['content'];
$this->items[] = $item;
}
}
public function getName(){ // get dent link
return $this->getInput('u') .' - Identica Bridge'; $item['uri'] = html_entity_decode($dent->find('a', 0)->href);
}
public function getURI(){ // extract dent timestamp
return self::URI.urlencode($this->getInput('u')); $item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext);
}
// extract dent text
$item['content'] = trim($dent->find('div.activity-content', 0)->innertext);
$item['title'] = $this->getInput('u') . ' | ' . $item['content'];
$this->items[] = $item;
}
}
public function getName(){
return $this->getInput('u') . ' - Identica Bridge';
}
public function getURI(){
return self::URI . urlencode($this->getInput('u'));
}
} }

View file

@ -1,71 +1,62 @@
<?php <?php
class InstagramBridge extends BridgeAbstract{ class InstagramBridge extends BridgeAbstract {
const MAINTAINER = "pauder"; const MAINTAINER = 'pauder';
const NAME = "Instagram Bridge"; const NAME = 'Instagram Bridge';
const URI = "http://instagram.com/"; const URI = 'http://instagram.com/';
const DESCRIPTION = "Returns the newest images"; const DESCRIPTION = 'Returns the newest images';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'username', 'name' => 'username',
'required'=>true 'required' => true
) )
)); ));
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request Instagram.'); or returnServerError('Could not request Instagram.');
$innertext = null; $innertext = null;
foreach($html->find('script') as $script) foreach($html->find('script') as $script){
{ if('' === $script->innertext){
if ('' === $script->innertext) { continue;
continue; }
}
$pos = strpos(trim($script->innertext), 'window._sharedData'); $pos = strpos(trim($script->innertext), 'window._sharedData');
if (0 !== $pos) if(0 !== $pos){
{ continue;
continue; }
}
$innertext = $script->innertext; $innertext = $script->innertext;
break; break;
} }
$json = trim(substr($innertext, $pos+18), ' =;'); $json = trim(substr($innertext, $pos + 18), ' =;');
$data = json_decode($json); $data = json_decode($json);
$userMedia = $data->entry_data->ProfilePage[0]->user->media->nodes;
foreach($userMedia as $media){
$item = array();
$item['uri'] = self::URI . 'p/' . $media->code . '/';
$item['content'] = '<img src="' . htmlentities($media->display_src) . '" />';
if (isset($media->caption)){
$item['title'] = $media->caption;
} else {
$item['title'] = basename($media->display_src);
}
$item['timestamp'] = $media->date;
$this->items[] = $item;
}
}
$userMedia = $data->entry_data->ProfilePage[0]->user->media->nodes; public function getName(){
return $this->getInput('u') . ' - Instagram Bridge';
}
foreach($userMedia as $media) public function getURI(){
{ return self::URI . urlencode($this->getInput('u'));
}
$item = array();
$item['uri'] = self::URI.'p/'.$media->code.'/';
$item['content'] = '<img src="' . htmlentities($media->display_src) . '" />';
if (isset($media->caption))
{
$item['title'] = $media->caption;
} else {
$item['title'] = basename($media->display_src);
}
$item['timestamp'] = $media->date;
$this->items[] = $item;
}
}
public function getName(){
return $this->getInput('u') .' - Instagram Bridge';
}
public function getURI(){
return self::URI.urlencode($this->getInput('u'));
}
} }

View file

@ -1,472 +1,465 @@
<?php <?php
class IsoHuntBridge extends BridgeAbstract{ class IsoHuntBridge extends BridgeAbstract {
const MAINTAINER = 'logmanoriginal'; const MAINTAINER = 'logmanoriginal';
const NAME = 'isoHunt Bridge'; const NAME = 'isoHunt Bridge';
const URI = 'https://isohunt.to/'; const URI = 'https://isohunt.to/';
const CACHE_TIMEOUT = 300; //5min const CACHE_TIMEOUT = 300; //5min
const DESCRIPTION = 'Returns the latest results by category or search result'; const DESCRIPTION = 'Returns the latest results by category or search result';
const PARAMETERS = array( const PARAMETERS = array(
/* /*
* Get feeds for one of the "latest" categories * Get feeds for one of the "latest" categories
* Notice: The categories "News" and "Top Searches" are received from the main page * Notice: The categories "News" and "Top Searches" are received from the main page
* Elements are sorted by name ascending! * Elements are sorted by name ascending!
*/ */
'By "Latest" category' => array( 'By "Latest" category' => array(
'latest_category'=>array( 'latest_category' => array(
'name'=>'Latest category', 'name' => 'Latest category',
'type'=>'list', 'type' => 'list',
'required'=>true, 'required' => true,
'title'=>'Select your category', 'title' => 'Select your category',
'defaultValue'=>'news', 'defaultValue' => 'news',
'values'=>array( 'values' => array(
'Hot Torrents'=>'hot_torrents', 'Hot Torrents' => 'hot_torrents',
'News'=>'news', 'News' => 'news',
'Releases'=>'releases', 'Releases' => 'releases',
'Torrents'=>'torrents' 'Torrents' => 'torrents'
) )
) )
), ),
/* /*
* Get feeds for one of the "torrent" categories * Get feeds for one of the "torrent" categories
* Make sure to add new categories also to get_torrent_category_index($)! * Make sure to add new categories also to get_torrent_category_index($)!
* Elements are sorted by name ascending! * Elements are sorted by name ascending!
*/ */
'By "Torrent" category' => array( 'By "Torrent" category' => array(
'torrent_category'=>array( 'torrent_category' => array(
'name'=>'Torrent category', 'name' => 'Torrent category',
'type'=>'list', 'type' => 'list',
'required'=>true, 'required' => true,
'title'=>'Select your category', 'title' => 'Select your category',
'defaultValue'=>'anime', 'defaultValue' => 'anime',
'values'=>array( 'values' => array(
'Adult'=>'adult', 'Adult' => 'adult',
'Anime'=>'anime', 'Anime' => 'anime',
'Books'=>'books', 'Books' => 'books',
'Games'=>'games', 'Games' => 'games',
'Movies'=>'movies', 'Movies' => 'movies',
'Music'=>'music', 'Music' => 'music',
'Other'=>'other', 'Other' => 'other',
'Series & TV'=>'series_tv', 'Series & TV' => 'series_tv',
'Software'=>'software' 'Software' => 'software'
) )
), ),
'torrent_popularity'=>array( 'torrent_popularity' => array(
'name'=>'Sort by popularity', 'name' => 'Sort by popularity',
'type'=>'checkbox', 'type' => 'checkbox',
'title'=>'Activate to receive results by popularity' 'title' => 'Activate to receive results by popularity'
) )
), ),
/* /*
* Get feeds for a specific search request * Get feeds for a specific search request
*/ */
'Search torrent by name' => array( 'Search torrent by name' => array(
'search_name'=>array( 'search_name' => array(
'name'=>'Name', 'name' => 'Name',
'required'=>true, 'required' => true,
'title'=>'Insert your search query', 'title' => 'Insert your search query',
'exampleValue'=>'Bridge' 'exampleValue' => 'Bridge'
), ),
'search_category'=>array( 'search_category' => array(
'name'=>'Category', 'name' => 'Category',
'type'=>'list', 'type' => 'list',
'title'=>'Select your category', 'title' => 'Select your category',
'defaultValue'=>'all', 'defaultValue' => 'all',
'values'=>array( 'values' => array(
'Adult'=>'adult', 'Adult' => 'adult',
'All'=>'all', 'All' => 'all',
'Anime'=>'anime', 'Anime' => 'anime',
'Books'=>'books', 'Books' => 'books',
'Games'=>'games', 'Games' => 'games',
'Movies'=>'movies', 'Movies' => 'movies',
'Music'=>'music', 'Music' => 'music',
'Other'=>'other', 'Other' => 'other',
'Series & TV'=>'series_tv', 'Series & TV' => 'series_tv',
'Software'=>'software' 'Software' => 'software'
) )
) )
) )
); );
public function getURI(){ public function getURI(){
$uri=self::URI; $uri = self::URI;
switch($this->queriedContext){ switch($this->queriedContext){
case 'By "Latest" category': case 'By "Latest" category':
switch($this->getInput('latest_category')){ switch($this->getInput('latest_category')){
case 'hot_torrents': case 'hot_torrents':
$uri .= 'statistic/hot/torrents'; $uri .= 'statistic/hot/torrents';
break; break;
case 'news': case 'news':
break; break;
case 'releases': case 'releases':
$uri .= 'releases.php'; $uri .= 'releases.php';
break; break;
case 'torrents': case 'torrents':
$uri .= 'latest.php'; $uri .= 'latest.php';
break; break;
} }
break; break;
case 'By "Torrent" category':
case 'By "Torrent" category': $uri .= $this->buildCategoryUri(
$uri .= $this->build_category_uri( $this->getInput('torrent_category'),
$this->getInput('torrent_category'), $this->getInput('torrent_popularity')
$this->getInput('torrent_popularity') );
); break;
break; case 'Search torrent by name':
$category = $this->getInput('search_category');
case 'Search torrent by name': $uri .= $this->buildCategoryUri($category);
$category=$this->getInput('search_category'); if($category !== 'movies')
$uri .= $this->build_category_uri($category); $uri .= '&ihq=' . urlencode($this->getInput('search_name'));
if($category!=='movies') break;
$uri .= '&ihq=' . urlencode($this->getInput('search_name'));
break; default: parent::getURI();
}
default: parent::getURI();
} return $uri;
}
return $uri;
} public function getName(){
switch($this->queriedContext){
public function getName(){ case 'By "Latest" category':
switch($this->queriedContext){ $categoryName = array_search(
case 'By "Latest" category': $this->getInput('latest_category'),
$categoryName = self::PARAMETERS['By "Latest" category']['latest_category']['values']
array_search( );
$this->getInput('latest_category'), $name = 'Latest ' . $categoryName . ' - ' . self::NAME;
self::PARAMETERS['By "Latest" category']['latest_category']['values'] break;
); case 'By "Torrent" category':
$name = 'Latest '.$categoryName.' - ' . self::NAME; $categoryName = array_search(
break; $this->getInput('torrent_category'),
self::PARAMETERS['By "Torrent" category']['torrent_category']['values']
case 'By "Torrent" category': );
$categoryName = $name = 'Category: ' . $categoryName . ' - ' . self::NAME;
array_search( break;
$this->getInput('torrent_category'), case 'Search torrent by name':
self::PARAMETERS['By "Torrent" category']['torrent_category']['values'] $categoryName = array_search(
); $this->getInput('search_category'),
$name = 'Category: ' . $categoryName . ' - ' . self::NAME; self::PARAMETERS['Search torrent by name']['search_category']['values']
break; );
$name = 'Search: "'
case 'Search torrent by name': . $this->getInput('search_name')
$categoryName = . '" in category: '
array_search( . $categoryName . ' - '
$this->getInput('search_category'), . self::NAME;
self::PARAMETERS['Search torrent by name']['search_category']['values'] break;
); default: return parent::getName();
$name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . self::NAME; }
break;
return $name;
default: return parent::getName(); }
}
public function collectData(){
return $name; $html = $this->loadHtml($this->getURI());
}
switch($this->queriedContext){
case 'By "Latest" category':
public function collectData(){ switch($this->getInput('latest_category')){
$html = $this->load_html($this->getURI()); case 'hot_torrents':
$this->getLatestHotTorrents($html);
switch($this->queriedContext){ break;
case 'By "Latest" category': case 'news':
switch($this->getInput('latest_category')){ $this->getLatestNews($html);
case 'hot_torrents': break;
$this->get_latest_hot_torrents($html); case 'releases':
break; case 'torrents':
case 'news': $this->getLatestTorrents($html);
$this->get_latest_news($html); break;
break; }
case 'releases': break;
case 'torrents': case 'By "Torrent" category':
$this->get_latest_torrents($html); if($this->getInput('torrent_category') === 'movies'){
break; // This one is special (content wise)
} $this->getMovieTorrents($html);
break; } else {
$this->getLatestTorrents($html);
case 'By "Torrent" category': }
if($this->getInput('torrent_category') === 'movies'){ break;
// This one is special (content wise) case 'Search torrent by name':
$this->get_movie_torrents($html); if( $this->getInput('search_category') === 'movies'){
}else{ // This one is special (content wise)
$this->get_latest_torrents($html); $this->getMovieTorrents($html);
} } else {
break; $this->getLatestTorrents($html);
}
case 'Search torrent by name': break;
if( $this->getInput('search_category') === 'movies'){ }
// This one is special (content wise) }
$this->get_movie_torrents($html);
} else { #region Helper functions for "Movie Torrents"
$this->get_latest_torrents($html);
} private function getMovieTorrents($html){
break; $container = $html->find('div#w0', 0);
} if(!$container)
} returnServerError('Unable to find torrent container!');
#region Helper functions for "Movie Torrents" $torrents = $container->find('article');
if(!$torrents)
private function get_movie_torrents($html){ returnServerError('Unable to find torrents!');
$container = $html->find('div#w0', 0);
if(!$container) foreach($torrents as $torrent){
returnServerError('Unable to find torrent container!');
$anchor = $torrent->find('a', 0);
$torrents = $container->find('article'); if(!$anchor)
if(!$torrents) returnServerError('Unable to find anchor!');
returnServerError('Unable to find torrents!');
$date = $torrent->find('small', 0);
foreach($torrents as $torrent){ if(!$date)
returnServerError('Unable to find date!');
$anchor = $torrent->find('a', 0);
if(!$anchor) $item = array();
returnServerError('Unable to find anchor!');
$item['uri'] = $this->fixRelativeUri($anchor->href);
$date = $torrent->find('small', 0); $item['title'] = $anchor->title;
if(!$date) // $item['author'] =
returnServerError('Unable to find date!'); $item['timestamp'] = strtotime($date->plaintext);
$item['content'] = $this->fixRelativeUri($torrent->innertext);
$item = array();
$this->items[] = $item;
$item['uri'] = $this->fix_relative_uri($anchor->href); }
$item['title'] = $anchor->title; }
// $item['author'] =
$item['timestamp'] = strtotime($date->plaintext); #endregion
$item['content'] = $this->fix_relative_uri($torrent->innertext);
#region Helper functions for "Latest Hot Torrents"
$this->items[] = $item;
} private function getLatestHotTorrents($html){
} $container = $html->find('div#serps', 0);
if(!$container)
#endregion returnServerError('Unable to find torrent container!');
#region Helper functions for "Latest Hot Torrents" $torrents = $container->find('tr');
if(!$torrents)
private function get_latest_hot_torrents($html){ returnServerError('Unable to find torrents!');
$container = $html->find('div#serps', 0);
if(!$container) // Remove first element (header row)
returnServerError('Unable to find torrent container!'); $torrents = array_slice($torrents, 1);
$torrents = $container->find('tr'); foreach($torrents as $torrent){
if(!$torrents)
returnServerError('Unable to find torrents!'); $cell = $torrent->find('td', 0);
if(!$cell)
// Remove first element (header row) returnServerError('Unable to find cell!');
$torrents = array_slice($torrents, 1);
$element = $cell->find('a', 0);
foreach($torrents as $torrent){ if(!$element)
returnServerError('Unable to find element!');
$cell = $torrent->find('td', 0);
if(!$cell) $item = array();
returnServerError('Unable to find cell!');
$item['uri'] = $element->href;
$element = $cell->find('a', 0); $item['title'] = $element->plaintext;
if(!$element) // $item['author'] =
returnServerError('Unable to find element!'); // $item['timestamp'] =
// $item['content'] =
$item = array();
$this->items[] = $item;
$item['uri'] = $element->href; }
$item['title'] = $element->plaintext; }
// $item['author'] =
// $item['timestamp'] = #endregion
// $item['content'] =
#region Helper functions for "Latest News"
$this->items[] = $item;
} private function getLatestNews($html){
} $container = $html->find('div#postcontainer', 0);
if(!$container)
#endregion returnServerError('Unable to find post container!');
$posts = $container->find('div.index-post');
if(!$posts)
returnServerError('Unable to find posts!');
#region Helper functions for "Latest News" foreach($posts as $post){
$item = array();
private function get_latest_news($html){ $item['uri'] = $this->latestNewsExtractUri($post);
$container = $html->find('div#postcontainer', 0); $item['title'] = $this->latestNewsExtractTitle($post);
if(!$container) $item['author'] = $this->latestNewsExtractAuthor($post);
returnServerError('Unable to find post container!'); $item['timestamp'] = $this->latestNewsExtractTimestamp($post);
$item['content'] = $this->latestNewsExtractContent($post);
$posts = $container->find('div.index-post'); $this->items[] = $item;
if(!$posts) }
returnServerError('Unable to find posts!'); }
foreach($posts as $post){ private function latestNewsExtractAuthor($post){
$item = array(); $author = $post->find('small', 0);
if(!$author)
returnServerError('Unable to find author!');
$item['uri'] = $this->latest_news_extract_uri($post); // The author is hidden within a string like: 'Posted by {author} on {date}'
$item['title'] = $this->latest_news_extract_title($post); preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches);
$item['author'] = $this->latest_news_extract_author($post);
$item['timestamp'] = $this->latest_news_extract_timestamp($post);
$item['content'] = $this->latest_news_extract_content($post);
$this->items[] = $item; return $matches[1];
} }
}
private function latest_news_extract_author($post){ private function latestNewsExtractTimestamp($post){
$author = $post->find('small', 0); $date = $post->find('small', 0);
if(!$author) if(!$date)
returnServerError('Unable to find author!'); returnServerError('Unable to find date!');
// The author is hidden within a string like: 'Posted by {author} on {date}' // The date is hidden within a string like: 'Posted by {author} on {date}'
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches); preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches);
return $matches[1]; $timestamp = strtotime($matches[1]);
}
private function latest_news_extract_timestamp($post){ // Make sure date is not in the future (dates are given like 'Nov. 20' without year)
$date = $post->find('small', 0); if($timestamp > time()){
if(!$date) $timestamp = strtotime('-1 year', $timestamp);
returnServerError('Unable to find date!'); }
// The date is hidden within a string like: 'Posted by {author} on {date}' return $timestamp;
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches); }
$timestamp = strtotime($matches[1]); private function latestNewsExtractTitle($post){
$title = $post->find('a', 0);
if(!$title)
returnServerError('Unable to find title!');
// Make sure date is not in the future (dates are given like 'Nov. 20' without year) return $title->plaintext;
if($timestamp > time()){ }
$timestamp = strtotime('-1 year', $timestamp);
}
return $timestamp; private function latestNewsExtractUri($post){
} $uri = $post->find('a', 0);
if(!$uri)
returnServerError('Unable to find uri!');
private function latest_news_extract_title($post){ return $uri->href;
$title = $post->find('a', 0); }
if(!$title)
returnServerError('Unable to find title!');
return $title->plaintext; private function latestNewsExtractContent($post){
} $content = $post->find('div', 0);
if(!$content)
returnServerError('Unable to find content!');
private function latest_news_extract_uri($post){ // Remove <h2>...</h2> (title)
$uri = $post->find('a', 0); foreach($content->find('h2') as $element){
if(!$uri) $element->outertext = '';
returnServerError('Unable to find uri!'); }
return $uri->href; // Remove <small>...</small> (author)
} foreach($content->find('small') as $element){
$element->outertext = '';
}
private function latest_news_extract_content($post){ return $content->innertext;
$content = $post->find('div', 0); }
if(!$content)
returnServerError('Unable to find content!'); #endregion
#region Helper functions for "Latest Torrents", "Latest Releases" and "Torrent Category"
// Remove <h2>...</h2> (title) private function getLatestTorrents($html){
foreach($content->find('h2') as $element){ $container = $html->find('div#serps', 0);
$element->outertext = ''; if(!$container)
} returnServerError('Unable to find torrent container!');
// Remove <small>...</small> (author) $torrents = $container->find('tr[data-key]');
foreach($content->find('small') as $element){ if(!$torrents)
$element->outertext = ''; returnServerError('Unable to find torrents!');
}
return $content->innertext; foreach($torrents as $torrent){
} $item = array();
#endregion $item['uri'] = $this->latestTorrentsExtractUri($torrent);
$item['title'] = $this->latestTorrentsExtractTitle($torrent);
#region Helper functions for "Latest Torrents", "Latest Releases" and "Torrent Category" $item['author'] = $this->latestTorrentsExtractAuthor($torrent);
$item['timestamp'] = $this->latestTorrentsExtractTimestamp($torrent);
$item['content'] = ''; // There is no valuable content
$this->items[] = $item;
}
}
private function latestTorrentsExtractTitle($torrent){
$cell = $torrent->find('td.title-row', 0);
if(!$cell)
returnServerError('Unable to find title cell!');
private function get_latest_torrents($html){ $title = $cell->find('span', 0);
$container = $html->find('div#serps', 0); if(!$title)
if(!$container) returnServerError('Unable to find title!');
returnServerError('Unable to find torrent container!');
$torrents = $container->find('tr[data-key]'); return $title->plaintext;
if(!$torrents) }
returnServerError('Unable to find torrents!');
private function latestTorrentsExtractUri($torrent){
$cell = $torrent->find('td.title-row', 0);
if(!$cell)
returnServerError('Unable to find title cell!');
foreach($torrents as $torrent){ $uri = $cell->find('a', 0);
$item = array(); if(!$uri)
returnServerError('Unable to find uri!');
$item['uri'] = $this->latest_torrents_extract_uri($torrent);
$item['title'] = $this->latest_torrents_extract_title($torrent);
$item['author'] = $this->latest_torrents_extract_author($torrent);
$item['timestamp'] = $this->latest_torrents_extract_timestamp($torrent);
$item['content'] = ''; // There is no valuable content
$this->items[] = $item;
}
}
private function latest_torrents_extract_title($torrent){
$cell = $torrent->find('td.title-row', 0);
if(!$cell)
returnServerError('Unable to find title cell!');
$title = $cell->find('span', 0); return $this->fixRelativeUri($uri->href);
if(!$title) }
returnServerError('Unable to find title!');
private function latestTorrentsExtractAuthor($torrent){
$cell = $torrent->find('td.user-row', 0);
if(!$cell)
return; // No author
return $title->plaintext; $user = $cell->find('a', 0);
} if(!$user)
returnServerError('Unable to find user!');
private function latest_torrents_extract_uri($torrent){
$cell = $torrent->find('td.title-row', 0); return $user->plaintext;
if(!$cell) }
returnServerError('Unable to find title cell!');
private function latestTorrentsExtractTimestamp($torrent){
$cell = $torrent->find('td.date-row', 0);
if(!$cell)
returnServerError('Unable to find date cell!');
return strtotime('-' . $cell->plaintext, time());
}
#endregion
#region Generic helper functions
private function loadHtml($uri){
$html = getSimpleHTMLDOM($uri);
if(!$html)
returnServerError('Unable to load ' . $uri . '!');
$uri = $cell->find('a', 0); return $html;
if(!$uri) }
returnServerError('Unable to find uri!');
private function fixRelativeUri($uri){
return $this->fix_relative_uri($uri->href); return preg_replace('/\//i', self::URI, $uri, 1);
} }
private function latest_torrents_extract_author($torrent){ private function buildCategoryUri($category, $order_popularity = false){
$cell = $torrent->find('td.user-row', 0); switch($category){
if(!$cell) case 'anime': $index = 1; break;
return; // No author case 'software' : $index = 2; break;
case 'games' : $index = 3; break;
$user = $cell->find('a', 0); case 'adult' : $index = 4; break;
if(!$user) case 'movies' : $index = 5; break;
returnServerError('Unable to find user!'); case 'music' : $index = 6; break;
case 'other' : $index = 7; break;
return $user->plaintext; case 'series_tv' : $index = 8; break;
} case 'books': $index = 9; break;
case 'all':
private function latest_torrents_extract_timestamp($torrent){ default: $index = 0; break;
$cell = $torrent->find('td.date-row', 0); }
if(!$cell)
returnServerError('Unable to find date cell!'); return 'torrents/?iht=' . $index . '&ihs=' . ($order_popularity ? 1 : 0) . '&age=0';
}
return strtotime('-' . $cell->plaintext, time());
} #endregion
#endregion
#region Generic helper functions
private function load_html($uri){
$html = getSimpleHTMLDOM($uri);
if(!$html)
returnServerError('Unable to load ' . $uri . '!');
return $html;
}
private function fix_relative_uri($uri){
return preg_replace('/\//i', self::URI, $uri, 1);
}
private function build_category_uri($category, $order_popularity = false){
switch($category){
case 'anime': $index = 1; break;
case 'software' : $index = 2; break;
case 'games' : $index = 3; break;
case 'adult' : $index = 4; break;
case 'movies' : $index = 5; break;
case 'music' : $index = 6; break;
case 'other' : $index = 7; break;
case 'series_tv' : $index = 8; break;
case 'books': $index = 9; break;
case 'all':
default: $index = 0; break;
}
return 'torrents/?iht=' . $index . '&ihs=' . ($order_popularity ? 1 : 0) . '&age=0';
}
#endregion
} }

View file

@ -1,89 +1,100 @@
<?php <?php
class JapanExpoBridge extends BridgeAbstract { class JapanExpoBridge extends BridgeAbstract {
const MAINTAINER = 'Ginko'; const MAINTAINER = 'Ginko';
const NAME = 'Japan Expo Actualités'; const NAME = 'Japan Expo Actualités';
const URI = 'http://www.japan-expo-paris.com/fr/actualites'; const URI = 'http://www.japan-expo-paris.com/fr/actualites';
const CACHE_TIMEOUT = 14400; // 4h const CACHE_TIMEOUT = 14400; // 4h
const DESCRIPTION = 'Returns most recent entries from Japan Expo actualités.'; const DESCRIPTION = 'Returns most recent entries from Japan Expo actualités.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'mode'=>array( 'mode' => array(
'name'=>'Show full contents', 'name' => 'Show full contents',
'type'=>'checkbox', 'type' => 'checkbox',
) )
)); ));
public function collectData(){ public function collectData(){
function french_pubdate_to_timestamp($date_to_parse) { function frenchPubDateToTimestamp($date_to_parse) {
return strtotime( return strtotime(
strtr( strtr(
strtolower(str_replace('Publié le ', '', $date_to_parse)), strtolower(str_replace('Publié le ', '', $date_to_parse)),
array( array(
'janvier' => 'jan', 'janvier' => 'jan',
'février' => 'feb', 'février' => 'feb',
'mars' => 'march', 'mars' => 'march',
'avril' => 'apr', 'avril' => 'apr',
'mai' => 'may', 'mai' => 'may',
'juin' => 'jun', 'juin' => 'jun',
'juillet' => 'jul', 'juillet' => 'jul',
'août' => 'aug', 'août' => 'aug',
'septembre' => 'sep', 'septembre' => 'sep',
'octobre' => 'oct', 'octobre' => 'oct',
'novembre' => 'nov', 'novembre' => 'nov',
'décembre' => 'dec' 'décembre' => 'dec'
) )
) )
); );
} }
$convert_article_images = function ($matches) { $convert_article_images = function($matches){
if (is_array($matches) && count($matches) > 1) { if(is_array($matches) && count($matches) > 1){
return '<img src="'.$matches[1].'" />'; return '<img src="' . $matches[1] . '" />';
} }
}; };
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request JapanExpo: '.self::URI); or returnServerError('Could not request JapanExpo: ' . self::URI);
$fullcontent = $this->getInput('mode'); $fullcontent = $this->getInput('mode');
$count = 0; $count = 0;
foreach ($html->find('a._tile2') as $element) { foreach($html->find('a._tile2') as $element){
$url = $element->href; $url = $element->href;
$thumbnail = 'http://s.japan-expo.com/katana/images/JES049/paris.png'; $thumbnail = 'http://s.japan-expo.com/katana/images/JES049/paris.png';
preg_match('/url\(([^)]+)\)/', $element->find('img.rspvimgset', 0)->style, $img_search_result); preg_match('/url\(([^)]+)\)/', $element->find('img.rspvimgset', 0)->style, $img_search_result);
if (count($img_search_result) >= 2)
$thumbnail = trim($img_search_result[1], "'");
if ($fullcontent) { if(count($img_search_result) >= 2)
if ($count >= 5) { $thumbnail = trim($img_search_result[1], "'");
break;
}
$article_html = getSimpleHTMLDOMCached('Could not request JapanExpo: '.$url); if($fullcontent){
$header = $article_html->find('header.pageHeadBox', 0); if($count >= 5){
$timestamp = strtotime($header->find('time', 0)->datetime); break;
$title_html = $header->find('div.section', 0)->next_sibling(); }
$title = $title_html->plaintext;
$headings = $title_html->next_sibling()->outertext;
$article = $article_html->find('div.content', 0)->innertext;
$article = preg_replace_callback('/<img [^>]+ style="[^\(]+\(\'([^\']+)\'[^>]+>/i', $convert_article_images, $article);
$content = $headings.$article;
} else {
$date_text = $element->find('span.date', 0)->plaintext;
$timestamp = french_pubdate_to_timestamp($date_text);
$title = trim($element->find('span._title', 0)->plaintext);
$content = '<img src="'.$thumbnail.'"></img><br />'.$date_text.'<br /><a href="'.$url.'">Lire l\'article</a>';
}
$item = array(); $article_html = getSimpleHTMLDOMCached('Could not request JapanExpo: ' . $url);
$item['uri'] = $url; $header = $article_html->find('header.pageHeadBox', 0);
$item['title'] = $title; $timestamp = strtotime($header->find('time', 0)->datetime);
$item['timestamp'] = $timestamp; $title_html = $header->find('div.section', 0)->next_sibling();
$item['content'] = $content; $title = $title_html->plaintext;
$this->items[] = $item; $headings = $title_html->next_sibling()->outertext;
$count++; $article = $article_html->find('div.content', 0)->innertext;
} $article = preg_replace_callback(
} '/<img [^>]+ style="[^\(]+\(\'([^\']+)\'[^>]+>/i',
$convert_article_images,
$article);
$content = $headings . $article;
} else {
$date_text = $element->find('span.date', 0)->plaintext;
$timestamp = frenchPubDateToTimestamp($date_text);
$title = trim($element->find('span._title', 0)->plaintext);
$content = '<img src="'
. $thumbnail
. '"></img><br />'
. $date_text
. '<br /><a href="'
. $url
. '">Lire l\'article</a>';
}
$item = array();
$item['uri'] = $url;
$item['title'] = $title;
$item['timestamp'] = $timestamp;
$item['content'] = $content;
$this->items[] = $item;
$count++;
}
}
} }

View file

@ -3,9 +3,9 @@ require_once('MoebooruBridge.php');
class KonachanBridge extends MoebooruBridge { class KonachanBridge extends MoebooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Konachan"; const NAME = 'Konachan';
const URI = "http://konachan.com/"; const URI = 'http://konachan.com/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
} }

View file

@ -1,12 +1,12 @@
<?php <?php
class KoreusBridge extends FeedExpander { class KoreusBridge extends FeedExpander {
const MAINTAINER = "pit-fgfjiudghdf"; const MAINTAINER = 'pit-fgfjiudghdf';
const NAME = "Koreus"; const NAME = 'Koreus';
const URI = "http://www.koreus.com/"; const URI = 'http://www.koreus.com/';
const DESCRIPTION = "Returns the newest posts from Koreus (full text)"; const DESCRIPTION = 'Returns the newest posts from Koreus (full text)';
protected function parseItem($item) { protected function parseItem($item){
$item = parent::parseItem($item); $item = parent::parseItem($item);
$html = getSimpleHTMLDOMCached($item['uri']); $html = getSimpleHTMLDOMCached($item['uri']);

View file

@ -1,40 +1,39 @@
<?php <?php
class KununuBridge extends BridgeAbstract { class KununuBridge extends BridgeAbstract {
const MAINTAINER = "logmanoriginal"; const MAINTAINER = 'logmanoriginal';
const NAME = "Kununu Bridge"; const NAME = 'Kununu Bridge';
const URI = "https://www.kununu.com/"; const URI = 'https://www.kununu.com/';
const CACHE_TIMEOUT = 86400; // 24h const CACHE_TIMEOUT = 86400; // 24h
const DESCRIPTION = "Returns the latest reviews for a company and site of your choice."; const DESCRIPTION = 'Returns the latest reviews for a company and site of your choice.';
const PARAMETERS = array( const PARAMETERS = array(
'global' => array( 'global' => array(
'site'=>array( 'site' => array(
'name'=>'Site', 'name' => 'Site',
'type'=>'list', 'type' => 'list',
'required'=>true, 'required' => true,
'title'=>'Select your site', 'title' => 'Select your site',
'values'=>array( 'values' => array(
'Austria'=>'at', 'Austria' => 'at',
'Germany'=>'de', 'Germany' => 'de',
'Switzerland'=>'ch', 'Switzerland' => 'ch',
'United States'=>'us' 'United States' => 'us'
) )
), ),
'full'=>array( 'full' => array(
'name'=>'Load full article', 'name' => 'Load full article',
'type'=>'checkbox', 'type' => 'checkbox',
'required'=>false, 'required' => false,
'exampleValue'=>'checked', 'exampleValue' => 'checked',
'title'=>'Activate to load full article' 'title' => 'Activate to load full article'
) )
), ),
array( array(
'company'=>array( 'company' => array(
'name'=>'Company', 'name' => 'Company',
'required'=>true, 'required' => true,
'exampleValue'=>'kununu-us', 'exampleValue' => 'kununu-us',
'title'=>'Insert company name (i.e. Kununu US) or URI path (i.e. kununu-us)' 'title' => 'Insert company name (i.e. Kununu US) or URI path (i.e. kununu-us)'
) )
) )
); );
@ -44,7 +43,7 @@ class KununuBridge extends BridgeAbstract {
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))){ if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))){
$company = $this->fix_company_name($this->getInput('company')); $company = $this->fixCompanyName($this->getInput('company'));
$site = $this->getInput('site'); $site = $this->getInput('site');
$section = ''; $section = '';
@ -67,8 +66,8 @@ class KununuBridge extends BridgeAbstract {
function getName(){ function getName(){
if(!is_null($this->getInput('company'))){ if(!is_null($this->getInput('company'))){
$company = $this->fix_company_name($this->getInput('company')); $company = $this->fixCompanyName($this->getInput('company'));
return ($this->companyName?:$company).' - '.self::NAME; return ($this->companyName ?: $company) . ' - ' . self::NAME;
} }
return paren::getName(); return paren::getName();
@ -82,7 +81,7 @@ class KununuBridge extends BridgeAbstract {
if(!$html) if(!$html)
returnServerError('Unable to receive data from ' . $this->getURI() . '!'); returnServerError('Unable to receive data from ' . $this->getURI() . '!');
// Update name for this request // Update name for this request
$this->companyName = $this->extract_company_name($html); $this->companyName = $this->extractCompanyName($html);
// Find the section with all the panels (reviews) // Find the section with all the panels (reviews)
$section = $html->find('section.kununu-scroll-element', 0); $section = $html->find('section.kununu-scroll-element', 0);
@ -98,15 +97,18 @@ class KununuBridge extends BridgeAbstract {
foreach($articles as $article){ foreach($articles as $article){
$item = array(); $item = array();
$item['author'] = $this->extract_article_author_position($article); $item['author'] = $this->extractArticleAuthorPosition($article);
$item['timestamp'] = $this->extract_article_date($article); $item['timestamp'] = $this->extractArticleDate($article);
$item['title'] = $this->extract_article_rating($article) . ' : ' . $this->extract_article_summary($article); $item['title'] = $this->extractArticleRating($article)
$item['uri'] = $this->extract_article_uri($article); . ' : '
. $this->extractArticleSummary($article);
$item['uri'] = $this->extractArticleUri($article);
if($full) if($full)
$item['content'] = $this->extract_full_description($item['uri']); $item['content'] = $this->extractFullDescription($item['uri']);
else else
$item['content'] = $this->extract_article_description($article); $item['content'] = $this->extractArticleDescription($article);
$this->items[] = $item; $this->items[] = $item;
} }
@ -115,24 +117,24 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Fixes relative URLs in the given text * Fixes relative URLs in the given text
*/ */
private function fix_url($text){ private function fixUrl($text){
return preg_replace('/href=(\'|\")\//i', 'href="'.self::URI, $text); return preg_replace('/href=(\'|\")\//i', 'href="'.self::URI, $text);
} }
/* /*
* Returns a fixed version of the provided company name * Returns a fixed version of the provided company name
*/ */
private function fix_company_name($company){ private function fixCompanyName($company){
$company = trim($company); $company = trim($company);
$company = str_replace(' ', '-', $company); $company = str_replace(' ', '-', $company);
$company = strtolower($company); $company = strtolower($company);
return $this->encode_umlauts($company); return $this->encodeUmlauts($company);
} }
/** /**
* Encodes unmlauts in the given text * Encodes unmlauts in the given text
*/ */
private function encode_umlauts($text){ private function encodeUmlauts($text){
$umlauts = Array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/"); $umlauts = Array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
$replace = Array("ae","oe","ue","Ae","Oe","Ue","ss"); $replace = Array("ae","oe","ue","Ae","Oe","Ue","ss");
@ -142,7 +144,7 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Returns the company name from the review html * Returns the company name from the review html
*/ */
private function extract_company_name($html){ private function extractCompanyName($html){
$company_name = $html->find('h1[itemprop=name]', 0); $company_name = $html->find('h1[itemprop=name]', 0);
if(is_null($company_name)) if(is_null($company_name))
returnServerError('Cannot find company name!'); returnServerError('Cannot find company name!');
@ -153,7 +155,7 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Returns the date from a given article * Returns the date from a given article
*/ */
private function extract_article_date($article){ private function extractArticleDate($article){
// They conviniently provide a time attribute for us :) // They conviniently provide a time attribute for us :)
$date = $article->find('meta[itemprop=dateCreated]', 0); $date = $article->find('meta[itemprop=dateCreated]', 0);
if(is_null($date)) if(is_null($date))
@ -165,7 +167,7 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Returns the rating from a given article * Returns the rating from a given article
*/ */
private function extract_article_rating($article){ private function extractArticleRating($article){
$rating = $article->find('span.rating', 0); $rating = $article->find('span.rating', 0);
if(is_null($rating)) if(is_null($rating))
returnServerError('Cannot find article rating!'); returnServerError('Cannot find article rating!');
@ -176,7 +178,7 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Returns the summary from a given article * Returns the summary from a given article
*/ */
private function extract_article_summary($article){ private function extractArticleSummary($article){
$summary = $article->find('[itemprop=name]', 0); $summary = $article->find('[itemprop=name]', 0);
if(is_null($summary)) if(is_null($summary))
returnServerError('Cannot find article summary!'); returnServerError('Cannot find article summary!');
@ -187,7 +189,7 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Returns the URI from a given article * Returns the URI from a given article
*/ */
private function extract_article_uri($article){ private function extractArticleUri($article){
$anchor = $article->find('ku-company-review-more', 0); $anchor = $article->find('ku-company-review-more', 0);
if(is_null($anchor)) if(is_null($anchor))
returnServerError('Cannot find article URI!'); returnServerError('Cannot find article URI!');
@ -198,7 +200,7 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Returns the position of the author from a given article * Returns the position of the author from a given article
*/ */
private function extract_article_author_position($article){ private function extractArticleAuthorPosition($article){
// We need to parse the user-content manually // We need to parse the user-content manually
$user_content = $article->find('div.user-content', 0); $user_content = $article->find('div.user-content', 0);
if(is_null($user_content)) if(is_null($user_content))
@ -219,18 +221,18 @@ class KununuBridge extends BridgeAbstract {
/** /**
* Returns the description from a given article * Returns the description from a given article
*/ */
private function extract_article_description($article){ private function extractArticleDescription($article){
$description = $article->find('[itemprop=reviewBody]', 0); $description = $article->find('[itemprop=reviewBody]', 0);
if(is_null($description)) if(is_null($description))
returnServerError('Cannot find article description!'); returnServerError('Cannot find article description!');
return $this->fix_url($description->innertext); return $this->fixUrl($description->innertext);
} }
/** /**
* Returns the full description from a given uri * Returns the full description from a given uri
*/ */
private function extract_full_description($uri){ private function extractFullDescription($uri){
// Load full article // Load full article
$html = getSimpleHTMLDOMCached($uri); $html = getSimpleHTMLDOMCached($uri);
if($html === false) if($html === false)
@ -242,6 +244,6 @@ class KununuBridge extends BridgeAbstract {
returnServerError('Cannot find article!'); returnServerError('Cannot find article!');
// Luckily they use the same layout for the review overview and full article pages :) // Luckily they use the same layout for the review overview and full article pages :)
return $this->extract_article_description($article); return $this->extractArticleDescription($article);
} }
} }

View file

@ -1,144 +1,145 @@
<?php <?php
class LWNprevBridge extends BridgeAbstract{ class LWNprevBridge extends BridgeAbstract{
const MAINTAINER = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
const NAME = 'LWN Free Weekly Edition'; const NAME = 'LWN Free Weekly Edition';
const URI = 'https://lwn.net/'; const URI = 'https://lwn.net/';
const CACHE_TIMEOUT = 604800; // 1 week const CACHE_TIMEOUT = 604800; // 1 week
const DESCRIPTION = 'LWN Free Weekly Edition available one week late'; const DESCRIPTION = 'LWN Free Weekly Edition available one week late';
function getURI(){ function getURI(){
return self::URI.'free/bigpage'; return self::URI . 'free/bigpage';
} }
private function jumpToNextTag(&$node){ private function jumpToNextTag(&$node){
while($node && $node->nodeType===XML_TEXT_NODE){ while($node && $node->nodeType === XML_TEXT_NODE){
$nextNode=$node->nextSibling; $nextNode = $node->nextSibling;
if(!$nextNode){ if(!$nextNode){
break; break;
} }
$node=$nextNode; $node = $nextNode;
} }
} }
private function jumpToPreviousTag(&$node){ private function jumpToPreviousTag(&$node){
while($node && $node->nodeType===XML_TEXT_NODE){ while($node && $node->nodeType === XML_TEXT_NODE){
$previousNode=$node->previousSibling; $previousNode = $node->previousSibling;
if(!$previousNode){ if(!$previousNode){
break; break;
} }
$node=$previousNode; $node = $previousNode;
} }
} }
public function collectData(){ public function collectData(){
// Because the LWN page is written in loose HTML and not XHTML, // Because the LWN page is written in loose HTML and not XHTML,
// Simple HTML Dom is not accurate enough for the job // Simple HTML Dom is not accurate enough for the job
$content=getContents($this->getURI()) $content = getContents($this->getURI())
or returnServerError('No results for LWNprev'); or returnServerError('No results for LWNprev');
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$html=new DOMDocument(); $html = new DOMDocument();
$html->loadHTML($content); $html->loadHTML($content);
libxml_clear_errors(); libxml_clear_errors();
$cat1=''; $cat1 = '';
$cat2=''; $cat2 = '';
foreach($html->getElementsByTagName('a') as $a){ foreach($html->getElementsByTagName('a') as $a){
if($a->textContent==='Multi-page format'){ if($a->textContent === 'Multi-page format'){
break; break;
} }
} }
$realURI=self::URI.$a->getAttribute('href'); $realURI = self::URI . $a->getAttribute('href');
$URICounter=0; $URICounter = 0;
$edition=$html->getElementsByTagName('h1')->item(0)->textContent; $edition = $html->getElementsByTagName('h1')->item(0)->textContent;
$editionTimeStamp=strtotime( $editionTimeStamp = strtotime(
substr($edition,strpos($edition,'for ')+strlen('for ')) substr($edition, strpos($edition, 'for ') + strlen('for '))
); );
foreach($html->getElementsByTagName('h2') as $h2){ foreach($html->getElementsByTagName('h2') as $h2){
if($h2->getAttribute('class')!=='SummaryHL'){ if($h2->getAttribute('class') !== 'SummaryHL'){
continue; continue;
} }
$item = array(); $item = array();
$h2NextSibling=$h2->nextSibling; $h2NextSibling = $h2->nextSibling;
$this->jumpToNextTag($h2NextSibling); $this->jumpToNextTag($h2NextSibling);
switch($h2NextSibling->getAttribute('class')){ switch($h2NextSibling->getAttribute('class')){
case 'FeatureByline': case 'FeatureByline':
$item['author']=$h2NextSibling->getElementsByTagName('b')->item(0)->textContent; $item['author'] = $h2NextSibling->getElementsByTagName('b')->item(0)->textContent;
break; break;
case 'GAByline': case 'GAByline':
$text=$h2NextSibling->textContent; $text = $h2NextSibling->textContent;
$item['author']=substr($text,strpos($text,'by ')); $item['author'] = substr($text,strpos($text, 'by '));
break; break;
default: default:
$item['author']='LWN'; $item['author'] = 'LWN';
break; break;
}; };
$h2FirstChild=$h2->firstChild; $h2FirstChild = $h2->firstChild;
$this->jumpToNextTag($h2FirstChild); $this->jumpToNextTag($h2FirstChild);
if($h2FirstChild->nodeName==='a'){ if($h2FirstChild->nodeName === 'a'){
$item['uri']=self::URI.$h2FirstChild->getAttribute('href'); $item['uri'] = self::URI . $h2FirstChild->getAttribute('href');
}else{ }else{
$item['uri']=$realURI.'#'.$URICounter; $item['uri'] = $realURI . '#' . $URICounter;
} }
$URICounter++; $URICounter++;
$item['timestamp']=$editionTimeStamp+$URICounter; $item['timestamp'] = $editionTimeStamp + $URICounter;
$h2PrevSibling=$h2->previousSibling; $h2PrevSibling = $h2->previousSibling;
$this->jumpToPreviousTag($h2PrevSibling); $this->jumpToPreviousTag($h2PrevSibling);
switch($h2PrevSibling->getAttribute('class')){ switch($h2PrevSibling->getAttribute('class')){
case 'Cat2HL': case 'Cat2HL':
$cat2=$h2PrevSibling->textContent; $cat2 = $h2PrevSibling->textContent;
$h2PrevSibling=$h2PrevSibling->previousSibling; $h2PrevSibling = $h2PrevSibling->previousSibling;
$this->jumpToPreviousTag($h2PrevSibling); $this->jumpToPreviousTag($h2PrevSibling);
if($h2PrevSibling->getAttribute('class')!=='Cat1HL'){ if($h2PrevSibling->getAttribute('class') !== 'Cat1HL'){
break; break;
} }
$cat1=$h2PrevSibling->textContent; $cat1 = $h2PrevSibling->textContent;
break; break;
case 'Cat1HL': case 'Cat1HL':
$cat1=$h2PrevSibling->textContent; $cat1 = $h2PrevSibling->textContent;
$cat2=''; $cat2 = '';
break; break;
default: default:
break; break;
} }
$h2PrevSibling=null; $h2PrevSibling = null;
$item['title']=''; $item['title'] = '';
if(!empty($cat1)){ if(!empty($cat1)){
$item['title'].='['.$cat1.($cat2?'/'.$cat2:'').'] '; $item['title'] .= '[' . $cat1 . ($cat2 ? '/' . $cat2 : '') . '] ';
} }
$item['title'].=$h2->textContent; $item['title'] .= $h2->textContent;
$node=$h2; $node = $h2;
$content=''; $content = '';
$contentEnd=false; $contentEnd = false;
while(!$contentEnd){ while(!$contentEnd){
$node=$node->nextSibling; $node = $node->nextSibling;
if( if(!$node || (
!$node || ( $node->nodeType !== XML_TEXT_NODE && (
$node->nodeType!==XML_TEXT_NODE && ( $node->nodeName === 'h2' || (
$node->nodeName==='h2' || !is_null($node->attributes) &&
(!is_null($node->attributes) && !is_null($class=$node->attributes->getNamedItem('class')) && !is_null($class = $node->attributes->getNamedItem('class')) &&
in_array($class->nodeValue,array('Cat1HL','Cat2HL'))) in_array($class->nodeValue, array('Cat1HL', 'Cat2HL'))
) )
) )
){ )
$contentEnd=true; ){
}else{ $contentEnd = true;
$content.=$node->C14N(); }else{
} $content .= $node->C14N();
} }
$item['content']=$content; }
$this->items[]=$item; $item['content'] = $content;
} $this->items[] = $item;
} }
}
} }

View file

@ -1,162 +1,166 @@
<?php <?php
class LeBonCoinBridge extends BridgeAbstract{ class LeBonCoinBridge extends BridgeAbstract {
const MAINTAINER = "16mhz"; const MAINTAINER = '16mhz';
const NAME = "LeBonCoin"; const NAME = 'LeBonCoin';
const URI = "http://www.leboncoin.fr/"; const URI = 'http://www.leboncoin.fr/';
const DESCRIPTION = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword ."; const DESCRIPTION = 'Returns most recent results from LeBonCoin for a
region, and optionally a category and a keyword .';
const PARAMETERS = array( array( const PARAMETERS = array(
'k'=>array('name'=>'Mot Clé'), array(
'r'=>array( 'k' => array('name' => 'Mot Clé'),
'name'=>'Région', 'r' => array(
'type'=>'list', 'name' => 'Région',
'values'=>array( 'type' => 'list',
'Toute la France'=>'ile_de_france/occasions', 'values' => array(
'Alsace'=>'alsace', 'Toute la France' => 'ile_de_france/occasions',
'Aquitaine'=>'aquitaine', 'Alsace' => 'alsace',
'Auvergne'=>'auvergne', 'Aquitaine' => 'aquitaine',
'Basse Normandie'=>'basse_normandie', 'Auvergne' => 'auvergne',
'Bourgogne'=>'bourgogne', 'Basse Normandie' => 'basse_normandie',
'Bretagne'=>'bretagne', 'Bourgogne' => 'bourgogne',
'Centre'=>'centre', 'Bretagne' => 'bretagne',
'Champagne Ardenne'=>'champagne_ardenne', 'Centre' => 'centre',
'Corse'=>'corse', 'Champagne Ardenne' => 'champagne_ardenne',
'Franche Comté'=>'franche_comte', 'Corse' => 'corse',
'Haute Normandie'=>'haute_normandie', 'Franche Comté' => 'franche_comte',
'Ile de France'=>'ile_de_france', 'Haute Normandie' => 'haute_normandie',
'Languedoc Roussillon'=>'languedoc_roussillon', 'Ile de France' => 'ile_de_france',
'Limousin'=>'limousin', 'Languedoc Roussillon' => 'languedoc_roussillon',
'Lorraine'=>'lorraine', 'Limousin' => 'limousin',
'Midi Pyrénées'=>'midi_pyrenees', 'Lorraine' => 'lorraine',
'Nord Pas De Calais'=>'nord_pas_de_calais', 'Midi Pyrénées' => 'midi_pyrenees',
'Pays de la Loire'=>'pays_de_la_loire', 'Nord Pas De Calais' => 'nord_pas_de_calais',
'Picardie'=>'picardie', 'Pays de la Loire' => 'pays_de_la_loire',
'Poitou Charentes'=>'poitou_charentes', 'Picardie' => 'picardie',
'Provence Alpes Côte d\'Azur'=>'provence_alpes_cote_d_azur', 'Poitou Charentes' => 'poitou_charentes',
'Rhône-Alpes'=>'rhone_alpes', 'Provence Alpes Côte d\'Azur' => 'provence_alpes_cote_d_azur',
'Guadeloupe'=>'guadeloupe', 'Rhône-Alpes' => 'rhone_alpes',
'Martinique'=>'martinique', 'Guadeloupe' => 'guadeloupe',
'Guyane'=>'guyane', 'Martinique' => 'martinique',
'Réunion'=>'reunion' 'Guyane' => 'guyane',
) 'Réunion' => 'reunion'
), )
'c'=>array( ),
'name'=>'Catégorie', 'c' => array(
'type'=>'list', 'name' => 'Catégorie',
'values'=>array( 'type' => 'list',
'TOUS'=>'', 'values' => array(
'EMPLOI'=>'_emploi_', 'TOUS' => '',
'VEHICULES'=>array( 'EMPLOI' => '_emploi_',
'Tous'=>'_vehicules_', 'VEHICULES' => array(
'Voitures'=>'voitures', 'Tous' => '_vehicules_',
'Motos'=>'motos', 'Voitures' => 'voitures',
'Caravaning'=>'caravaning', 'Motos' => 'motos',
'Utilitaires'=>'utilitaires', 'Caravaning' => 'caravaning',
'Équipement Auto'=>'equipement_auto', 'Utilitaires' => 'utilitaires',
'Équipement Moto'=>'equipement_moto', 'Équipement Auto' => 'equipement_auto',
'Équipement Caravaning'=>'equipement_caravaning', 'Équipement Moto' => 'equipement_moto',
'Nautisme'=>'nautisme', 'Équipement Caravaning' => 'equipement_caravaning',
'Équipement Nautisme'=>'equipement_nautisme' 'Nautisme' => 'nautisme',
), 'Équipement Nautisme' => 'equipement_nautisme'
'IMMOBILIER'=>array( ),
'Tous'=>'_immobilier_', 'IMMOBILIER' => array(
'Ventes immobilières'=>'ventes_immobilieres', 'Tous' => '_immobilier_',
'Locations'=>'locations', 'Ventes immobilières' => 'ventes_immobilieres',
'Colocations'=>'colocations', 'Locations' => 'locations',
'Bureaux & Commerces'=>'bureaux_commerces' 'Colocations' => 'colocations',
), 'Bureaux & Commerces' => 'bureaux_commerces'
'VACANCES'=>array( ),
'Tous'=>'_vacances_', 'VACANCES' => array(
'Location gîtes'=>'locations_gites', 'Tous' => '_vacances_',
'Chambres d\'hôtes'=>'chambres_d_hotes', 'Location gîtes' => 'locations_gites',
'Campings'=>'campings', 'Chambres d\'hôtes' => 'chambres_d_hotes',
'Hôtels'=>'hotels', 'Campings' => 'campings',
'Hébergements insolites'=>'hebergements_insolites' 'Hôtels' => 'hotels',
), 'Hébergements insolites' => 'hebergements_insolites'
'MULTIMEDIA'=>array( ),
'Tous'=>'_multimedia_', 'MULTIMEDIA' => array(
'Informatique'=>'informatique', 'Tous' => '_multimedia_',
'Consoles & Jeux vidéo'=>'consoles_jeux_video', 'Informatique' => 'informatique',
'Image & Son'=>'image_son', 'Consoles & Jeux vidéo' => 'consoles_jeux_video',
'Téléphonie'=>'telephonie' 'Image & Son' => 'image_son',
), 'Téléphonie' => 'telephonie'
'LOISIRS'=>array( ),
'Tous'=>'_loisirs_', 'LOISIRS' => array(
'DVD / Films'=>'dvd_films', 'Tous' => '_loisirs_',
'CD / Musique'=>'cd_musique', 'DVD / Films' => 'dvd_films',
'Livres'=>'livres', 'CD / Musique' => 'cd_musique',
'Animaux'=>'animaux', 'Livres' => 'livres',
'Vélos'=>'velos', 'Animaux' => 'animaux',
'Sports & Hobbies'=>'sports_hobbies', 'Vélos' => 'velos',
'Instruments de musique'=>'instruments_de_musique', 'Sports & Hobbies' => 'sports_hobbies',
'Collection'=>'collection', 'Instruments de musique' => 'instruments_de_musique',
'Jeux & Jouets'=>'jeux_jouets', 'Collection' => 'collection',
'Vins & Gastronomie'=>'vins_gastronomie' 'Jeux & Jouets' => 'jeux_jouets',
), 'Vins & Gastronomie' => 'vins_gastronomie'
'MATÉRIEL PROFESSIONNEL'=>array( ),
'Tous'=>'_materiel_professionnel_', 'MATÉRIEL PROFESSIONNEL' => array(
'Matériel Agricole'=>'mateiel_agricole', 'Tous' => '_materiel_professionnel_',
'Transport - Manutention'=>'transport_manutention', 'Matériel Agricole' => 'mateiel_agricole',
'BTP - Chantier - Gros-œuvre'=>'btp_chantier_gros_oeuvre', 'Transport - Manutention' => 'transport_manutention',
'Outillage - Matériaux 2nd-œuvre'=>'outillage_materiaux_2nd_oeuvre', 'BTP - Chantier - Gros-œuvre' => 'btp_chantier_gros_oeuvre',
'Équipements Industriels'=>'equipement_industriels', 'Outillage - Matériaux 2nd-œuvre' => 'outillage_materiaux_2nd_oeuvre',
'Restauration - Hôtellerie'=>'restauration_hotellerie', 'Équipements Industriels' => 'equipement_industriels',
'Fournitures de Bureau'=>'fournitures_de_bureau', 'Restauration - Hôtellerie' => 'restauration_hotellerie',
'Commerces & Marchés'=>'commerces_marches', 'Fournitures de Bureau' => 'fournitures_de_bureau',
'Matériel médical'=>'materiel_medical' 'Commerces & Marchés' => 'commerces_marches',
), 'Matériel médical' => 'materiel_medical'
'SERVICES'=>array( ),
'Tous'=>'_services_', 'SERVICES' => array(
'Prestations de services'=>'prestations_de_services', 'Tous' => '_services_',
'Billetterie'=>'billetterie', 'Prestations de services' => 'prestations_de_services',
'Évènements'=>'evenements', 'Billetterie' => 'billetterie',
'Cours particuliers'=>'cours_particuliers', 'Évènements' => 'evenements',
'Covoiturage'=>'covoiturage' 'Cours particuliers' => 'cours_particuliers',
), 'Covoiturage' => 'covoiturage'
'MAISON'=>array( ),
'Tous'=>'_maison_', 'MAISON' => array(
'Ameublement'=>'ameublement', 'Tous' => '_maison_',
'Électroménager'=>'electromenager', 'Ameublement' => 'ameublement',
'Arts de la table'=>'arts_de_la_table', 'Électroménager' => 'electromenager',
'Décoration'=>'decoration', 'Arts de la table' => 'arts_de_la_table',
'Linge de maison'=>'linge_de_maison', 'Décoration' => 'decoration',
'Bricolage'=>'bricolage', 'Linge de maison' => 'linge_de_maison',
'Jardinage'=>'jardinage', 'Bricolage' => 'bricolage',
'Vêtements'=>'vetements', 'Jardinage' => 'jardinage',
'Chaussures'=>'chaussures', 'Vêtements' => 'vetements',
'Accessoires & Bagagerie'=>'accessoires_bagagerie', 'Chaussures' => 'chaussures',
'Montres & Bijoux'=>'montres_bijoux', 'Accessoires & Bagagerie' => 'accessoires_bagagerie',
'Équipement bébé'=>'equipement_bebe', 'Montres & Bijoux' => 'montres_bijoux',
'Vêtements bébé'=>'vetements_bebe' 'Équipement bébé' => 'equipement_bebe',
), 'Vêtements bébé' => 'vetements_bebe'
'AUTRES'=>'autres' ),
) 'AUTRES' => 'autres'
) )
) )
); )
);
public function collectData(){ public function collectData(){
$category=$this->getInput('c'); $category = $this->getInput('c');
if (empty($category)){ if(empty($category)){
$category='annonces'; $category = 'annonces';
} }
$html = getSimpleHTMLDOM( $html = getSimpleHTMLDOM(self::URI
self::URI.$category.'/offres/' . $this->getInput('r') . '/?' . $category
.'f=a&th=1&' . '/offres/'
.'q=' . urlencode($this->getInput('k')) . $this->getInput('r')
) or returnServerError('Could not request LeBonCoin.'); . '/?f=a&th=1&q='
. urlencode($this->getInput('k')))
or returnServerError('Could not request LeBonCoin.');
$list = $html->find('.tabsContent', 0); $list = $html->find('.tabsContent', 0);
if($list === NULL) { if($list === null){
return; return;
} }
$tags = $list->find('li'); $tags = $list->find('li');
foreach($tags as $element) { foreach($tags as $element){
$element = $element->find('a', 0); $element = $element->find('a', 0);
@ -165,7 +169,7 @@ class LeBonCoinBridge extends BridgeAbstract{
$title = html_entity_decode($element->getAttribute('title')); $title = html_entity_decode($element->getAttribute('title'));
$content_image = $element->find('div.item_image', 0)->find('.lazyload', 0); $content_image = $element->find('div.item_image', 0)->find('.lazyload', 0);
if($content_image !== NULL) { if($content_image !== null){
$content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">'; $content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">';
} else { } else {
$content = ""; $content = "";
@ -176,7 +180,7 @@ class LeBonCoinBridge extends BridgeAbstract{
for($i = 0; $i <= 1; $i++) $content .= $detailsList->find('p.item_supp', $i)->plaintext; for($i = 0; $i <= 1; $i++) $content .= $detailsList->find('p.item_supp', $i)->plaintext;
$price = $detailsList->find('h3.item_price', 0); $price = $detailsList->find('h3.item_price', 0);
$content .= $price === NULL ? '' : $price->plaintext; $content .= $price === null ? '' : $price->plaintext;
$item['title'] = $title; $item['title'] = $title;
$item['content'] = $content . $date; $item['content'] = $content . $date;

View file

@ -1,42 +1,44 @@
<?php <?php
class LeMondeInformatiqueBridge extends FeedExpander { class LeMondeInformatiqueBridge extends FeedExpander {
const MAINTAINER = "ORelio"; const MAINTAINER = 'ORelio';
const NAME = "Le Monde Informatique"; const NAME = 'Le Monde Informatique';
const URI = "http://www.lemondeinformatique.fr/"; const URI = 'http://www.lemondeinformatique.fr/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns the newest articles."; const DESCRIPTION = 'Returns the newest articles.';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . 'rss/rss.xml', 10); $this->collectExpandableDatas(self::URI . 'rss/rss.xml', 10);
} }
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$article_html = getSimpleHTMLDOMCached($item['uri']) $article_html = getSimpleHTMLDOMCached($item['uri'])
or returnServerError('Could not request LeMondeInformatique: ' . $item['uri']); or returnServerError('Could not request LeMondeInformatique: ' . $item['uri']);
$item['content'] = $this->CleanArticle($article_html->find('div#article', 0)->innertext); $item['content'] = $this->cleanArticle($article_html->find('div#article', 0)->innertext);
$item['title'] = $article_html->find('h1.cleanprint-title', 0)->plaintext; $item['title'] = $article_html->find('h1.cleanprint-title', 0)->plaintext;
return $item; return $item;
} }
private function StripCDATA($string) { private function stripCDATA($string){
$string = str_replace('<![CDATA[', '', $string); $string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string); $string = str_replace(']]>', '', $string);
return $string; return $string;
} }
private function StripWithDelimiters($string, $start, $end) { private function stripWithDelimiters($string, $start, $end){
while (strpos($string, $start) !== false) { while(strpos($string, $start) !== false){
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
} return $string; }
}
private function CleanArticle($article_html) { return $string;
$article_html = $this->StripWithDelimiters($article_html, '<script', '</script>'); }
$article_html = $this->StripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>');
return $article_html; private 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;
}
} }

View file

@ -1,70 +1,68 @@
<?php <?php
class LegifranceJOBridge extends BridgeAbstract{ class LegifranceJOBridge extends BridgeAbstract {
const MAINTAINER = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
const NAME = 'Journal Officiel de la République Française'; const NAME = 'Journal Officiel de la République Française';
const URI = 'https://www.legifrance.gouv.fr/affichJO.do'; const URI = 'https://www.legifrance.gouv.fr/affichJO.do';
const DESCRIPTION = 'Returns the laws and decrees officially registered daily in France'; const DESCRIPTION = 'Returns the laws and decrees officially registered daily in France';
const PARAMETERS=array(); const PARAMETERS = array();
private $author; private $author;
private $timestamp; private $timestamp;
private $uri; private $uri;
private function extractItem($section,$subsection=null,$origin=null){ private function extractItem($section, $subsection = null, $origin = null){
$item=array(); $item = array();
$item['author']=$this->author; $item['author'] = $this->author;
$item['timestamp']=$this->timestamp; $item['timestamp'] = $this->timestamp;
$item['uri']=$this->uri.'#'.count($this->items); $item['uri'] = $this->uri . '#' . count($this->items);
$item['title']=$section->plaintext; $item['title'] = $section->plaintext;
if(!is_null($origin)){ if(!is_null($origin)){
$item['title']='[ '.$item['title'].' / '.$subsection->plaintext.' ] '.$origin->plaintext; $item['title'] = '[ ' . $item['title'] . ' / ' . $subsection->plaintext . ' ] ' . $origin->plaintext;
$data=$origin; $data = $origin;
}elseif(!is_null($subsection)){ } elseif(!is_null($subsection)){
$item['title']='[ '.$item['title'].' ] '.$subsection->plaintext; $item['title'] = '[ ' . $item['title'] . ' ] ' . $subsection->plaintext;
$data=$subsection; $data = $subsection;
}else{ } else {
$data=$section; $data = $section;
} }
$item['content']=''; $item['content'] = '';
foreach($data->nextSibling()->find('a') as $content){ foreach($data->nextSibling()->find('a') as $content){
$text=$content->plaintext; $text = $content->plaintext;
$href=$content->nextSibling()->getAttribute('resource'); $href = $content->nextSibling()->getAttribute('resource');
$item['content'].='<p><a href="'.$href.'">'.$text.'</a></p>'; $item['content'] .= '<p><a href="' . $href . '">' . $text . '</a></p>';
} }
return $item; return $item;
} }
public function collectData(){ public function collectData(){
$html=getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or $this->returnServer('Unable to download '.self::URI); or $this->returnServer('Unable to download ' . self::URI);
$this->author=trim($html->find('h2.title',0)->plaintext); $this->author = trim($html->find('h2.title', 0)->plaintext);
$uri=$html->find('h2.titleELI',0)->plaintext; $uri = $html->find('h2.titleELI', 0)->plaintext;
$this->uri=trim(substr($uri,strpos($uri,'https'))); $this->uri = trim(substr($uri, strpos($uri, 'https')));
$this->timestamp=strtotime(substr($this->uri,strpos($this->uri,'eli/jo/')+strlen('eli/jo/'))); $this->timestamp = strtotime(substr($this->uri, strpos($this->uri, 'eli/jo/') + strlen('eli/jo/')));
foreach($html->find('h3') as $section){ foreach($html->find('h3') as $section){
$subsections=$section->nextSibling()->find('h4'); $subsections = $section->nextSibling()->find('h4');
foreach($subsections as $subsection){ foreach($subsections as $subsection){
$origins=$subsection->nextSibling()->find('h5'); $origins = $subsection->nextSibling()->find('h5');
foreach($origins as $origin){ foreach($origins as $origin){
$this->items[]=$this->extractItem($section,$subsection,$origin); $this->items[] = $this->extractItem($section, $subsection, $origin);
} }
if(!empty($origins)){ if(!empty($origins)){
continue; continue;
} }
$this->items[]=$this->extractItem($section,$subsection); $this->items[] = $this->extractItem($section, $subsection);
} }
if(!empty($subsections)){ if(!empty($subsections)){
continue; continue;
} }
$this->items[]=$this->extractItem($section); $this->items[] = $this->extractItem($section);
} }
} }
} }

View file

@ -1,47 +1,45 @@
<?php <?php
class LesJoiesDuCodeBridge extends BridgeAbstract{ class LesJoiesDuCodeBridge extends BridgeAbstract {
const MAINTAINER = "superbaillot.net"; const MAINTAINER = 'superbaillot.net';
const NAME = "Les Joies Du Code"; const NAME = 'Les Joies Du Code';
const URI = "http://lesjoiesducode.fr/"; const URI = 'http://lesjoiesducode.fr/';
const CACHE_TIMEOUT = 7200; // 2h const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "LesJoiesDuCode"; const DESCRIPTION = 'LesJoiesDuCode';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request LesJoiesDuCode.'); or returnServerError('Could not request LesJoiesDuCode.');
foreach($html->find('div.blog-post') as $element) { foreach($html->find('div.blog-post') as $element){
$item = array(); $item = array();
$temp = $element->find('h1 a', 0); $temp = $element->find('h1 a', 0);
$titre = html_entity_decode($temp->innertext); $titre = html_entity_decode($temp->innertext);
$url = $temp->href; $url = $temp->href;
$temp = $element->find('div.blog-post-content', 0); $temp = $element->find('div.blog-post-content', 0);
// retrieve .gif instead of static .jpg // retrieve .gif instead of static .jpg
$images = $temp->find('p img'); $images = $temp->find('p img');
foreach($images as $image){ foreach($images as $image){
$img_src = str_replace(".jpg",".gif",$image->src); $img_src = str_replace(".jpg", ".gif", $image->src);
$image->src = $img_src; $image->src = $img_src;
} }
$content = $temp->innertext; $content = $temp->innertext;
$auteur = $temp->find('i', 0); $auteur = $temp->find('i', 0);
$pos = strpos($auteur->innertext, "by"); $pos = strpos($auteur->innertext, "by");
if($pos > 0) if($pos > 0){
{ $auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2))));
$auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2)))); $item['author'] = $auteur;
$item['author'] = $auteur; }
}
$item['content'] .= trim($content);
$item['uri'] = $url;
$item['title'] = trim($titre);
$item['content'] .= trim($content); $this->items[] = $item;
$item['uri'] = $url; }
$item['title'] = trim($titre); }
$this->items[] = $item;
}
}
} }

View file

@ -1,31 +1,31 @@
<?php <?php
class LichessBridge extends FeedExpander { class LichessBridge extends FeedExpander {
const MAINTAINER = 'AmauryCarrade'; const MAINTAINER = 'AmauryCarrade';
const NAME = 'Lichess Blog'; const NAME = 'Lichess Blog';
const URI = 'http://fr.lichess.org/blog'; const URI = 'http://fr.lichess.org/blog';
const DESCRIPTION = 'Returns the 5 newest posts from the Lichess blog (full text)'; const DESCRIPTION = 'Returns the 5 newest posts from the Lichess blog (full text)';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . '.atom', 5); $this->collectExpandableDatas(self::URI . '.atom', 5);
} }
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = $this->retrieve_lichess_post($item['uri']); $item['content'] = $this->retrieveLichessPost($item['uri']);
return $item; return $item;
} }
private function retrieve_lichess_post($blog_post_uri){ private function retrieveLichessPost($blog_post_uri){
$blog_post_html = getSimpleHTMLDOMCached($blog_post_uri); $blog_post_html = getSimpleHTMLDOMCached($blog_post_uri);
$blog_post_div = $blog_post_html->find('#lichess_blog', 0); $blog_post_div = $blog_post_html->find('#lichess_blog', 0);
$post_chapo = $blog_post_div->find('.shortlede', 0)->innertext; $post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;
$post_content = $blog_post_div->find('.body', 0)->innertext; $post_content = $blog_post_div->find('.body', 0)->innertext;
$content = '<p><em>' . $post_chapo . '</em></p>'; $content = '<p><em>' . $post_chapo . '</em></p>';
$content .= '<div>' . $post_content . '</div>'; $content .= '<div>' . $post_content . '</div>';
return $content; return $content;
} }
} }

View file

@ -1,36 +1,37 @@
<?php <?php
class LinkedInCompanyBridge extends BridgeAbstract{ class LinkedInCompanyBridge extends BridgeAbstract {
const MAINTAINER = "regisenguehard"; const MAINTAINER = 'regisenguehard';
const NAME = "LinkedIn Company"; const NAME = 'LinkedIn Company';
const URI = "https://www.linkedin.com/"; const URI = 'https://www.linkedin.com/';
const CACHE_TIMEOUT = 21600; //6 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>)"; const DESCRIPTION = 'Returns most recent actus from Company on LinkedIn.
(https://www.linkedin.com/company/<strong style=\"font-weight:bold;\">apple</strong>)';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'c'=>array( 'c' => array(
'name'=>'Company name', 'name' => 'Company name',
'required'=>true 'required' => true
) )
)); ));
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$link = self::URI.'company/'.$this->getInput('c'); $link = self::URI . 'company/' . $this->getInput('c');
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('Could not request LinkedIn.'); or returnServerError('Could not request LinkedIn.');
foreach($html->find('//*[@id="my-feed-post"]/li') as $element) { foreach($html->find('//*[@id="my-feed-post"]/li') as $element){
$title = $element->find('span.share-body', 0)->innertext; $title = $element->find('span.share-body', 0)->innertext;
if ($title) { if($title){
$item = array(); $item = array();
$item['uri'] = $link; $item['uri'] = $link;
$item['title'] = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0 ,100); $item['title'] = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0, 100);
$item['content'] = strip_tags($element->find('span.share-body', 0)->innertext); $item['content'] = strip_tags($element->find('span.share-body', 0)->innertext);
$this->items[] = $item; $this->items[] = $item;
$i++; $i++;
} }
} }
} }
} }

View file

@ -1,11 +1,11 @@
<?php <?php
require_once('MoebooruBridge.php'); require_once('MoebooruBridge.php');
class LolibooruBridge extends MoebooruBridge{ class LolibooruBridge extends MoebooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Lolibooru"; const NAME = 'Lolibooru';
const URI = "https://lolibooru.moe/"; const URI = 'https://lolibooru.moe/';
const DESCRIPTION = "Returns images from given page and tags"; const DESCRIPTION = 'Returns images from given page and tags';
} }

View file

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

View file

@ -1,11 +1,11 @@
<?php <?php
require_once('Shimmie2Bridge.php'); require_once('Shimmie2Bridge.php');
class MilbooruBridge extends Shimmie2Bridge{ class MilbooruBridge extends Shimmie2Bridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Milbooru"; const NAME = 'Milbooru';
const URI = "http://sheslostcontrol.net/moe/shimmie/"; const URI = 'http://sheslostcontrol.net/moe/shimmie/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
} }

View file

@ -2,45 +2,47 @@
class MixCloudBridge extends BridgeAbstract { class MixCloudBridge extends BridgeAbstract {
const MAINTAINER = "Alexis CHEMEL"; const MAINTAINER = 'Alexis CHEMEL';
const NAME = "MixCloud"; const NAME = 'MixCloud';
const URI = "https://mixcloud.com/"; const URI = 'https://mixcloud.com/';
const CACHE_TIMEOUT = 3600; // 1h const CACHE_TIMEOUT = 3600; // 1h
const DESCRIPTION = "Returns latest musics on user stream"; const DESCRIPTION = 'Returns latest musics on user stream';
const PARAMETERS = array(array( const PARAMETERS = array(array(
'u' => array( 'u' => array(
'name' => 'username', 'name' => 'username',
'required' => true, 'required' => true,
))); )
));
public function getName(){ public function getName(){
return 'MixCloud - ' . $this->getInput('u');
}
return 'MixCloud - '.$this->getInput('u'); public function collectData(){
}
public function collectData() { $html = getSimpleHTMLDOM(self::URI . '/' . $this->getInput('u'))
or returnServerError('Could not request MixCloud.');
$html = getSimpleHTMLDOM(self::URI.'/'.$this->getInput('u')) foreach($html->find('div.card-elements-container') as $element){
or returnServerError('Could not request MixCloud.');
foreach($html->find('div.card-elements-container') as $element) { $item = array();
$item = array(); $item['uri'] = self::URI . $element->find('h3.card-cloudcast-title a', 0)->getAttribute('href');
$item['title'] = html_entity_decode(
$element->find('h3.card-cloudcast-title a span', 0)->getAttribute('title'),
ENT_QUOTES
);
$item['uri'] = self::URI.$element->find('h3.card-cloudcast-title a', 0)->getAttribute('href'); $image = $element->find('img.image-for-cloudcast', 0);
$item['title'] = html_entity_decode($element->find('h3.card-cloudcast-title a span', 0)->getAttribute('title'), ENT_QUOTES);
$image = $element->find('img.image-for-cloudcast', 0); if($image){
$item['content'] = '<img src="' . $image->getAttribute('src') . '" />';
}
if( $image ) { $item['author'] = trim($element->find('h4.card-cloudcast-user a', 0)->innertext);
$item['content'] = '<img src="'.$image->getAttribute('src').'" />'; $this->items[] = $item;
} }
}
$item['author'] = trim($element->find('h4.card-cloudcast-user a', 0)->innertext);
$this->items[] = $item;
}
}
} }

View file

@ -1,47 +1,56 @@
<?php <?php
class MoebooruBridge extends BridgeAbstract{ class MoebooruBridge extends BridgeAbstract {
const NAME = "Moebooru"; const NAME = 'Moebooru';
const URI = "https://moe.dev.myconan.net/"; const URI = 'https://moe.dev.myconan.net/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
const MAINTAINER = 'pmaziere'; const MAINTAINER = 'pmaziere';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'p'=>array( 'p' => array(
'name'=>'page', 'name' => 'page',
'defaultValue'=>1, 'defaultValue' => 1,
'type'=>'number' 'type' => 'number'
), ),
't'=>array('name'=>'tags') 't' => array(
)); 'name' => 'tags'
)
));
protected function getFullURI(){ protected function getFullURI(){
return $this->getURI().'post?' return $this->getURI()
.'page='.$this->getInput('p') . 'post?page='
.'&tags='.urlencode($this->getInput('t')); . $this->getInput('p')
} . '&tags='
. urlencode($this->getInput('t'));
}
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getFullURI()) $html = getSimpleHTMLDOM($this->getFullURI())
or returnServerError('Could not request '.$this->getName()); 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]);
$input_json = explode('Post.register(', $html); foreach($data as $datai){
foreach($input_json as $element) $json = json_decode($datai, true);
$data[] = preg_replace('/}\)(.*)/', '}', $element); $item = array();
unset($data[0]); $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'];
foreach($data as $datai) { $this->items[] = $item;
$json = json_decode($datai, TRUE); }
$item = array(); }
$item['uri'] = $this->getURI().'/post/show/'.$json['id'];
$item['postid'] = $json['id'];
$item['timestamp'] = $json['created_at'];
$item['imageUri'] = $json['file_url'];
$item['title'] = $this->getName().' | '.$json['id'];
$item['content'] = '<a href="' . $item['imageUri'] . '"><img src="' . $json['preview_url'] . '" /></a><br>Tags: '.$json['tags'];
$this->items[] = $item;
}
}
} }

View file

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

View file

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

View file

@ -1,12 +1,12 @@
<?php <?php
require_once('GelbooruBridge.php'); require_once('GelbooruBridge.php');
class MspabooruBridge extends GelbooruBridge{ class MspabooruBridge extends GelbooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Mspabooru"; const NAME = 'Mspabooru';
const URI = "http://mspabooru.com/"; const URI = 'http://mspabooru.com/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
const PIDBYPAGE = 50;
const PIDBYPAGE=50;
} }

View file

@ -1,43 +1,44 @@
<?php <?php
class NasaApodBridge extends BridgeAbstract{ class NasaApodBridge extends BridgeAbstract {
const MAINTAINER = "corenting"; const MAINTAINER = 'corenting';
const NAME = "NASA APOD Bridge"; const NAME = 'NASA APOD Bridge';
const URI = "http://apod.nasa.gov/apod/"; const URI = 'http://apod.nasa.gov/apod/';
const CACHE_TIMEOUT = 43200; // 12h const CACHE_TIMEOUT = 43200; // 12h
const DESCRIPTION = "Returns the 3 latest NASA APOD pictures and explanations"; const DESCRIPTION = 'Returns the 3 latest NASA APOD pictures and explanations';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI.'archivepix.html') or returnServerError('Error while downloading the website content'); $html = getSimpleHTMLDOM(self::URI . 'archivepix.html')
$list = explode("<br>", $html->find('b', 0)->innertext); or returnServerError('Error while downloading the website content');
for($i = 0; $i < 3;$i++) $list = explode("<br>", $html->find('b', 0)->innertext);
{
$line = $list[$i];
$item = array();
$uri_page = $html->find('a',$i + 3)->href; for($i = 0; $i < 3; $i++){
$uri = self::URI.$uri_page; $line = $list[$i];
$item['uri'] = $uri; $item = array();
$picture_html = getSimpleHTMLDOM($uri); $uri_page = $html->find('a', $i + 3)->href;
$picture_html_string = $picture_html->innertext; $uri = self::URI . $uri_page;
$item['uri'] = $uri;
//Extract image and explanation $picture_html = getSimpleHTMLDOM($uri);
$media = $picture_html->find('p',1)->innertext; $picture_html_string = $picture_html->innertext;
$media = strstr($media, '<br>');
$media = preg_replace('/<br>/', '', $media, 1);
$explanation = $picture_html->find('p',2)->innertext;
//Extract date from the picture page //Extract image and explanation
$date = explode(" ", $picture_html->find('p',1)->innertext); $media = $picture_html->find('p', 1)->innertext;
$item['timestamp'] = strtotime($date[4].$date[3].$date[2]); $media = strstr($media, '<br>');
$media = preg_replace('/<br>/', '', $media, 1);
$explanation = $picture_html->find('p', 2)->innertext;
//Other informations //Extract date from the picture page
$item['content'] = $media.'<br />'.$explanation; $date = explode(" ", $picture_html->find('p', 1)->innertext);
$item['title'] = $picture_html->find('b',0)->innertext; $item['timestamp'] = strtotime($date[4] . $date[3] . $date[2]);
$this->items[] = $item;
} //Other informations
} $item['content'] = $media . '<br />' . $explanation;
$item['title'] = $picture_html->find('b', 0)->innertext;
$this->items[] = $item;
}
}
} }

View file

@ -1,17 +1,19 @@
<?php <?php
class NeuviemeArtBridge extends FeedExpander { class NeuviemeArtBridge extends FeedExpander {
const MAINTAINER = "ORelio"; const MAINTAINER = 'ORelio';
const NAME = '9ème Art Bridge'; const NAME = '9ème Art Bridge';
const URI = "http://www.9emeart.fr/"; const URI = 'http://www.9emeart.fr/';
const DESCRIPTION = "Returns the newest articles."; const DESCRIPTION = 'Returns the newest articles.';
private function StripWithDelimiters($string, $start, $end) { private function stripWithDelimiters($string, $start, $end){
while (strpos($string, $start) !== false) { while(strpos($string, $start) !== false){
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
} return $string; }
return $string;
} }
protected function parseItem($item){ protected function parseItem($item){
@ -19,29 +21,29 @@ class NeuviemeArtBridge extends FeedExpander {
$article_html = getSimpleHTMLDOMCached($item['uri']); $article_html = getSimpleHTMLDOMCached($item['uri']);
if(!$article_html){ if(!$article_html){
$item['content'] = 'Could not request 9eme Art: '.$item['uri']; $item['content'] = 'Could not request 9eme Art: ' . $item['uri'];
return $item; return $item;
} }
$article_image = ''; $article_image = '';
foreach ($article_html->find('img.img_full') as $img){ foreach ($article_html->find('img.img_full') as $img){
if ($img->alt == $item['title']){ if ($img->alt == $item['title']){
$article_image = self::URI.$img->src; $article_image = self::URI . $img->src;
break; break;
} }
} }
$article_content=''; $article_content = '';
if($article_image){ if($article_image){
$article_content = '<p><img src="'.$article_image.'" /></p>'; $article_content = '<p><img src="' . $article_image . '" /></p>';
} }
$article_content .= str_replace( $article_content .= str_replace(
'src="/', 'src="'.self::URI, 'src="/', 'src="' . self::URI,
$article_html->find('div.newsGenerique_con', 0)->innertext $article_html->find('div.newsGenerique_con', 0)->innertext
); );
$article_content = $this->StripWithDelimiters($article_content, '<script', '</script>'); $article_content = $this->stripWithDelimiters($article_content, '<script', '</script>');
$article_content = $this->StripWithDelimiters($article_content, '<style', '</style>'); $article_content = $this->stripWithDelimiters($article_content, '<style', '</style>');
$article_content = $this->StripWithDelimiters($article_content, '<link', '>'); $article_content = $this->stripWithDelimiters($article_content, '<link', '>');
$item['content'] = $article_content; $item['content'] = $article_content;
@ -49,7 +51,7 @@ class NeuviemeArtBridge extends FeedExpander {
} }
public function collectData(){ public function collectData(){
$feedUrl = self::URI.'9emeart.rss'; $feedUrl = self::URI . '9emeart.rss';
$this->collectExpandableDatas($feedUrl); $this->collectExpandableDatas($feedUrl);
} }
} }

View file

@ -1,10 +1,10 @@
<?php <?php
class NextInpactBridge extends FeedExpander { class NextInpactBridge extends FeedExpander {
const MAINTAINER = "qwertygc"; const MAINTAINER = 'qwertygc';
const NAME = "NextInpact Bridge"; const NAME = 'NextInpact Bridge';
const URI = "http://www.nextinpact.com/"; const URI = 'http://www.nextinpact.com/';
const DESCRIPTION = "Returns the newest articles."; const DESCRIPTION = 'Returns the newest articles.';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . 'rss/news.xml', 10); $this->collectExpandableDatas(self::URI . 'rss/news.xml', 10);
@ -12,18 +12,23 @@ class NextInpactBridge extends FeedExpander {
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = $this->ExtractContent($item['uri']); $item['content'] = $this->extractContent($item['uri']);
return $item; return $item;
} }
private function ExtractContent($url) { private function extractContent($url){
$html2 = getSimpleHTMLDOMCached($url); $html2 = getSimpleHTMLDOMCached($url);
$text = '<p><em>'.$html2->find('span.sub_title', 0)->innertext.'</em></p>' $text = '<p><em>'
.'<p><img src="'.$html2->find('div.container_main_image_article', 0)->find('img.dedicated',0)->src.'" alt="-" /></p>' . $html2->find('span.sub_title', 0)->innertext
.'<div>'.$html2->find('div[itemprop=articleBody]', 0)->innertext.'</div>'; . '</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>';
$premium_article = $html2->find('h2.title_reserve_article', 0); $premium_article = $html2->find('h2.title_reserve_article', 0);
if (is_object($premium_article)) if (is_object($premium_article))
$text = $text.'<p><em>'.$premium_article->innertext.'</em></p>'; $text = $text . '<p><em>' . $premium_article->innertext . '</em></p>';
return $text; return $text;
} }
} }

View file

@ -1,70 +1,74 @@
<?php <?php
class NextgovBridge extends FeedExpander { class NextgovBridge extends FeedExpander {
const MAINTAINER = 'ORelio'; const MAINTAINER = 'ORelio';
const NAME = 'Nextgov Bridge'; const NAME = 'Nextgov Bridge';
const URI = 'https://www.nextgov.com/'; const URI = 'https://www.nextgov.com/';
const DESCRIPTION = 'USA Federal technology news, best practices, and web 2.0 tools.'; const DESCRIPTION = 'USA Federal technology news, best practices, and web 2.0 tools.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'category'=>array( 'category' => array(
'name'=>'Category', 'name' => 'Category',
'type'=>'list', 'type' => 'list',
'values'=>array( 'values' => array(
'All'=>'all', 'All' => 'all',
'Technology News'=>'technology-news', 'Technology News' => 'technology-news',
'CIO Briefing'=>'cio-briefing', 'CIO Briefing' => 'cio-briefing',
'Emerging Tech'=>'emerging-tech', 'Emerging Tech' => 'emerging-tech',
'Cloud'=>'cloud-computing', 'Cloud' => 'cloud-computing',
'Cybersecurity'=>'cybersecurity', 'Cybersecurity' => 'cybersecurity',
'Mobile'=>'mobile', 'Mobile' => 'mobile',
'Health'=>'health', 'Health' => 'health',
'Defense'=>'defense', 'Defense' => 'defense',
'Big Data'=>'big-data' 'Big Data' => 'big-data'
) )
) )
)); ));
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . 'rss/' . $this->getInput('category') . '/', 10); $this->collectExpandableDatas(self::URI . 'rss/' . $this->getInput('category') . '/', 10);
} }
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = ''; $item['content'] = '';
$namespaces = $newsItem->getNamespaces(true); $namespaces = $newsItem->getNamespaces(true);
if(isset($namespaces['media'])){ if(isset($namespaces['media'])){
$media = $newsItem->children($namespaces['media']); $media = $newsItem->children($namespaces['media']);
if(isset($media->content)){ if(isset($media->content)){
$attributes = $media->content->attributes(); $attributes = $media->content->attributes();
$item['content'] = '<img src="' . $attributes['url'] . '">'; $item['content'] = '<img src="' . $attributes['url'] . '">';
} }
} }
$item['content'] .= $this->ExtractContent($item['uri']); $item['content'] .= $this->extractContent($item['uri']);
return $item; return $item;
} }
private function StripWithDelimiters($string, $start, $end) { private function stripWithDelimiters($string, $start, $end){
while (strpos($string, $start) !== false) { while (strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
} return $string; }
}
private function ExtractContent($url){ return $string;
$article = getSimpleHTMLDOMCached($url) }
or returnServerError('Could not request Nextgov: ' . $url);
$contents = $article->find('div.wysiwyg', 0)->innertext; private function extractContent($url){
$contents = $this->StripWithDelimiters($contents, '<div class="ad-container">', '</div>'); $article = getSimpleHTMLDOMCached($url)
$contents = $this->StripWithDelimiters($contents, '<div', '</div>'); //ad outer div or returnServerError('Could not request Nextgov: ' . $url);
return $this->StripWithDelimiters($contents, '<script', '</script>');
$contents = ($article_thumbnail == '' ? '' : '<p><img src="'.$article_thumbnail.'" /></p>') $contents = $article->find('div.wysiwyg', 0)->innertext;
.'<p><b>'.$article_subtitle.'</b></p>' $contents = $this->stripWithDelimiters($contents, '<div class="ad-container">', '</div>');
.trim($contents); $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);
}
} }

View file

@ -1,10 +1,10 @@
<?php <?php
class NiceMatinBridge extends FeedExpander { class NiceMatinBridge extends FeedExpander {
const MAINTAINER = "pit-fgfjiudghdf"; const MAINTAINER = 'pit-fgfjiudghdf';
const NAME = "NiceMatin"; const NAME = 'NiceMatin';
const URI = "http://www.nicematin.com/"; const URI = 'http://www.nicematin.com/';
const DESCRIPTION = "Returns the 10 newest posts from NiceMatin (full text)"; const DESCRIPTION = 'Returns the 10 newest posts from NiceMatin (full text)';
public function collectData(){ public function collectData(){
$this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10); $this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10);
@ -12,11 +12,11 @@ class NiceMatinBridge extends FeedExpander {
protected function parseItem($newsItem){ protected function parseItem($newsItem){
$item = parent::parseItem($newsItem); $item = parent::parseItem($newsItem);
$item['content'] = $this->NiceMatinExtractContent($item['uri']); $item['content'] = $this->extractContent($item['uri']);
return $item; return $item;
} }
private function NiceMatinExtractContent($url) { private function extractContent($url){
$html = getSimpleHTMLDOMCached($url); $html = getSimpleHTMLDOMCached($url);
if(!$html) if(!$html)
return 'Could not acquire content from url: ' . $url . '!'; return 'Could not acquire content from url: ' . $url . '!';

View file

@ -1,52 +1,61 @@
<?php <?php
class NovelUpdatesBridge extends BridgeAbstract{ class NovelUpdatesBridge extends BridgeAbstract {
const MAINTAINER = "albirew"; const MAINTAINER = 'albirew';
const NAME = "Novel Updates"; const NAME = 'Novel Updates';
const URI = "http://www.novelupdates.com/"; const URI = 'http://www.novelupdates.com/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns releases from Novel Updates"; const DESCRIPTION = 'Returns releases from Novel Updates';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'n'=>array( 'n' => array(
'name'=>'Novel name as found in the url', 'name' => 'Novel name as found in the url',
'exampleValue'=>'spirit-realm', 'exampleValue' => 'spirit-realm',
'required'=>true 'required' => true
) )
)); ));
private $seriesTitle=''; private $seriesTitle = '';
public function getURI(){ public function getURI(){
return static::URI.'/series/'.$this->getInput('n').'/'; return static::URI . '/series/' . $this->getInput('n') . '/';
} }
public function collectData(){ public function collectData(){
$fullhtml = getSimpleHTMLDOM($this->getURI()) $fullhtml = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request NovelUpdates, novel "'.$this->getInput('n').'" not found'); or returnServerError('Could not request NovelUpdates, novel "' . $this->getInput('n') . '" not found');
$this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext; $this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext;
// dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259 // dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259
// forcefully removes tbody // forcefully removes tbody
$html = $fullhtml->find('table#myTable', 0)->innertext; $html = $fullhtml->find('table#myTable', 0)->innertext;
$html = stristr($html, '<tbody>'); //strip thead $html = stristr($html, '<tbody>'); //strip thead
$html = stristr($html, '<tr>'); //remove tbody $html = stristr($html, '<tr>'); //remove tbody
$html = str_get_html(stristr($html, '</tbody>', true)); //remove last tbody and get back as an array $html = str_get_html(stristr($html, '</tbody>', true)); //remove last tbody and get back as an array
foreach($html->find('tr') as $element){ foreach($html->find('tr') as $element){
$item = array(); $item = array();
$item['uri'] = $element->find('td', 2)->find('a', 0)->href; $item['uri'] = $element->find('td', 2)->find('a', 0)->href;
$item['title'] = $element->find('td', 2)->find('a', 0)->plaintext; $item['title'] = $element->find('td', 2)->find('a', 0)->plaintext;
$item['team'] = $element->find('td', 1)->innertext; $item['team'] = $element->find('td', 1)->innertext;
$item['timestamp'] = strtotime($element->find('td', 0)->plaintext); $item['timestamp'] = strtotime($element->find('td', 0)->plaintext);
$item['content'] = $item['content'] = '<a href="'
'<a href="'.$item['uri'].'">' . $item['uri']
.$this->seriesTitle.' - '.$item['title'] . '">'
.'</a> by '.$item['team'].'<br>' . $this->seriesTitle
.'<a href="'.$item['uri'].'">'.$fullhtml->find('div.seriesimg', 0)->innertext.'</a>'; . ' - '
$this->items[] = $item; . $item['title']
} . '</a> by '
} . $item['team']
. '<br><a href="'
. $item['uri']
. '">'
. $fullhtml->find('div.seriesimg', 0)->innertext
. '</a>';
public function getName(){ $this->items[] = $item;
return $this->seriesTitle. ' - ' . static::NAME; }
} }
public function getName(){
return $this->seriesTitle . ' - ' . static::NAME;
}
} }

View file

@ -1,46 +1,45 @@
<?php <?php
class OpenClassroomsBridge extends BridgeAbstract{ class OpenClassroomsBridge extends BridgeAbstract {
const MAINTAINER = "sebsauvage"; const MAINTAINER = 'sebsauvage';
const NAME = "OpenClassrooms Bridge"; const NAME = 'OpenClassrooms Bridge';
const URI = "https://openclassrooms.com/"; const URI = 'https://openclassrooms.com/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns latest tutorials from OpenClassrooms."; const DESCRIPTION = 'Returns latest tutorials from OpenClassrooms.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'Catégorie', 'name' => 'Catégorie',
'type'=>'list', 'type' => 'list',
'required'=>true, 'required' => true,
'values'=>array( 'values' => array(
'Arts & Culture'=>'arts', 'Arts & Culture' => 'arts',
'Code'=>'code', 'Code' => 'code',
'Design'=>'design', 'Design' => 'design',
'Entreprise'=>'business', 'Entreprise' => 'business',
'Numérique'=>'digital', 'Numérique' => 'digital',
'Sciences'=>'sciences', 'Sciences' => 'sciences',
'Sciences Humaines'=>'humainities', 'Sciences Humaines' => 'humainities',
'Systèmes d\'information'=>'it', 'Systèmes d\'information' => 'it',
'Autres'=>'others' 'Autres' => 'others'
) )
) )
)); ));
public function getURI(){ public function getURI(){
return self::URI.'/courses?categories='.$this->getInput('u').'&' return self::URI . '/courses?categories=' . $this->getInput('u') . '&title=&sort=updatedAt+desc';
.'title=&sort=updatedAt+desc'; }
}
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request OpenClassrooms.'); or returnServerError('Could not request OpenClassrooms.');
foreach($html->find('.courseListItem') as $element) { foreach($html->find('.courseListItem') as $element){
$item = array(); $item = array();
$item['uri'] = self::URI.$element->find('a', 0)->href; $item['uri'] = self::URI . $element->find('a', 0)->href;
$item['title'] = $element->find('h3', 0)->plaintext; $item['title'] = $element->find('h3', 0)->plaintext;
$item['content'] = $element->find('slidingItem__descriptionContent', 0)->plaintext; $item['content'] = $element->find('slidingItem__descriptionContent', 0)->plaintext;
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }

View file

@ -1,96 +1,98 @@
<?php <?php
class ParuVenduImmoBridge extends BridgeAbstract class ParuVenduImmoBridge extends BridgeAbstract {
{
const MAINTAINER = "polo2ro"; const MAINTAINER = 'polo2ro';
const NAME = "Paru Vendu Immobilier"; const NAME = 'Paru Vendu Immobilier';
const URI = "http://www.paruvendu.fr"; const URI = 'http://www.paruvendu.fr';
const CACHE_TIMEOUT = 10800; // 3h const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the ads from the first page of search result."; const DESCRIPTION = 'Returns the ads from the first page of search result.';
const PARAMETERS = array( array(
'minarea' => array(
'name' => 'Minimal surface m²',
'type' => 'number'
),
'maxprice' => array(
'name' => 'Max price',
'type' => 'number'
),
'pa' => array(
'name' => 'Country code',
'exampleValue' => 'FR'
),
'lo' => array(
'name' => 'department numbers or postal codes, comma-separated'
)
));
const PARAMETERS = array( array( public function collectData(){
'minarea'=>array( $html = getSimpleHTMLDOM($this->getURI())
'name'=>'Minimal surface m²', or returnServerError('Could not request paruvendu.');
'type'=>'number'
),
'maxprice'=>array(
'name'=>'Max price',
'type'=>'number'
),
'pa'=>array(
'name'=>'Country code',
'exampleValue'=>'FR'
),
'lo'=>array('name'=>'department numbers or postal codes, comma-separated')
));
public function collectData() foreach($html->find('div.annonce a') as $element){
{
$html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request paruvendu.');
foreach($html->find('div.annonce a') as $element) { if(!$element->title){
continue;
}
if (!$element->title) { $img = '';
continue; foreach($element->find('span.img img') as $img){
} if($img->original){
$img = '<img src="' . $img->original . '" />';
}
}
$img =''; $desc = $element->find('span.desc')[0]->innertext;
foreach($element->find('span.img img') as $img) { $desc = str_replace("voir l'annonce", '', $desc);
if ($img->original) {
$img = '<img src="'.$img->original.'" />';
}
}
$desc = $element->find('span.desc')[0]->innertext; $price = $element->find('span.price')[0]->innertext;
$desc = str_replace("voir l'annonce", '', $desc);
$price = $element->find('span.price')[0]->innertext; list($href) = explode('#', $element->href);
list($href) = explode('#', $element->href); $item = array();
$item['uri'] = self::URI . $href;
$item['title'] = $element->title;
$item['content'] = $img . $desc . $price;
$this->items[] = $item;
}
}
$item = array(); public function getURI(){
$item['uri'] = self::URI.$href; $appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1';
$item['title'] = $element->title; $maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1';
$item['content'] = $img.$desc.$price; $link = self::URI
$this->items[] = $item; . '/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'
. $appartment
. $maison;
} if($this->getInput('minarea')){
} $link .= '&sur0=' . urlencode($this->getInput('minarea'));
}
public function getURI(){ if($this->getInput('maxprice')){
$appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1'; $link .= '&px1=' . urlencode($this->getInput('maxprice'));
$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')) { if($this->getInput('pa')){
$link .= '&sur0='.urlencode($this->getInput('minarea')); $link .= '&pa=' . urlencode($this->getInput('pa'));
} }
if ($this->getInput('maxprice')) { if($this->getInput('lo')){
$link .= '&px1='.urlencode($this->getInput('maxprice')); $link .= '&lo=' . urlencode($this->getInput('lo'));
} }
return $link;
}
if ($this->getInput('pa')) { public function getName(){
$link .= '&pa='.urlencode($this->getInput('pa')); $request = '';
} $minarea = $this->getInput('minarea');
if(!empty($minarea)){
if ($this->getInput('lo')) { $request .= ' ' . $minarea . ' m2';
$link .= '&lo='.urlencode($this->getInput('lo')); }
} $location = $this->getInput('lo');
return $link; if(!empty($location)){
} $request .= ' In: ' . $location;
}
public function getName(){ return 'Paru Vendu Immobilier' . $request;
$request=''; }
$minarea=$this->getInput('minarea');
if(!empty($minarea)){
$request .= ' '.$minarea.' m2';
}
$location=$this->getInput('lo');
if(!empty($location)){
$request .= ' In: '.$location;
}
return 'Paru Vendu Immobilier'.$request;
}
} }

View file

@ -1,73 +1,93 @@
<?php <?php
class PickyWallpapersBridge extends BridgeAbstract { class PickyWallpapersBridge extends BridgeAbstract {
const MAINTAINER = "nel50n"; const MAINTAINER = 'nel50n';
const NAME = "PickyWallpapers Bridge"; const NAME = 'PickyWallpapers Bridge';
const URI = "http://www.pickywallpapers.com/"; const URI = 'http://www.pickywallpapers.com/';
const CACHE_TIMEOUT = 43200; // 12h const CACHE_TIMEOUT = 43200; // 12h
const DESCRIPTION = "Returns the latests wallpapers from PickyWallpapers"; const DESCRIPTION = 'Returns the latests wallpapers from PickyWallpapers';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'c'=>array( 'c' => array(
'name'=>'category', 'name' => 'category',
'required'=>true 'required' => true
), ),
's'=>array('name'=>'subcategory'), 's' => array(
'm'=>array( 'name' => 'subcategory'
'name'=>'Max number of wallpapers', ),
'defaultValue'=>12, 'm' => array(
'type'=>'number' 'name' => 'Max number of wallpapers',
), 'defaultValue' => 12,
'r'=>array( 'type' => 'number'
'name'=>'resolution', ),
'exampleValue'=>'1920x1200, 1680x1050,…', 'r' => array(
'defaultValue'=>'1920x1200', 'name' => 'resolution',
'pattern'=>'[0-9]{3,4}x[0-9]{3,4}' 'exampleValue' => '1920x1200, 1680x1050,…',
) 'defaultValue' => '1920x1200',
)); 'pattern' => '[0-9]{3,4}x[0-9]{3,4}'
)
));
public function collectData(){
$lastpage = 1;
$num = 0;
$max = $this->getInput('m');
$resolution = $this->getInput('r'); // Wide wallpaper default
public function collectData(){ for($page = 1; $page <= $lastpage; $page++){
$lastpage = 1; $html = getSimpleHTMLDOM($this->getURI() . '/page-' . $page . '/')
$num = 0; or returnServerError('No results for this query.');
$max = $this->getInput('m');
$resolution = $this->getInput('r'); // Wide wallpaper default
for ($page = 1; $page <= $lastpage; $page++) { if($page === 1){
$html = getSimpleHTMLDOM($this->getURI().'/page-'.$page.'/') preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches);
or returnServerError('No results for this query.'); $lastpage = min($matches[1], ceil($max / 12));
}
if ($page === 1) { foreach($html->find('.items li img') as $element){
preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches); $item = array();
$lastpage = min($matches[1], ceil($max/12)); $item['uri'] = str_replace('www', 'wallpaper', self::URI)
} . '/'
. $resolution
. '/'
. basename($element->src);
foreach($html->find('.items li img') as $element) { $item['timestamp'] = time();
$item['title'] = $element->alt;
$item['content'] = $item['title']
. '<br><a href="'
. $item['uri']
. '">'
. $element
. '</a>';
$item = array(); $this->items[] = $item;
$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;
$num++; $num++;
if ($num >= $max) if ($num >= $max)
break 2; break 2;
} }
} }
} }
public function getURI(){ public function getURI(){
$subcategory = $this->getInput('s'); $subcategory = $this->getInput('s');
$link = self::URI.$this->getInput('r').'/'.$this->getInput('c').'/'.$subcategory; $link = self::URI
return $link; . $this->getInput('r')
} . '/'
. $this->getInput('c')
. '/'
. $subcategory;
public function getName(){ return $link;
$subcategory = $this->getInput('s'); }
return 'PickyWallpapers - '.$this->getInput('c')
.($subcategory? ' > '.$subcategory : '') public function getName(){
.' ['.$this->getInput('r').']'; $subcategory = $this->getInput('s');
} return 'PickyWallpapers - '
. $this->getInput('c')
. ($subcategory ? ' > ' . $subcategory : '')
. ' ['
. $this->getInput('r')
. ']';
}
} }

View file

@ -1,10 +1,10 @@
<?php <?php
class PinterestBridge extends BridgeAbstract { class PinterestBridge extends BridgeAbstract {
const MAINTAINER = "pauder"; const MAINTAINER = 'pauder';
const NAME = "Pinterest Bridge"; const NAME = 'Pinterest Bridge';
const URI = "http://www.pinterest.com/"; const URI = 'http://www.pinterest.com/';
const DESCRIPTION = "Returns the newest images on a board"; const DESCRIPTION = 'Returns the newest images on a board';
const PARAMETERS = array( const PARAMETERS = array(
'By username and board' => array( 'By username and board' => array(
@ -63,8 +63,7 @@ class PinterestBridge extends BridgeAbstract {
. htmlentities($item['avatar']) . htmlentities($item['avatar'])
. '" /> <strong>' . '" /> <strong>'
. $item['username'] . $item['username']
. '</strong>' . '</strong><br />'
. '<br />'
. $item['fullname']; . $item['fullname'];
$item['title'] = $img->getAttribute('alt'); $item['title'] = $img->getAttribute('alt');

View file

@ -1,28 +1,35 @@
<?php <?php
class PlanetLibreBridge extends BridgeAbstract{ class PlanetLibreBridge extends BridgeAbstract {
const MAINTAINER = "pit-fgfjiudghdf"; const MAINTAINER = 'pit-fgfjiudghdf';
const NAME = "PlanetLibre"; const NAME = 'PlanetLibre';
const URI = "http://www.planet-libre.org"; const URI = 'http://www.planet-libre.org';
const DESCRIPTION = "Returns the 5 newest posts from PlanetLibre (full text)"; const DESCRIPTION = 'Returns the 5 newest posts from PlanetLibre (full text)';
private function PlanetLibreExtractContent($url){ private function extractContent($url){
$html2 = getSimpleHTMLDOM($url); $html2 = getSimpleHTMLDOM($url);
$text = $html2->find('div[class="post-text"]', 0)->innertext; $text = $html2->find('div[class="post-text"]', 0)->innertext;
return $text; return $text;
} }
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request PlanetLibre.'); or returnServerError('Could not request PlanetLibre.');
$limit = 0; $limit = 0;
foreach($html->find('div.post') as $element) { foreach($html->find('div.post') as $element){
if($limit < 5) { if($limit < 5){
$item = array(); $item = array();
$item['title'] = $element->find('h1', 0)->plaintext; $item['title'] = $element->find('h1', 0)->plaintext;
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;
$item['timestamp'] = strtotime(str_replace('/', '-', $element->find('div[class="post-date"]', 0)->plaintext)); $item['timestamp'] = strtotime(
$item['content'] = $this->PlanetLibreExtractContent($item['uri']); str_replace(
'/',
'-',
$element->find('div[class="post-date"]', 0)->plaintext
)
);
$item['content'] = $this->extractContent($item['uri']);
$this->items[] = $item; $this->items[] = $item;
$limit++; $limit++;
} }

View file

@ -1,38 +1,46 @@
<?php <?php
class RTBFBridge extends BridgeAbstract { class RTBFBridge extends BridgeAbstract {
const NAME = "RTBF Bridge"; const NAME = 'RTBF Bridge';
const URI = "http://www.rtbf.be/auvio/emissions/"; const URI = 'http://www.rtbf.be/auvio/emissions/';
const CACHE_TIMEOUT = 21600; //6h const CACHE_TIMEOUT = 21600; //6h
const DESCRIPTION = "Returns the newest RTBF videos by series ID"; const DESCRIPTION = 'Returns the newest RTBF videos by series ID';
const MAINTAINER = "Frenzie"; const MAINTAINER = 'Frenzie';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'c'=>array( 'c' => array(
'name'=>'series id', 'name' => 'series id',
'exampleValue'=>9500, 'exampleValue' => 9500,
'required'=>true 'required' => true
) )
)); ));
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$limit = 10; $limit = 10;
$count = 0; $count = 0;
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request RTBF.'); or returnServerError('Could not request RTBF.');
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element){
if($count >= $limit){
break;
}
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
if($count >= $limit) {
break;
}
$item = array(); $item = array();
$item['id'] = $element->getAttribute('data-id'); $item['id'] = $element->getAttribute('data-id');
$item['uri'] = self::URI.'detail?id='.$item['id']; $item['uri'] = self::URI . 'detail?id=' . $item['id'];
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset')); $thumbnailUriSrcSet = explode(
',',
$element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset')
);
$thumbnailUriLastSrc = end($thumbnailUriSrcSet); $thumbnailUriLastSrc = end($thumbnailUriSrcSet);
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0]; $thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
$item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext); $item['title'] = trim($element->find('h3',0)->plaintext)
. ' - '
. trim($element->find('h4',0)->plaintext);
$item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime')); $item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
$this->items[] = $item; $this->items[] = $item;
@ -40,9 +48,9 @@ class RTBFBridge extends BridgeAbstract {
} }
} }
public function getURI(){ public function getURI(){
return self::URI.'detail?id='.$this->getInput('c'); return self::URI . 'detail?id=' . $this->getInput('c');
} }
public function getName(){ public function getName(){
return $this->getInput('c') .' - RTBF Bridge'; return $this->getInput('c') .' - RTBF Bridge';

View file

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

View file

@ -1,120 +1,136 @@
<?php <?php
class Releases3DSBridge extends BridgeAbstract { class Releases3DSBridge extends BridgeAbstract {
const MAINTAINER = "ORelio"; const MAINTAINER = 'ORelio';
const NAME = "3DS Scene Releases"; const NAME = '3DS Scene Releases';
const URI = "http://www.3dsdb.com/"; const URI = 'http://www.3dsdb.com/';
const CACHE_TIMEOUT = 10800; // 3h const CACHE_TIMEOUT = 10800; // 3h
const DESCRIPTION = "Returns the newest scene releases."; const DESCRIPTION = 'Returns the newest scene releases.';
public function collectData(){ public function collectData(){
function ExtractFromDelimiters($string, $start, $end) { function extractFromDelimiters($string, $start, $end){
if (strpos($string, $start) !== false) { if(strpos($string, $start) !== false){
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
} return false; }
}
function TypeToString($type) { return false;
switch ($type) { }
case 1: return '3DS Game';
case 4: return 'eShop';
default: return '??? ('.$type.')';
}
}
function CardToString($card) { function typeToString($type){
switch ($card) { switch($type){
case 1: return 'Regular (CARD1)'; case 1: return '3DS Game';
case 2: return 'NAND (CARD2)'; case 4: return 'eShop';
default: return '??? ('.$card.')'; default: return '??? (' . $type . ')';
} }
} }
$dataUrl = self::URI.'xml.php'; function cardToString($card){
$xml = getContents($dataUrl) or returnServerError('Could not request 3dsdb: '.$dataUrl); switch($card){
$limit = 0; case 1: return 'Regular (CARD1)';
case 2: return 'NAND (CARD2)';
default: return '??? (' . $card . ')';
}
}
foreach (array_reverse(explode('<release>', $xml)) as $element) { $dataUrl = self::URI . 'xml.php';
if ($limit >= 5) { $xml = getContents($dataUrl)
break; or returnServerError('Could not request 3dsdb: ' . $dataUrl);
} $limit = 0;
if (strpos($element, '</release>') === false) { foreach(array_reverse(explode('<release>', $xml)) as $element){
continue; if($limit >= 5){
} break;
}
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>'); if(strpos($element, '</release>') === false){
if (empty($releasename)) { continue;
continue; }
}
$id = ExtractFromDelimiters($element, '<id>', '</id>'); $releasename = extractFromDelimiters($element, '<releasename>', '</releasename>');
$name = ExtractFromDelimiters($element, '<name>', '</name>'); if(empty($releasename)){
$publisher = ExtractFromDelimiters($element, '<publisher>', '</publisher>'); continue;
$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? $id = extractFromDelimiters($element, '<id>', '</id>');
$ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = ''; $name = extractFromDelimiters($element, '<name>', '</name>');
$ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name); $publisher = extractFromDelimiters($element, '<publisher>', '</publisher>');
if ($ignResult = getSimpleHTMLDOM($ignSearchUrl)) { $region = extractFromDelimiters($element, '<region>', '</region>');
$ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src; $group = extractFromDelimiters($element, '<group>', '</group>');
$ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext; $imagesize = extractFromDelimiters($element, '<imagesize>', '</imagesize>');
$ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href; $serial = extractFromDelimiters($element, '<serial>', '</serial>');
$ignDate = strtotime(trim($ignResult->find('span.publish-date', 0)->plaintext)); $titleid = extractFromDelimiters($element, '<titleid>', '</titleid>');
$ignDescription = '<div><img src="'.$ignCoverArt.'" /></div><div>'.$ignDesc.' <a href="'.$ignLink.'">More at IGN</a></div>'; $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>');
//Main section : Release description from 3DS database //Retrieve cover art and short desc from IGN?
$releaseDescription = '<h3>Release Details</h3>' $ignResult = false;
.'<b>Release ID: </b>'.$id.'<br />' $ignDescription = '';
.'<b>Game Name: </b>'.$name.'<br />' $ignLink = '';
.'<b>Publisher: </b>'.$publisher.'<br />' $ignDate = time();
.'<b>Region: </b>'.$region.'<br />' $ignCoverArt = '';
.'<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 $ignSearchUrl = 'http://www.ign.com/search?q=' . urlencode($name);
$releaseNameEncoded = urlencode(str_replace(' ', '+', $releasename)); if($ignResult = getSimpleHTMLDOM($ignSearchUrl)){
$searchLinkGoogle = 'https://google.com/?q='.$releaseNameEncoded; $ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src;
$searchLinkDuckDuckGo = 'https://duckduckgo.com/?q='.$releaseNameEncoded; $ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext;
$searchLinkQwant = 'https://lite.qwant.com/?q='.$releaseNameEncoded.'&t=web'; $ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href;
$releaseSearchLinks = '<h3>Search this release</h3><ul>' $ignDate = strtotime(trim($ignResult->find('span.publish-date', 0)->plaintext));
.'<li><a href="'.$searchLinkGoogle.'">Search using Google</a></li>' $ignDescription = '<div><img src="'
.'<li><a href="'.$searchLinkDuckDuckGo.'">Search using DuckDuckGo</a></li>' . $ignCoverArt
.'<li><a href="'.$searchLinkQwant.'">Search using Qwant</a></li>' . '" /></div><div>'
.'</ul>'; . $ignDesc
. ' <a href="'
. $ignLink
. '">More at IGN</a></div>';
}
//Build and add final item with the above three sections //Main section : Release description from 3DS database
$item = array(); $releaseDescription = '<h3>Release Details</h3><b>Release ID: </b>' . $id
$item['title'] = $name; . '<br /><b>Game Name: </b>' . $name
$item['author'] = $publisher; . '<br /><b>Publisher: </b>' . $publisher
$item['timestamp'] = $ignDate; . '<br /><b>Region: </b>' . $region
$item['uri'] = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink; . '<br /><b>Group: </b>' . $group
$item['content'] = $ignDescription.$releaseDescription.$releaseSearchLinks; . '<br /><b>Image size: </b>' . (intval($imagesize) / 8)
$this->items[] = $item; . 'MB<br /><b>Serial: </b>' . $serial
$limit++; . '<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++;
}
}
} }

View file

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

View file

@ -1,22 +1,25 @@
<?php <?php
class Rue89Bridge extends FeedExpander { class Rue89Bridge extends FeedExpander {
const MAINTAINER = "pit-fgfjiudghdf"; const MAINTAINER = 'pit-fgfjiudghdf';
const NAME = "Rue89"; const NAME = 'Rue89';
const URI = "http://rue89.nouvelobs.com/"; const URI = 'http://rue89.nouvelobs.com/';
const DESCRIPTION = "Returns the 5 newest posts from Rue89 (full text)"; const DESCRIPTION = 'Returns the 5 newest posts from Rue89 (full text)';
protected function parseItem($item){ protected function parseItem($item){
$item = parent::parseItem($item); $item = parent::parseItem($item);
$url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($item['uri'], -8)) . "/full"; $url = "http://api.rue89.nouvelobs.com/export/mobile2/node/"
. str_replace(" ", "", substr($item['uri'], -8))
. "/full";
$datas = json_decode(getContents($url), true); $datas = json_decode(getContents($url), true);
$item['content'] = $datas['node']['body']; $item['content'] = $datas['node']['body'];
return $item; return $item;
} }
public function collectData(){ public function collectData(){
$this->collectExpandableDatas('http://api.rue89.nouvelobs.com/feed'); $this->collectExpandableDatas('http://api.rue89.nouvelobs.com/feed');
} }
} }

View file

@ -1,12 +1,12 @@
<?php <?php
require_once('GelbooruBridge.php'); require_once('GelbooruBridge.php');
class Rule34Bridge extends GelbooruBridge{ class Rule34Bridge extends GelbooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Rule34"; const NAME = 'Rule34';
const URI = "http://rule34.xxx/"; const URI = 'http://rule34.xxx/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
const PIDBYPAGE=50; const PIDBYPAGE = 50;
} }

View file

@ -1,10 +1,10 @@
<?php <?php
require_once('Shimmie2Bridge.php'); require_once('Shimmie2Bridge.php');
class Rule34pahealBridge extends Shimmie2Bridge{ class Rule34pahealBridge extends Shimmie2Bridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Rule34paheal"; const NAME = 'Rule34paheal';
const URI = "http://rule34.paheal.net/"; const URI = 'http://rule34.paheal.net/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
} }

View file

@ -1,12 +1,12 @@
<?php <?php
require_once('GelbooruBridge.php'); require_once('GelbooruBridge.php');
class SafebooruBridge extends GelbooruBridge{ class SafebooruBridge extends GelbooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Safebooru"; const NAME = 'Safebooru';
const URI = "http://safebooru.org/"; const URI = 'http://safebooru.org/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
const PIDBYPAGE=40; const PIDBYPAGE = 40;
} }

View file

@ -1,11 +1,11 @@
<?php <?php
require_once('MoebooruBridge.php'); require_once('MoebooruBridge.php');
class SakugabooruBridge extends MoebooruBridge{ class SakugabooruBridge extends MoebooruBridge {
const MAINTAINER = "mitsukarenai"; const MAINTAINER = 'mitsukarenai';
const NAME = "Sakugabooru"; const NAME = 'Sakugabooru';
const URI = "http://sakuga.yshi.org/"; const URI = 'http://sakuga.yshi.org/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
} }

View file

@ -1,37 +1,39 @@
<?php <?php
class ScmbBridge extends BridgeAbstract{ class ScmbBridge extends BridgeAbstract {
const MAINTAINER = "Astalaseven"; const MAINTAINER = 'Astalaseven';
const NAME = "Se Coucher Moins Bête Bridge"; const NAME = 'Se Coucher Moins Bête Bridge';
const URI = "http://secouchermoinsbete.fr"; const URI = 'http://secouchermoinsbete.fr';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns the newest anecdotes."; const DESCRIPTION = 'Returns the newest anecdotes.';
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Se Coucher Moins Bete.'); or returnServerError('Could not request Se Coucher Moins Bete.');
foreach($html->find('article') as $article) { foreach($html->find('article') as $article){
$item = array(); $item = array();
$item['uri'] = self::URI.$article->find('p.summary a',0)->href; $item['uri'] = self::URI . $article->find('p.summary a', 0)->href;
$item['title'] = $article->find('header h1 a',0)->innertext; $item['title'] = $article->find('header h1 a', 0)->innertext;
$article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content // remove text "En savoir plus" from anecdote content
$content = $article->find('p.summary a',0)->innertext; $article->find('span.read-more', 0)->outertext = '';
$content =substr($content,0,strlen($content)-17); // remove superfluous spaces at the end $content = $article->find('p.summary a', 0)->innertext;
// remove superfluous spaces at the end
$content = substr($content, 0, strlen($content) - 17);
// get publication date // get publication date
$str_date = $article->find('time',0)->datetime; $str_date = $article->find('time', 0)->datetime;
list($date, $time) = explode(' ', $str_date); list($date, $time) = explode(' ', $str_date);
list($y, $m, $d) = explode('-', $date); list($y, $m, $d) = explode('-', $date);
list($h, $i) = explode(':', $time); list($h, $i) = explode(':', $time);
$timestamp = mktime($h,$i,0,$m,$d,$y); $timestamp = mktime($h, $i, 0, $m, $d, $y);
$item['timestamp'] = $timestamp; $item['timestamp'] = $timestamp;
$item['content'] = $content; $item['content'] = $content;
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }

View file

@ -1,33 +1,42 @@
<?php <?php
class ScoopItBridge extends BridgeAbstract{ class ScoopItBridge extends BridgeAbstract {
const MAINTAINER = "Pitchoule"; const MAINTAINER = 'Pitchoule';
const NAME = "ScoopIt"; const NAME = 'ScoopIt';
const URI = "http://www.scoop.it/"; const URI = 'http://www.scoop.it/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Returns most recent results from ScoopIt."; const DESCRIPTION = 'Returns most recent results from ScoopIt.';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'keyword', 'name' => 'keyword',
'required'=>true 'required' => true
) )
)); ));
public function collectData(){ public function collectData(){
$this->request = $this->getInput('u'); $this->request = $this->getInput('u');
$link = self::URI.'search?q=' .urlencode($this->getInput('u')); $link = self::URI . 'search?q=' . urlencode($this->getInput('u'));
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('Could not request ScoopIt. for : ' . $link); or returnServerError('Could not request ScoopIt. for : ' . $link);
foreach($html->find('div.post-view') as $element) { foreach($html->find('div.post-view') as $element){
$item = array(); $item = array();
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;
$item['title'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext); $item['title'] = preg_replace(
$item['content'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext); '~[[:cntrl:]]~',
$this->items[] = $item; '',
} $element->find('div.tCustomization_post_title',0)->plaintext
} );
$item['content'] = preg_replace(
'~[[:cntrl:]]~',
'',
$element->find('div.tCustomization_post_description', 0)->plaintext
);
$this->items[] = $item;
}
}
} }

View file

@ -1,78 +1,97 @@
<?php <?php
class SensCritiqueBridge extends BridgeAbstract { class SensCritiqueBridge extends BridgeAbstract {
const MAINTAINER = "kranack"; const MAINTAINER = 'kranack';
const NAME = "Sens Critique"; const NAME = 'Sens Critique';
const URI = "http://www.senscritique.com/"; const URI = 'http://www.senscritique.com/';
const CACHE_TIMEOUT = 21600; // 6h const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = "Sens Critique news"; const DESCRIPTION = 'Sens Critique news';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'm'=>array( 'm' => array(
'name'=>'Movies', 'name' => 'Movies',
'type'=>'checkbox' 'type' => 'checkbox'
), ),
's'=>array( 's' => array(
'name'=>'Series', 'name' => 'Series',
'type'=>'checkbox' 'type' => 'checkbox'
), ),
'g'=>array( 'g' => array(
'name'=>'Video Games', 'name' => 'Video Games',
'type'=>'checkbox' 'type' => 'checkbox'
), ),
'b'=>array( 'b' => array(
'name'=>'Books', 'name' => 'Books',
'type'=>'checkbox' 'type' => 'checkbox'
), ),
'bd'=>array( 'bd' => array(
'name'=>'BD', 'name' => 'BD',
'type'=>'checkbox' 'type' => 'checkbox'
), ),
'mu'=>array( 'mu' => array(
'name'=>'Music', 'name' => 'Music',
'type'=>'checkbox' 'type' => 'checkbox'
) )
)); ));
public function collectData(){ public function collectData(){
$categories=array(); $categories = array();
foreach(self::PARAMETERS[$this->queriedContext] as $category=>$properties){ foreach(self::PARAMETERS[$this->queriedContext] as $category => $properties){
if($this->getInput($category)){ if($this->getInput($category)){
$uri=self::URI; $uri = self::URI;
switch($category){ switch($category){
case 'm': $uri.='films/cette-semaine'; break; case 'm': $uri .= 'films/cette-semaine';
case 's': $uri.='series/actualite'; break; break;
case 'g': $uri.='jeuxvideo/actualite'; break; case 's': $uri .= 'series/actualite';
case 'b': $uri.='livres/actualite'; break; break;
case 'bd': $uri.='bd/actualite'; break; case 'g': $uri .= 'jeuxvideo/actualite';
case 'mu': $uri.='musique/actualite'; break; break;
} case 'b': $uri .= 'livres/actualite';
$html = getSimpleHTMLDOM($uri) break;
or returnServerError('No results for this query.'); case 'bd': $uri .= 'bd/actualite';
$list = $html->find('ul.elpr-list', 0); break;
case 'mu': $uri .= 'musique/actualite';
break;
}
$html = getSimpleHTMLDOM($uri)
or returnServerError('No results for this query.');
$list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list); $this->extractDataFromList($list);
} }
} }
} }
private function extractDataFromList($list) { private function extractDataFromList($list){
if ($list === null) { if($list === null){
returnClientError('Cannot extract data from list'); returnClientError('Cannot extract data from list');
} }
foreach ($list->find('li') as $movie) { foreach($list->find('li') as $movie){
$item = array(); $item = array();
$item['author'] = htmlspecialchars_decode($movie->find('.elco-title a', 0)->plaintext, ENT_QUOTES) . ' ' . $movie->find('.elco-date', 0)->plaintext; $item['author'] = htmlspecialchars_decode($movie->find('.elco-title a', 0)->plaintext, ENT_QUOTES)
$item['title'] = $movie->find('.elco-title a', 0)->plaintext . ' ' . $movie->find('.elco-date', 0)->plaintext; . ' '
$item['content'] = '<em>' . $movie->find('.elco-original-title', 0)->plaintext . '</em><br><br>' . . $movie->find('.elco-date', 0)->plaintext;
$movie->find('.elco-baseline', 0)->plaintext . '<br>' .
$movie->find('.elco-baseline', 1)->plaintext . '<br><br>' . $item['title'] = $movie->find('.elco-title a', 0)->plaintext
$movie->find('.elco-description', 0)->plaintext . '<br><br>' . . ' '
trim($movie->find('.erra-ratings .erra-global', 0)->plaintext) . ' / 10'; . $movie->find('.elco-date', 0)->plaintext;
$item['id'] = $this->getURI() . $movie->find('.elco-title a', 0)->href;
$item['uri'] = $this->getURI() . $movie->find('.elco-title a', 0)->href; $item['content'] = '<em>'
$this->items[] = $item; . $movie->find('.elco-original-title', 0)->plaintext
. '</em><br><br>'
. $movie->find('.elco-baseline', 0)->plaintext
. '<br>'
. $movie->find('.elco-baseline', 1)->plaintext
. '<br><br>'
. $movie->find('.elco-description', 0)->plaintext
. '<br><br>'
. trim($movie->find('.erra-ratings .erra-global', 0)->plaintext)
. ' / 10';
$item['id'] = $this->getURI() . $movie->find('.elco-title a', 0)->href;
$item['uri'] = $this->getURI() . $movie->find('.elco-title a', 0)->href;
$this->items[] = $item;
} }
} }
} }

View file

@ -1,75 +1,99 @@
<?php <?php
class SexactuBridge extends BridgeAbstract{ class SexactuBridge extends BridgeAbstract {
const MAINTAINER = "Riduidel"; const MAINTAINER = 'Riduidel';
const NAME = "Sexactu"; const NAME = 'Sexactu';
const URI = "https://www.gqmagazine.fr"; const URI = 'https://www.gqmagazine.fr';
const CACHE_TIMEOUT = 7200; // 2h const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = "Sexactu via rss-bridge"; const DESCRIPTION = 'Sexactu via rss-bridge';
public function collectData(){ public function collectData(){
$find = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'novembre', 'décembre'); $find = array(
$replace = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); 'janvier',
'février',
'mars',
'avril',
'mai',
'juin',
'juillet',
'août',
'septembre',
'novembre',
'décembre'
);
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request '.$this->getURI()); $replace = array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
);
foreach($html->find('.content-holder') as $contentHolder) { $html = getSimpleHTMLDOM($this->getURI())
// only use first list as second one only contains pages numbers or returnServerError('Could not request ' . $this->getURI());
$articles = $contentHolder->find('ul', 0);
foreach($articles->find('li') as $element) {
// if you ask about that method_exists, there seems to be a bug in simple html dom
// see stackoverflow for more details : http://stackoverflow.com/a/10828479/15619
if(is_object($element)) {
$item = array();
// various metadata
$titleBlock = $element->find('.title-holder', 0);
if(is_object($titleBlock)) {
$titleDetails = $titleBlock->find('.article-title',0);
$titleData = $titleDetails->find('h2', 0)->find('a',0);
$titleTimestamp =$titleDetails->find('h4',0);
$item['title'] = $this->correctCase(trim($titleData->innertext));
$item['uri'] = self::URI.$titleData->href;
// Fugly date parsing due to the fact my DNS-323 doesn't support php intl extension foreach($html->find('.content-holder') as $contentHolder){
$dateText = $titleTimestamp->innertext; // only use first list as second one only contains pages numbers
$dateText = substr($dateText, strpos($dateText,',')+1); $articles = $contentHolder->find('ul', 0);
$dateText = str_replace($find, $replace, strtolower($dateText)); foreach($articles->find('li') as $element){
$date = strtotime($dateText); // if you ask about that method_exists, there seems to be a bug in simple html dom
$item['timestamp'] = $date; // see stackoverflow for more details : http://stackoverflow.com/a/10828479/15619
if(is_object($element)){
$item = array();
// various metadata
$titleBlock = $element->find('.title-holder', 0);
if(is_object($titleBlock)){
$titleDetails = $titleBlock->find('.article-title', 0);
$titleData = $titleDetails->find('h2', 0)->find('a', 0);
$titleTimestamp = $titleDetails->find('h4', 0);
$item['title'] = $this->correctCase(trim($titleData->innertext));
$item['uri'] = self::URI . $titleData->href;
$item['author'] = "Maïa Mazaurette"; // Fugly date parsing due to the fact my DNS-323 doesn't support php intl extension
$elementText = $element->find('.text-container', 0); $dateText = $titleTimestamp->innertext;
// don't forget to replace images server url with gq one $dateText = substr($dateText, strpos($dateText, ',') + 1);
foreach($elementText->find('img') as $image) { $dateText = str_replace($find, $replace, strtolower($dateText));
$image->src = self::URI.$image->src; $date = strtotime($dateText);
} $item['timestamp'] = $date;
$item['content'] = $elementText->innertext;
$this->items[] = $item;
}
} $item['author'] = 'Maïa Mazaurette';
$elementText = $element->find('.text-container', 0);
// don't forget to replace images server url with gq one
foreach($elementText->find('img') as $image){
$image->src = self::URI . $image->src;
}
$item['content'] = $elementText->innertext;
$this->items[] = $item;
}
}
}
}
}
} public function getURI(){
} return self::URI . '/sexactu';
} }
public function getURI(){ private function correctCase($str){
return self::URI.'/sexactu'; $sentences = explode('.', mb_strtolower($str, 'UTF-8'));
} $str = '';
$sep = '';
foreach ($sentences as $sentence){
//upper case first char
$sentence = ucfirst(trim($sentence));
private function correctCase($str) { //append sentence to output
$sentences=explode('.', mb_strtolower($str, "UTF-8")); $str = $str . $sep . $sentence;
$str=""; $sep = '. ';
$sep=""; }
foreach ($sentences as $sentence) return $str;
{ }
//upper case first char
$sentence=ucfirst(trim($sentence));
//append sentence to output
$str=$str.$sep.$sentence;
$sep=". ";
}
return $str;
}
} }

View file

@ -1,109 +1,123 @@
<?php <?php
class ShanaprojectBridge extends BridgeAbstract { class ShanaprojectBridge extends BridgeAbstract {
const MAINTAINER = 'logmanoriginal'; const MAINTAINER = 'logmanoriginal';
const NAME = 'Shanaproject Bridge'; const NAME = 'Shanaproject Bridge';
const URI = 'http://www.shanaproject.com'; const URI = 'http://www.shanaproject.com';
const DESCRIPTION = 'Returns a list of anime from the current Season Anime List'; const DESCRIPTION = 'Returns a list of anime from the current Season Anime List';
// Returns an html object for the Season Anime List (latest season) // Returns an html object for the Season Anime List (latest season)
private function LoadSeasonAnimeList(){ private function loadSeasonAnimeList(){
// First we need to find the URI to the latest season from the 'seasons' page searching for 'Season Anime List' // First we need to find the URI to the latest season from the
$html = getSimpleHTMLDOM($this->getURI() . '/seasons'); // 'seasons' page searching for 'Season Anime List'
if(!$html) $html = getSimpleHTMLDOM($this->getURI() . '/seasons');
returnServerError('Could not load \'seasons\' page!'); if(!$html)
returnServerError('Could not load \'seasons\' page!');
$season = $html->find('div.follows_menu/a', 1); $season = $html->find('div.follows_menu/a', 1);
if(!$season) if(!$season)
returnServerError('Could not find \'Season Anime List\'!'); returnServerError('Could not find \'Season Anime List\'!');
$html = getSimpleHTMLDOM($this->getURI() . $season->href); $html = getSimpleHTMLDOM($this->getURI() . $season->href);
if(!$html) if(!$html)
returnServerError('Could not load \'Season Anime List\' from \'' . $season->innertext . '\'!'); returnServerError(
'Could not load \'Season Anime List\' from \''
. $season->innertext
. '\'!'
);
return $html; return $html;
} }
// Extracts the anime title // Extracts the anime title
private function ExtractAnimeTitle($anime){ private function extractAnimeTitle($anime){
$title = $anime->find('a', 0); $title = $anime->find('a', 0);
if(!$title) if(!$title)
returnServerError('Could not find anime title!'); returnServerError('Could not find anime title!');
return trim($title->innertext); return trim($title->innertext);
} }
// Extracts the anime URI // Extracts the anime URI
private function ExtractAnimeURI($anime){ private function extractAnimeUri($anime){
$uri = $anime->find('a', 0); $uri = $anime->find('a', 0);
if(!$uri) if(!$uri)
returnServerError('Could not find anime URI!'); returnServerError('Could not find anime URI!');
return $this->getURI() . $uri->href; return $this->getURI() . $uri->href;
} }
// Extracts the anime release date (timestamp) // Extracts the anime release date (timestamp)
private function ExtractAnimeTimestamp($anime){ private function extractAnimeTimestamp($anime){
$timestamp = $anime->find('span.header_info_block', 1); $timestamp = $anime->find('span.header_info_block', 1);
if(!$timestamp) if(!$timestamp)
returnServerError('Could not find anime timestamp!'); returnServerError('Could not find anime timestamp!');
return strtotime($timestamp->innertext); return strtotime($timestamp->innertext);
} }
// Extracts the anime studio name (author) // Extracts the anime studio name (author)
private function ExtractAnimeAuthor($anime){ private function extractAnimeAuthor($anime){
$author = $anime->find('span.header_info_block', 2); $author = $anime->find('span.header_info_block', 2);
if(!$author) if(!$author)
return; // Sometimes the studio is unknown, so leave empty return; // Sometimes the studio is unknown, so leave empty
return trim($author->innertext); return trim($author->innertext);
} }
// Extracts the episode information (x of y released) // Extracts the episode information (x of y released)
private function ExtractAnimeEpisodeInformation($anime){ private function extractAnimeEpisodeInformation($anime){
$episode = $anime->find('div.header_info_episode', 0); $episode = $anime->find('div.header_info_episode', 0);
if(!$episode) if(!$episode)
returnServerError('Could not find anime episode information!'); returnServerError('Could not find anime episode information!');
return preg_replace('/\r|\n/', ' ', $episode->plaintext); return preg_replace('/\r|\n/', ' ', $episode->plaintext);
} }
// Extracts the background image // Extracts the background image
private function ExtractAnimeBackgroundImage($anime){ private function extractAnimeBackgroundImage($anime){
// Getting the picture is a little bit tricky as it is part of the style. // Getting the picture is a little bit tricky as it is part of the style.
// Luckily the style is part of the parent div :) // Luckily the style is part of the parent div :)
if(preg_match("/url\(\/\/([^\)]+)\)/i", $anime->parent->style, $matches)) if(preg_match("/url\(\/\/([^\)]+)\)/i", $anime->parent->style, $matches))
return $matches[1]; return $matches[1];
returnServerError('Could not extract background image!'); returnServerError('Could not extract background image!');
} }
// Builds an URI to search for a specific anime (subber is left empty) // Builds an URI to search for a specific anime (subber is left empty)
private function BuildAnimeSearchURI($anime){ private function buildAnimeSearchUri($anime){
return $this->getURI() . '/search/?title=' . urlencode($this->ExtractAnimeTitle($anime)) . '&subber='; return $this->getURI()
} . '/search/?title='
. urlencode($this->extractAnimeTitle($anime))
. '&subber=';
}
// Builds the content string for a given anime // Builds the content string for a given anime
private function BuildAnimeContent($anime){ private function buildAnimeContent($anime){
// We'll use a template string to place our contents // We'll use a template string to place our contents
return '<a href="' . $this->ExtractAnimeURI($anime) . '"> return '<a href="'
<img src="http://' . $this->ExtractAnimeBackgroundImage($anime) . '" alt="' . htmlspecialchars($this->ExtractAnimeTitle($anime)) . '" style="border: 1px solid black"> . $this->extractAnimeUri($anime)
</a><br> . '"><img src="http://'
<p>' . $this->ExtractAnimeEpisodeInformation($anime) . '</p><br> . $this->extractAnimeBackgroundImage($anime)
<p><a href="' . $this->BuildAnimeSearchURI($anime) . '">Search episodes</a></p>'; . '" alt="'
} . htmlspecialchars($this->extractAnimeTitle($anime))
. '" style="border: 1px solid black"></a><br><p>'
. $this->extractAnimeEpisodeInformation($anime)
. '</p><br><p><a href="'
. $this->buildAnimeSearchUri($anime)
. '">Search episodes</a></p>';
}
public function collectData(){ public function collectData(){
$html = $this->LoadSeasonAnimeList(); $html = $this->loadSeasonAnimeList();
$animes = $html->find('div.header_display_box_info'); $animes = $html->find('div.header_display_box_info');
if(!$animes) if(!$animes)
returnServerError('Could not find anime headers!'); returnServerError('Could not find anime headers!');
foreach($animes as $anime){ foreach($animes as $anime){
$item = array(); $item = array();
$item['title'] = $this->ExtractAnimeTitle($anime); $item['title'] = $this->extractAnimeTitle($anime);
$item['author'] = $this->ExtractAnimeAuthor($anime); $item['author'] = $this->extractAnimeAuthor($anime);
$item['uri'] = $this->ExtractAnimeURI($anime); $item['uri'] = $this->extractAnimeUri($anime);
$item['timestamp'] = $this->ExtractAnimeTimestamp($anime); $item['timestamp'] = $this->extractAnimeTimestamp($anime);
$item['content'] = $this->BuildAnimeContent($anime); $item['content'] = $this->buildAnimeContent($anime);
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }

View file

@ -1,31 +1,39 @@
<?php <?php
require_once('DanbooruBridge.php'); require_once('DanbooruBridge.php');
class Shimmie2Bridge extends DanbooruBridge{ class Shimmie2Bridge extends DanbooruBridge {
const NAME = "Shimmie v2"; const NAME = 'Shimmie v2';
const URI = "http://shimmie.shishnet.org/v2/"; const URI = 'http://shimmie.shishnet.org/v2/';
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = 'Returns images from given page';
const PATHTODATA='.shm-thumb-link'; const PATHTODATA = '.shm-thumb-link';
const IDATTRIBUTE='data-post-id'; const IDATTRIBUTE = 'data-post-id';
protected function getFullURI(){ protected function getFullURI(){
return $this->getURI().'post/list/' return $this->getURI()
.$this->getInput('t').'/' . 'post/list/'
.$this->getInput('p'); . $this->getInput('t')
} . '/'
. $this->getInput('p');
}
protected function getItemFromElement($element){ protected function getItemFromElement($element){
$item = array(); $item = array();
$item['uri'] = $this->getURI().$element->href; $item['uri'] = $this->getURI() . $element->href;
$item['id'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute(static::IDATTRIBUTE)); $item['id'] = (int)preg_replace("/[^0-9]/", '', $element->getAttribute(static::IDATTRIBUTE));
$item['timestamp'] = time(); $item['timestamp'] = time();
$thumbnailUri = $this->getURI().$element->find('img', 0)->src; $thumbnailUri = $this->getURI() . $element->find('img', 0)->src;
$item['tags'] = $element->getAttribute('data-tags'); $item['tags'] = $element->getAttribute('data-tags');
$item['title'] = $this->getName().' | '.$item['id']; $item['title'] = $this->getName() . ' | ' . $item['id'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags']; $item['content'] = '<a href="'
return $item; . $item['uri']
} . '"><img src="'
. $thumbnailUri
. '" /></a><br>Tags: '
. $item['tags'];
return $item;
}
} }

View file

@ -1,50 +1,60 @@
<?php <?php
class SoundCloudBridge extends BridgeAbstract{ class SoundCloudBridge extends BridgeAbstract {
const MAINTAINER = "kranack"; const MAINTAINER = 'kranack';
const NAME = "Soundcloud Bridge"; const NAME = 'Soundcloud Bridge';
const URI = "https://soundcloud.com/"; const URI = 'https://soundcloud.com/';
const CACHE_TIMEOUT = 600; // 10min const CACHE_TIMEOUT = 600; // 10min
const DESCRIPTION = "Returns 10 newest music from user profile"; const DESCRIPTION = 'Returns 10 newest music from user profile';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'u'=>array( 'u' => array(
'name'=>'username', 'name' => 'username',
'required'=>true 'required' => true
) )
)); ));
const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875'; const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875';
public function collectData(){ public function collectData(){
$res = json_decode(getContents( $res = json_decode(getContents(
'https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/' 'https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'
. urlencode($this->getInput('u')) . urlencode($this->getInput('u'))
.'&client_id=' . self::CLIENT_ID . '&client_id='
)) or returnServerError('No results for this query'); . self::CLIENT_ID
$tracks = json_decode(getContents( )) or returnServerError('No results for this query');
'https://api.soundcloud.com/users/'
. urlencode($res->id)
.'/tracks?client_id=' . self::CLIENT_ID
)) or returnServerError('No results for this user');
for ($i=0; $i < 10; $i++) { $tracks = json_decode(getContents(
$item = array(); 'https://api.soundcloud.com/users/'
$item['author'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; . urlencode($res->id)
$item['title'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; . '/tracks?client_id='
$item['content'] = '<audio src="'. $tracks[$i]->uri .'/stream?client_id='. self::CLIENT_ID .'">'; . self::CLIENT_ID
$item['id'] = self::URI )) or returnServerError('No results for this user');
. urlencode($this->getInput('u')) .'/'
. urlencode($tracks[$i]->permalink); for($i = 0; $i < 10; $i++){
$item['uri'] = self::URI $item = array();
. urlencode($this->getInput('u')) .'/' $item['author'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title;
. urlencode($tracks[$i]->permalink); $item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title;
$this->items[] = $item; $item['content'] = '<audio src="'
. $tracks[$i]->uri
. '/stream?client_id='
. self::CLIENT_ID
. '">';
$item['id'] = self::URI
. urlencode($this->getInput('u'))
. '/'
. urlencode($tracks[$i]->permalink);
$item['uri'] = self::URI
. urlencode($this->getInput('u'))
. '/'
. urlencode($tracks[$i]->permalink);
$this->items[] = $item;
} }
} }
public function getName(){ public function getName(){
return self::NAME .' - '. $this->getInput('u'); return self::NAME . ' - ' . $this->getInput('u');
} }
} }

View file

@ -1,24 +1,23 @@
<?php <?php
class StripeAPIChangeLogBridge extends BridgeAbstract{ class StripeAPIChangeLogBridge extends BridgeAbstract {
const MAINTAINER = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
const NAME = 'Stripe API Changelog'; const NAME = 'Stripe API Changelog';
const URI = 'https://stripe.com/docs/upgrades'; const URI = 'https://stripe.com/docs/upgrades';
const CACHE_TIMEOUT = 86400; // 24h const CACHE_TIMEOUT = 86400; // 24h
const DESCRIPTION = 'Returns the changes made to the stripe.com API'; const DESCRIPTION = 'Returns the changes made to the stripe.com API';
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('No results for Stripe API Changelog'); or returnServerError('No results for Stripe API Changelog');
foreach($html->find('h3') as $change){
foreach($html->find('h3') as $change){ $item = array();
$item=array(); $item['title'] = trim($change->plaintext);
$item['title']=trim($change->plaintext); $item['uri'] = self::URI . '#' . $item['title'];
$item['uri']=self::URI.'#'.$item['title']; $item['author'] = 'stripe';
$item['author']='stripe'; $item['content'] = $change->nextSibling()->outertext;
$item['content']=$change->nextSibling()->outertext; $item['timestamp'] = strtotime($item['title']);
$item['timestamp']=strtotime($item['title']); $this->items[] = $item;
$this->items[]=$item; }
} }
}
} }

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