This commit is contained in:
logmanoriginal 2016-09-01 19:13:26 +02:00
commit 85a025a82b
38 changed files with 472 additions and 554 deletions

View file

@ -10,6 +10,7 @@ class OpenClassroomsBridge extends BridgeAbstract{
'u'=>array( 'u'=>array(
'name'=>'Catégorie', 'name'=>'Catégorie',
'type'=>'list', 'type'=>'list',
'required'=>true,
'values'=>array( 'values'=>array(
'Arts & Culture'=>'arts', 'Arts & Culture'=>'arts',
'Code'=>'code', 'Code'=>'code',
@ -24,21 +25,18 @@ class OpenClassroomsBridge extends BridgeAbstract{
) )
)); ));
public function getURI(){
return $this->uri.'/courses?categories='.$this->getInput('u').'&'
.'title=&sort=updatedAt+desc';
}
public function collectData(){ public function collectData(){
if (empty($this->getInput('u'))) $html = $this->getSimpleHTMLDOM($this->getURI())
{ or $this->returnServerError('Could not request OpenClassrooms.');
$this->returnServerError('Error: You must chose a category.');
}
$html = '';
$link = 'https://openclassrooms.com/courses?categories='.$this->getInput('u').'&title=&sort=updatedAt+desc';
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request OpenClassrooms.');
foreach($html->find('.courseListItem') as $element) { foreach($html->find('.courseListItem') as $element) {
$item = array(); $item = array();
$item['uri'] = 'https://openclassrooms.com'.$element->find('a', 0)->href; $item['uri'] = $this->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

@ -25,30 +25,8 @@ class ParuVenduImmoBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$html = ''; $html = $this->getSimpleHTMLDOM($this->getURI())
$num = 20; or $this->returnServerError('Could not request paruvendu.');
$appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1';
$maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1';
$link = $this->uri.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison;
if ($this->getInput('minarea')) {
$link .= '&sur0='.urlencode($this->getInput('minarea'));
}
if ($this->getInput('maxprice')) {
$link .= '&px1='.urlencode($this->getInput('maxprice'));
}
if ($this->getInput('pa')) {
$link .= '&pa='.urlencode($this->getInput('pa'));
}
if ($this->getInput('lo')) {
$link .= '&lo='.urlencode($this->getInput('lo'));
}
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request paruvendu.');
foreach($html->find('div.annonce a') as $element) { foreach($html->find('div.annonce a') as $element) {
@ -79,16 +57,38 @@ class ParuVenduImmoBridge extends BridgeAbstract
} }
} }
public function getURI(){
$appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1';
$maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1';
$link = $this->uri.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison;
if ($this->getInput('minarea')) {
$link .= '&sur0='.urlencode($this->getInput('minarea'));
}
if ($this->getInput('maxprice')) {
$link .= '&px1='.urlencode($this->getInput('maxprice'));
}
if ($this->getInput('pa')) {
$link .= '&pa='.urlencode($this->getInput('pa'));
}
if ($this->getInput('lo')) {
$link .= '&lo='.urlencode($this->getInput('lo'));
}
return $link;
}
public function getName(){ public function getName(){
$request=''; $request='';
if($this->getInput('minarea') && $minarea=$this->getInput('minarea');
!empty($this->getInput('minarea')) if(!empty($minarea)){
){ $request .= ' '.$minarea.' m2';
$request .= ' '.$this->getInput('minarea').' m2';
} }
if($this->getInput('lo') && $location=$this->getInput('lo');
!empty($this->getInput('lo'))){ if(!empty($location)){
$request .= ' In: '.$this->getInput('lo'); $request .= ' In: '.$location;
} }
return 'Paru Vendu Immobilier'.$request; return 'Paru Vendu Immobilier'.$request;
} }

View file

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

View file

@ -1,53 +1,41 @@
<?php <?php
class PinterestBridge extends BridgeAbstract{ class PinterestBridge extends BridgeAbstract{
private $username;
private $board;
private $query;
public $maintainer = "pauder"; public $maintainer = "pauder";
public $name = "Pinterest Bridge"; public $name = "Pinterest Bridge";
public $uri = "http://www.pinterest.com"; public $uri = "http://www.pinterest.com/";
public $description = "Returns the newest images on a board"; public $description = "Returns the newest images on a board";
public $parameters = array( public $parameters = array(
'By username and board' => array( 'By username and board' => array(
'u'=>array('name'=>'username'), 'u'=>array(
'b'=>array('name'=>'board') 'name'=>'username',
'required'=>true
),
'b'=>array(
'name'=>'board',
'required'=>true
)
), ),
'From search' => array( 'From search' => array(
'q'=>array('name'=>'Keyword') 'q'=>array(
'name'=>'Keyword',
'required'=>true
)
) )
); );
public function collectData(){ public function collectData(){
$html = ''; $html = $this->getSimpleHTMLDOM($this->getURI()) ;
if ($this->getInput('u') || $this->getInput('b')) { if(!$html){
switch($this->queriedContext){
if (empty($this->getInput('u'))) case 'By username and board':
{ $this->returnServerError('Username and/or board not found');
$this->returnClientError('You must specify a Pinterest username (?u=...).'); case 'From search':
} $this->returnServerError('Could not request Pinterest.');
if (empty($this->getInput('b')))
{
$this->returnClientError('You must specify a Pinterest board for this username (?b=...).');
}
$this->username = $this->getInput('u');
$this->board = $this->getInput('b');
$html = $this->getSimpleHTMLDOM($this->getURI().'/'.urlencode($this->username).'/'.urlencode($this->board)) or $this->returnServerError('Username and/or board not found');
} else if ($this->getInput('q'))
{
$this->query = $this->getInput('q');
$html = $this->getSimpleHTMLDOM($this->getURI().'/search/?q='.urlencode($this->query)) or $this->returnServerError('Could not request Pinterest.');
} }
}
else {
$this->returnClientError('You must specify a Pinterest username and a board name (?u=...&b=...).');
}
foreach($html->find('div.pinWrapper') as $div) foreach($html->find('div.pinWrapper') as $div)
{ {
@ -60,7 +48,7 @@ class PinterestBridge extends BridgeAbstract{
$item['content'] = '<img src="' . htmlentities(str_replace('/236x/', '/736x/', $img->getAttribute('src'))) . '" alt="" />'; $item['content'] = '<img src="' . htmlentities(str_replace('/236x/', '/736x/', $img->getAttribute('src'))) . '" alt="" />';
if (isset($this->query)) if ($this->queriedContext==='From search')
{ {
$avatar = $div->find('div.creditImg', 0)->find('img', 0); $avatar = $div->find('div.creditImg', 0)->find('img', 0);
$avatar = $avatar->getAttribute('data-src'); $avatar = $avatar->getAttribute('data-src');
@ -86,13 +74,28 @@ class PinterestBridge extends BridgeAbstract{
} }
} }
public function getName(){ public function getURI(){
switch($this->queriedContext){
case 'By username and board':
$uri = $this->uri.urlencode($this->getInput('u')).'/'.urlencode($this->getInput('b'));
break;
case 'From search':
$uri = $this->uri.'search/?q='.urlencode($this->getInput('q'));
break;
}
if (isset($this->query)) return $uri;
{ }
return $this->query .' - Pinterest';
} else { public function getName(){
return $this->username .' - '. $this->board.' - Pinterest'; switch($this->queriedContext){
} case 'By username and board':
$specific = $this->getInput('u').'-'.$this->getInput('b');
break;
case 'From search':
$specific = $this->getInput('q');
break;
}
return $specific .' - '.$this->name;
} }
} }

View file

@ -13,7 +13,8 @@ class PlanetLibreBridge extends BridgeAbstract{
} }
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM('http://www.planet-libre.org/') or $this->returnServerError('Could not request PlanetLibre.'); $html = $this->getSimpleHTMLDOM($this->uri)
or $this->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) {

View file

@ -8,12 +8,12 @@ class ProjectMGameBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$html = ''; $html = $this->getSimpleHTMLDOM($this->uri)
$html = $this->getSimpleHTMLDOM('http://projectmgame.com/en/') or $this->returnServerError('Error while downloading the Project M homepage'); or $this->returnServerError('Error while downloading the Project M homepage');
foreach($html->find('article') as $article) { foreach($html->find('article') as $article) {
$item = array(); $item = array();
$item['uri'] = 'http://projectmgame.com/en/'.$article->find('section div.info_block a',0)->href; $item['uri'] = $this->uri.$article->find('section div.info_block a',0)->href;
$item['title'] = $article->find('h1 p',0)->innertext; $item['title'] = $article->find('h1 p',0)->innertext;
$p_list = $article->find('section p'); $p_list = $article->find('section p');

View file

@ -1,7 +1,7 @@
<?php <?php
class RTBFBridge extends BridgeAbstract { class RTBFBridge extends BridgeAbstract {
public $name = "RTBF Bridge"; public $name = "RTBF Bridge";
public $uri = "http://www.rtbf.be/auvio/emissions"; public $uri = "http://www.rtbf.be/auvio/emissions/";
public $description = "Returns the newest RTBF videos by series ID"; public $description = "Returns the newest RTBF videos by series ID";
public $maintainer = "Frenzie"; public $maintainer = "Frenzie";
@ -18,32 +18,33 @@ class RTBFBridge extends BridgeAbstract {
$limit = 10; $limit = 10;
$count = 0; $count = 0;
if ($this->getInput('c')) { $html = $this->getSimpleHTMLDOM($this->getURI())
$html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$this->getInput('c')) or $this->returnServerError('Could not request RTBF.'); or $this->returnServerError('Could not request RTBF.');
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) { foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
if($count < $limit) { if($count >= $limit) {
$item = array(); break;
$item['id'] = $element->getAttribute('data-id'); }
$item['uri'] = 'http://www.rtbf.be/auvio/detail?id='.$item['id']; $item = array();
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset')); $item['id'] = $element->getAttribute('data-id');
$thumbnailUriLastSrc = end($thumbnailUriSrcSet); $item['uri'] = $this->uri.'detail?id='.$item['id'];
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0]; $thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
$item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext); $thumbnailUriLastSrc = end($thumbnailUriSrcSet);
$item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime')); $thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; $item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext);
$this->items[] = $item; $item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
$count++; $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
} $this->items[] = $item;
} $count++;
}
else {
$this->returnClientError('You must specify a series id.');
} }
} }
public function getURI(){
return $this->uri.'detail?id='.$this->getInput('c');
}
public function getName(){ public function getName(){
return (!empty($this->request) ? $this->request .' - ' : '') .'RTBF Bridge'; return $this->getInput('c') .' - RTBF Bridge';
} }
public function getCacheDuration(){ public function getCacheDuration(){

View file

@ -32,84 +32,88 @@ class Releases3DSBridge extends BridgeAbstract {
} }
} }
$dataUrl = 'http://3dsdb.com/xml.php'; $dataUrl = $this->uri.'xml.php';
$xml = $this->getContents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl); $xml = $this->getContents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl);
$limit = 0; $limit = 0;
foreach (array_reverse(explode('<release>', $xml)) as $element) { foreach (array_reverse(explode('<release>', $xml)) as $element) {
if ($limit < 5) { if ($limit >= 5) {
if (strpos($element, '</release>') !== false) { break;
$id = ExtractFromDelimiters($element, '<id>', '</id>');
$name = ExtractFromDelimiters($element, '<name>', '</name>');
$publisher = ExtractFromDelimiters($element, '<publisher>', '</publisher>');
$region = ExtractFromDelimiters($element, '<region>', '</region>');
$group = ExtractFromDelimiters($element, '<group>', '</group>');
$imagesize = ExtractFromDelimiters($element, '<imagesize>', '</imagesize>');
$serial = ExtractFromDelimiters($element, '<serial>', '</serial>');
$titleid = ExtractFromDelimiters($element, '<titleid>', '</titleid>');
$imgcrc = ExtractFromDelimiters($element, '<imgcrc>', '</imgcrc>');
$filename = ExtractFromDelimiters($element, '<filename>', '</filename>');
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
$trimmedsize = ExtractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>');
$firmware = ExtractFromDelimiters($element, '<firmware>', '</firmware>');
$type = ExtractFromDelimiters($element, '<type>', '</type>');
$card = ExtractFromDelimiters($element, '<card>', '</card>');
if (!empty($releasename)) {
//Retrieve cover art and short desc from IGN?
$ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = '';
$ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name);
if ($ignResult = $this->getSimpleHTMLDOM($ignSearchUrl)) {
$ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src;
$ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext;
$ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href;
$ignDate = strtotime(trim($ignResult->find('span.publish-date', 0)->plaintext));
$ignDescription = '<div><img src="'.$ignCoverArt.'" /></div><div>'.$ignDesc.' <a href="'.$ignLink.'">More at IGN</a></div>';
}
//Main section : Release description from 3DS database
$releaseDescription = '<h3>Release Details</h3>'
.'<b>Release ID: </b>'.$id.'<br />'
.'<b>Game Name: </b>'.$name.'<br />'
.'<b>Publisher: </b>'.$publisher.'<br />'
.'<b>Region: </b>'.$region.'<br />'
.'<b>Group: </b>'.$group.'<br />'
.'<b>Image size: </b>'.(intval($imagesize)/8).'MB<br />'
.'<b>Serial: </b>'.$serial.'<br />'
.'<b>Title ID: </b>'.$titleid.'<br />'
.'<b>Image CRC: </b>'.$imgcrc.'<br />'
.'<b>File Name: </b>'.$filename.'<br />'
.'<b>Release Name: </b>'.$releasename.'<br />'
.'<b>Trimmed size: </b>'.intval(intval($trimmedsize)/1048576).'MB<br />'
.'<b>Firmware: </b>'.$firmware.'<br />'
.'<b>Type: </b>'.TypeToString($type).'<br />'
.'<b>Card: </b>'.CardToString($card).'<br />';
//Build search links section to facilitate release search using search engines
$releaseNameEncoded = urlencode(str_replace(' ', '+', $releasename));
$searchLinkGoogle = 'https://google.com/?q='.$releaseNameEncoded;
$searchLinkDuckDuckGo = 'https://duckduckgo.com/?q='.$releaseNameEncoded;
$searchLinkQwant = 'https://lite.qwant.com/?q='.$releaseNameEncoded.'&t=web';
$releaseSearchLinks = '<h3>Search this release</h3><ul>'
.'<li><a href="'.$searchLinkGoogle.'">Search using Google</a></li>'
.'<li><a href="'.$searchLinkDuckDuckGo.'">Search using DuckDuckGo</a></li>'
.'<li><a href="'.$searchLinkQwant.'">Search using Qwant</a></li>'
.'</ul>';
//Build and add final item with the above three sections
$item = array();
$item['title'] = $name;
$item['author'] = $publisher;
$item['timestamp'] = $ignDate;
$item['uri'] = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink;
$item['content'] = $ignDescription.$releaseDescription.$releaseSearchLinks;
$this->items[] = $item;
$limit++;
}
}
} }
if (strpos($element, '</release>') === false) {
continue;
}
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
if (empty($releasename)) {
continue;
}
$id = ExtractFromDelimiters($element, '<id>', '</id>');
$name = ExtractFromDelimiters($element, '<name>', '</name>');
$publisher = ExtractFromDelimiters($element, '<publisher>', '</publisher>');
$region = ExtractFromDelimiters($element, '<region>', '</region>');
$group = ExtractFromDelimiters($element, '<group>', '</group>');
$imagesize = ExtractFromDelimiters($element, '<imagesize>', '</imagesize>');
$serial = ExtractFromDelimiters($element, '<serial>', '</serial>');
$titleid = ExtractFromDelimiters($element, '<titleid>', '</titleid>');
$imgcrc = ExtractFromDelimiters($element, '<imgcrc>', '</imgcrc>');
$filename = ExtractFromDelimiters($element, '<filename>', '</filename>');
$trimmedsize = ExtractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>');
$firmware = ExtractFromDelimiters($element, '<firmware>', '</firmware>');
$type = ExtractFromDelimiters($element, '<type>', '</type>');
$card = ExtractFromDelimiters($element, '<card>', '</card>');
//Retrieve cover art and short desc from IGN?
$ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = '';
$ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name);
if ($ignResult = $this->getSimpleHTMLDOM($ignSearchUrl)) {
$ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src;
$ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext;
$ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href;
$ignDate = strtotime(trim($ignResult->find('span.publish-date', 0)->plaintext));
$ignDescription = '<div><img src="'.$ignCoverArt.'" /></div><div>'.$ignDesc.' <a href="'.$ignLink.'">More at IGN</a></div>';
}
//Main section : Release description from 3DS database
$releaseDescription = '<h3>Release Details</h3>'
.'<b>Release ID: </b>'.$id.'<br />'
.'<b>Game Name: </b>'.$name.'<br />'
.'<b>Publisher: </b>'.$publisher.'<br />'
.'<b>Region: </b>'.$region.'<br />'
.'<b>Group: </b>'.$group.'<br />'
.'<b>Image size: </b>'.(intval($imagesize)/8).'MB<br />'
.'<b>Serial: </b>'.$serial.'<br />'
.'<b>Title ID: </b>'.$titleid.'<br />'
.'<b>Image CRC: </b>'.$imgcrc.'<br />'
.'<b>File Name: </b>'.$filename.'<br />'
.'<b>Release Name: </b>'.$releasename.'<br />'
.'<b>Trimmed size: </b>'.intval(intval($trimmedsize)/1048576).'MB<br />'
.'<b>Firmware: </b>'.$firmware.'<br />'
.'<b>Type: </b>'.TypeToString($type).'<br />'
.'<b>Card: </b>'.CardToString($card).'<br />';
//Build search links section to facilitate release search using search engines
$releaseNameEncoded = urlencode(str_replace(' ', '+', $releasename));
$searchLinkGoogle = 'https://google.com/?q='.$releaseNameEncoded;
$searchLinkDuckDuckGo = 'https://duckduckgo.com/?q='.$releaseNameEncoded;
$searchLinkQwant = 'https://lite.qwant.com/?q='.$releaseNameEncoded.'&t=web';
$releaseSearchLinks = '<h3>Search this release</h3><ul>'
.'<li><a href="'.$searchLinkGoogle.'">Search using Google</a></li>'
.'<li><a href="'.$searchLinkDuckDuckGo.'">Search using DuckDuckGo</a></li>'
.'<li><a href="'.$searchLinkQwant.'">Search using Qwant</a></li>'
.'</ul>';
//Build and add final item with the above three sections
$item = array();
$item['title'] = $name;
$item['author'] = $publisher;
$item['timestamp'] = $ignDate;
$item['uri'] = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink;
$item['content'] = $ignDescription.$releaseDescription.$releaseSearchLinks;
$this->items[] = $item;
$limit++;
} }
} }

View file

@ -24,7 +24,7 @@ class ReporterreBridge extends BridgeAbstract{
} }
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM('http://www.reporterre.net/spip.php?page=backend') or $this->returnServerError('Could not request Reporterre.'); $html = $this->getSimpleHTMLDOM($this->uri.'spip.php?page=backend') or $this->returnServerError('Could not request Reporterre.');
$limit = 0; $limit = 0;
foreach($html->find('item') as $element) { foreach($html->find('item') as $element) {

View file

@ -15,21 +15,16 @@ class Rule34Bridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$page = 0;$tags=''; $html = $this->getSimpleHTMLDOM(
if ($this->getInput('p')) { $this->uri.'index.php?page=post&s=list&'
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
$page = $page - 1; .'&tags='.urlencode($this->getInput('t'))
$page = $page * 50; ) or $this->returnServerError('Could not request Rule34.');
}
if ($this->getInput('t')) {
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("http://rule34.xxx/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Rule34.');
foreach($html->find('div[class=content] span') as $element) { foreach($html->find('div[class=content] span') as $element) {
$item = array(); $item = array();
$item['uri'] = 'http://rule34.xxx/'.$element->find('a', 0)->href; $item['uri'] = $this->uri.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time(); $item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src; $thumbnailUri = $element->find('img', 0)->src;

View file

@ -16,19 +16,13 @@ class Rule34pahealBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$page = 0;$tags=''; $html = $this->getSimpleHTMLDOM($this->uri.'post/list/'.$tags.'/'.$page)
if ($this->getInput('p')) { or $this->returnServerError('Could not request Rule34paheal.');
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p'));
}
if ($this->getInput('t')) {
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("http://rule34.paheal.net/post/list/$tags/$page") or $this->returnServerError('Could not request Rule34paheal.');
foreach($html->find('div[class=shm-image-list] div[class=shm-thumb]') as $element) { foreach($html->find('div[class=shm-image-list] div[class=shm-thumb]') as $element) {
$item = array(); $item = array();
$item['uri'] = 'http://rule34.paheal.net'.$element->find('a', 0)->href; $item['uri'] = $this->uri.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('img', 0)->getAttribute('id')); $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('img', 0)->getAttribute('id'));
$item['timestamp'] = time(); $item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src; $thumbnailUri = $element->find('img', 0)->src;

View file

@ -15,21 +15,15 @@ class SafebooruBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$page = 0;$tags=''; $html = $this->getSimpleHTMLDOM(
if ($this->getInput('p')) { $this->uri.'index.php?page=post&s=list&'
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*40:'')
$page = $page - 1; .'&tags='.urlencode($this->getInput('t'))
$page = $page * 40; ) or $this->returnServerError('Could not request Safebooru.');
}
if ($this->getInput('t')) {
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("http://safebooru.org/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Safebooru.');
foreach($html->find('div[class=content] span') as $element) { foreach($html->find('div[class=content] span') as $element) {
$item = array(); $item = array();
$item['uri'] = 'http://safebooru.org/'.$element->find('a', 0)->href; $item['uri'] = $this->uri.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time(); $item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src; $thumbnailUri = $element->find('img', 0)->src;

View file

@ -9,20 +9,19 @@ class SakugabooruBridge extends BridgeAbstract{
public $parameters = array( array( public $parameters = array( array(
'p'=>array( 'p'=>array(
'name'=>'page', 'name'=>'page',
'defaultValue'=>1,
'type'=>'number' 'type'=>'number'
), ),
't'=>array('name'=>'tags') 't'=>array('name'=>'tags')
)); ));
public function collectData(){ public function collectData(){
$page = 1;$tags=''; $html = $this->getSimpleHTMLDOM(
if ($this->getInput('p')) { $this->uri.'post?'
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); .'&page='.$this->getInput('p')
} .'&tags='.urlencode($this->getInput('t'))
if ($this->getInput('t')) { ) or $this->returnServerError('Could not request Sakugabooru.');
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("http://sakuga.yshi.org/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Sakugabooru.');
$input_json = explode('Post.register(', $html); $input_json = explode('Post.register(', $html);
foreach($input_json as $element) foreach($input_json as $element)
$data[] = preg_replace('/}\)(.*)/', '}', $element); $data[] = preg_replace('/}\)(.*)/', '}', $element);
@ -31,7 +30,7 @@ class SakugabooruBridge extends BridgeAbstract{
foreach($data as $datai) { foreach($data as $datai) {
$json = json_decode($datai, TRUE); $json = json_decode($datai, TRUE);
$item = array(); $item = array();
$item['uri'] = 'http://sakuga.yshi.org/post/show/'.$json['id']; $item['uri'] = $this->uri.'/post/show/'.$json['id'];
$item['postid'] = $json['id']; $item['postid'] = $json['id'];
$item['timestamp'] = $json['created_at']; $item['timestamp'] = $json['created_at'];
$item['imageUri'] = $json['file_url']; $item['imageUri'] = $json['file_url'];

View file

@ -8,11 +8,12 @@ class ScmbBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$html = $this->getSimpleHTMLDOM('http://secouchermoinsbete.fr/') or $this->returnServerError('Could not request Se Coucher Moins Bete.'); $html = $this->getSimpleHTMLDOM($this->uri)
or $this->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'] = 'http://secouchermoinsbete.fr'.$article->find('p.summary a',0)->href; $item['uri'] = $this->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 $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content

View file

@ -3,7 +3,7 @@ class ScoopItBridge extends BridgeAbstract{
public $maintainer = "Pitchoule"; public $maintainer = "Pitchoule";
public $name = "ScoopIt"; public $name = "ScoopIt";
public $uri = "http://www.scoop.it"; public $uri = "http://www.scoop.it/";
public $description = "Returns most recent results from ScoopIt."; public $description = "Returns most recent results from ScoopIt.";
public $parameters = array( array( public $parameters = array( array(
@ -14,23 +14,19 @@ class ScoopItBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$html = ''; $this->request = $this->getInput('u');
if ($this->getInput('u') != '') { $link = $this->uri.'search?q=' .urlencode($this->getInput('u'));
$this->request = $this->getInput('u');
$link = 'http://scoop.it/search?q=' .urlencode($this->request);
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request ScoopIt. for : ' . $link); $html = $this->getSimpleHTMLDOM($link)
or $this->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('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext);
$item['content'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext); $item['content'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext);
$this->items[] = $item; $this->items[] = $item;
} }
} else {
$this->returnServerError('You must specify a keyword');
}
} }
public function getCacheDuration(){ public function getCacheDuration(){

View file

@ -3,7 +3,7 @@ class SensCritiqueBridge extends BridgeAbstract {
public $maintainer = "kranack"; public $maintainer = "kranack";
public $name = "Sens Critique"; public $name = "Sens Critique";
public $uri = "http://www.senscritique.com"; public $uri = "http://www.senscritique.com/";
public $description = "Sens Critique news"; public $description = "Sens Critique news";
public $parameters = array( array( public $parameters = array( array(
@ -34,71 +34,27 @@ class SensCritiqueBridge extends BridgeAbstract {
)); ));
public function collectData(){ public function collectData(){
if (($this->getInput('m') && $this->getInput('m'))) { $categories=array();
$this->collectMoviesData(); foreach($this->parameters[$this->queriedContext] as $category=>$properties){
} else if (($this->getInput('s') && $this->getInput('s'))) { if($this->getInput($category)){
$this->collectSeriesData(); $uri=$this->uri;
} else if (($this->getInput('g') && $this->getInput('g'))) { switch($category){
$this->collectGamesData(); case 'm': $uri.='films/cette-semaine'; break;
} else if (($this->getInput('b') && $this->getInput('b'))) { case 's': $uri.='series/actualite'; break;
$this->collectBooksData(); case 'g': $uri.='jeuxvideo/actualite'; break;
} else if (($this->getInput('bd') && $this->getInput('bd'))) { case 'b': $uri.='livres/actualite'; break;
$this->collectBDsData(); case 'bd': $uri.='bd/actualite'; break;
} else if (($this->getInput('mu') && $this->getInput('mu'))) { case 'mu': $uri.='musique/actualite'; break;
$this->collectMusicsData(); }
} else { $html = $this->getSimpleHTMLDOM($uri)
$this->returnClientError('You must choose a category'); or $this->returnServerError('No results for this query.');
} $list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list);
}
}
} }
private function collectMoviesData() {
$html = '';
$html = $this->getSimpleHTMLDOM('http://www.senscritique.com/films/cette-semaine') or $this->returnServerError('No results for this query.');
$list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list);
}
private function collectSeriesData() {
$html = '';
$html = $this->getSimpleHTMLDOM('http://www.senscritique.com/series/actualite') or $this->returnServerError('No results for this query.');
$list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list);
}
private function collectGamesData() {
$html = '';
$html = $this->getSimpleHTMLDOM('http://www.senscritique.com/jeuxvideo/actualite') or $this->returnServerError('No results for this query.');
$list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list);
}
private function collectBooksData() {
$html = '';
$html = $this->getSimpleHTMLDOM('http://www.senscritique.com/livres/actualite') or $this->returnServerError('No results for this query.');
$list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list);
}
private function collectBDsData() {
$html = '';
$html = $this->getSimpleHTMLDOM('http://www.senscritique.com/bd/actualite') or $this->returnServerError('No results for this query.');
$list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list);
}
private function collectMusicsData() {
$html = '';
$html = $this->getSimpleHTMLDOM('http://www.senscritique.com/musique/actualite') or $this->returnServerError('No results for this query.');
$list = $html->find('ul.elpr-list', 0);
$this->extractDataFromList($list);
}
private function extractDataFromList($list) { private function extractDataFromList($list) {
if ($list === null) { if ($list === null) {
$this->returnClientError('Cannot extract data from list'); $this->returnClientError('Cannot extract data from list');

View file

@ -14,8 +14,9 @@ class SiliconBridge extends BridgeAbstract {
return $string; return $string;
} }
$feedUrl = 'http://www.silicon.fr/feed'; $feedUrl = $this->uri.'feed';
$html = $this->getSimpleHTMLDOM($feedUrl) or $this->returnServerError('Could not request Silicon: '.$feedUrl); $html = $this->getSimpleHTMLDOM($feedUrl)
or $this->returnServerError('Could not request Silicon: '.$feedUrl);
$limit = 0; $limit = 0;
foreach($html->find('item') as $element) { foreach($html->find('item') as $element) {
@ -25,7 +26,8 @@ class SiliconBridge extends BridgeAbstract {
$article_uri = $element->innertext; $article_uri = $element->innertext;
$article_uri = substr($article_uri, strpos($article_uri, '<link>') + 6); $article_uri = substr($article_uri, strpos($article_uri, '<link>') + 6);
$article_uri = substr($article_uri, 0, strpos($article_uri, '</link>')); $article_uri = substr($article_uri, 0, strpos($article_uri, '</link>'));
$article_html = $this->getSimpleHTMLDOM($article_uri) or $this->returnServerError('Could not request Silicon: '.$article_uri); $article_html = $this->getSimpleHTMLDOM($article_uri)
or $this->returnServerError('Could not request Silicon: '.$article_uri);
//Build article contents from corresponding elements //Build article contents from corresponding elements
$thumbnailUri = $element->find('enclosure', 0)->url; $thumbnailUri = $element->find('enclosure', 0)->url;

View file

@ -3,7 +3,7 @@ class SoundCloudBridge extends BridgeAbstract{
public $maintainer = "kranack"; public $maintainer = "kranack";
public $name = "Soundcloud Bridge"; public $name = "Soundcloud Bridge";
public $uri = "http://www.soundcloud.com/"; public $uri = "https://soundcloud.com/";
public $description = "Returns 10 newest music from user profile"; public $description = "Returns 10 newest music from user profile";
public $parameters = array( array( public $parameters = array( array(
@ -33,10 +33,10 @@ class SoundCloudBridge extends BridgeAbstract{
$item['author'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item['author'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title;
$item['title'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item['title'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title;
$item['content'] = '<audio src="'. $tracks[$i]->uri .'/stream?client_id='. self::CLIENT_ID .'">'; $item['content'] = '<audio src="'. $tracks[$i]->uri .'/stream?client_id='. self::CLIENT_ID .'">';
$item['id'] = 'https://soundcloud.com/' $item['id'] = $this->uri
. urlencode($this->getInput('u')) .'/' . urlencode($this->getInput('u')) .'/'
. urlencode($tracks[$i]->permalink); . urlencode($tracks[$i]->permalink);
$item['uri'] = 'https://soundcloud.com/' $item['uri'] = $this->uri
. urlencode($this->getInput('u')) .'/' . urlencode($this->getInput('u')) .'/'
. urlencode($tracks[$i]->permalink); . urlencode($tracks[$i]->permalink);
$this->items[] = $item; $this->items[] = $item;

View file

@ -6,14 +6,14 @@ class StripeAPIChangeLogBridge extends BridgeAbstract{
public $description = 'Returns the changes made to the stripe.com API'; public $description = 'Returns the changes made to the stripe.com API';
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM('https://stripe.com/docs/upgrades') $html = $this->getSimpleHTMLDOM($this->uri)
or $this->returnServerError('No results for Stripe API Changelog'); or $this->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']='https://stripe.com/docs/upgrades#'.$item['title']; $item['uri']=$this->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']);

View file

@ -1,45 +1,46 @@
<?php <?php
class SuperbWallpapersBridge extends BridgeAbstract { class SuperbWallpapersBridge extends BridgeAbstract {
private $category;
private $resolution;
public $maintainer = "nel50n"; public $maintainer = "nel50n";
public $name = "Superb Wallpapers Bridge"; public $name = "Superb Wallpapers Bridge";
public $uri = "http://www.superbwallpapers.com/"; public $uri = "http://www.superbwallpapers.com/";
public $description = "Returns the latests wallpapers from SuperbWallpapers"; public $description = "Returns the latests wallpapers from SuperbWallpapers";
public $parameters = array( array( public $parameters = array( array(
'c'=>array('name'=>'category'), 'c'=>array(
'name'=>'category',
'required'=>true
),
'm'=>array( 'm'=>array(
'name'=>'Max number of wallpapers', 'name'=>'Max number of wallpapers',
'type'=>'number' 'type'=>'number'
), ),
'r'=>array( 'r'=>array(
'name'=>'resolution', 'name'=>'resolution',
'exampleValue'=>'1920x1200, 1680x1050,…' 'exampleValue'=>'1920x1200, 1680x1050,…',
'defaultValue'=>'1920x1200'
) )
)); ));
public function collectData(){ public function collectData(){
$html = ''; $category = $this->getInput('c');
$baseUri = 'http://www.superbwallpapers.com'; $resolution = $this->getInput('r'); // Wide wallpaper default
$this->category = $this->getInput('c') ?: ''; // All default
$this->resolution = $this->getInput('r') ?: '1920x1200'; // Wide wallpaper default
$num = 0; $num = 0;
$max = $this->getInput('m') ?: 36; $max = $this->getInput('m') ?: 36;
$lastpage = 1; $lastpage = 1;
// Get last page number // Get last page number
$link = $baseUri.'/'.$this->category.'/9999.html'; $link = $this->uri.'/'.$category.'/9999.html';
$html = $this->getSimpleHTMLDOM($link); $html = $this->getSimpleHTMLDOM($link)
or $this->returnServerError('Could not load '.$link);
$lastpage = min($html->find('.paging .cpage', 0)->innertext(), ceil($max/36)); $lastpage = min($html->find('.paging .cpage', 0)->innertext(), ceil($max/36));
for ($page = 1; $page <= $lastpage; $page++) { for ($page = 1; $page <= $lastpage; $page++) {
$link = $baseUri.'/'.$this->category.'/'.$page.'.html'; $link = $this->uri.'/'.$category.'/'.$page.'.html';
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.'); $html = $this->getSimpleHTMLDOM($link)
or $this->returnServerError('No results for this query.');
foreach($html->find('.wpl .i a') as $element) { foreach($html->find('.wpl .i a') as $element) {
$thumbnail = $element->find('img', 0); $thumbnail = $element->find('img', 0);
@ -59,7 +60,7 @@ class SuperbWallpapersBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
return 'HDWallpapers - '.$this->category.' ['.$this->resolution.']'; return $this->name .'- '.$this->getInput('c').' ['.$this->getInput('r').']';
} }
public function getCacheDuration(){ public function getCacheDuration(){

View file

@ -24,14 +24,11 @@ class T411Bridge extends BridgeAbstract {
} return false; } return false;
} }
//Ensure proper parameters have been provided
if (empty($this->getInput('search'))) {
$this->returnClientError('You must specify a search criteria');
}
//Retrieve torrent listing from search results, which does not contain torrent description //Retrieve torrent listing from search results, which does not contain torrent description
$url = $this->uri.'torrents/search/?'.$this->getInput('search').'&order=added&type=desc'; $url = $this->uri.'torrents/search/?'.$this->getInput('search').'&order=added&type=desc';
$html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request t411: '.$url); $html = $this->getSimpleHTMLDOM($url)
or $this->returnServerError('Could not request t411: '.$url);
$results = $html->find('table.results', 0); $results = $html->find('table.results', 0);
if (is_null($results)) if (is_null($results))
$this->returnServerError('No results from t411: '.$url); $this->returnServerError('No results from t411: '.$url);
@ -41,42 +38,48 @@ class T411Bridge extends BridgeAbstract {
foreach ($results->find('tr') as $element) { foreach ($results->find('tr') as $element) {
//Limit total amount of requests and ignore table header //Limit total amount of requests and ignore table header
if ($limit < 10 && !is_object($element->find('th', 0))) { if ($limit >= 10){
break;
//Requests are rate-limited
usleep(500000); //So we need to wait (500ms)
//Retrieve data from RSS entry
$item_uri = $this->uri.'torrents/details/?id='.ExtractFromDelimiters($element->find('a.nfo', 0)->outertext, '?id=', '"');
$item_title = ExtractFromDelimiters($element->outertext, '" title="', '"');
$item_date = strtotime($element->find('dd', 0)->plaintext);
//Retrieve full description from torrent page
if ($item_html = $this->getSimpleHTMLDOM($item_uri)) {
//Retrieve data from page contents
$item_desc = $item_html->find('div.description', 0);
$item_author = $item_html->find('a.profile', 0)->innertext;
//Cleanup advertisments
$divs = explode('<div class="align-center">', $item_desc->innertext);
$item_desc = '';
foreach ($divs as $text)
if (strpos($text, 'adprovider.adlure.net') === false)
$item_desc = $item_desc.'<div class="align-center">'.$text;
$item_desc = preg_replace('/<h2 class="align-center">LIENS DE T..?L..?CHARGEMENT<\/h2>/i', '', $item_desc);
//Build and add final item
$item = array();
$item['uri'] = $item_uri;
$item['title'] = $item_title;
$item['author'] = $item_author;
$item['timestamp'] = $item_date;
$item['content'] = $item_desc;
$this->items[] = $item;
$limit++;
}
} }
if(is_object($element->find('th', 0))){
continue;
}
//Requests are rate-limited
usleep(500000); //So we need to wait (500ms)
//Retrieve data from RSS entry
$item_uri = $this->uri.'torrents/details/?id='.ExtractFromDelimiters($element->find('a.nfo', 0)->outertext, '?id=', '"');
$item_title = ExtractFromDelimiters($element->outertext, '" title="', '"');
$item_date = strtotime($element->find('dd', 0)->plaintext);
//Retrieve full description from torrent page
$item_html = $this->getSimpleHTMLDOM($item_uri);
if (!$item_html) {
continue;
}
//Retrieve data from page contents
$item_desc = $item_html->find('div.description', 0);
$item_author = $item_html->find('a.profile', 0)->innertext;
//Cleanup advertisments
$divs = explode('<div class="align-center">', $item_desc->innertext);
$item_desc = '';
foreach ($divs as $text)
if (strpos($text, 'adprovider.adlure.net') === false)
$item_desc = $item_desc.'<div class="align-center">'.$text;
$item_desc = preg_replace('/<h2 class="align-center">LIENS DE T..?L..?CHARGEMENT<\/h2>/i', '', $item_desc);
//Build and add final item
$item = array();
$item['uri'] = $item_uri;
$item['title'] = $item_title;
$item['author'] = $item_author;
$item['timestamp'] = $item_date;
$item['content'] = $item_desc;
$this->items[] = $item;
$limit++;
} }
} }
} }

View file

@ -3,7 +3,7 @@ class TagBoardBridge extends BridgeAbstract{
public $maintainer = "Pitchoule"; public $maintainer = "Pitchoule";
public $name = "TagBoard"; public $name = "TagBoard";
public $uri = "http://www.TagBoard.com"; public $uri = "http://www.TagBoard.com/";
public $description = "Returns most recent results from TagBoard."; public $description = "Returns most recent results from TagBoard.";
public $parameters = array( array( public $parameters = array( array(
@ -14,11 +14,10 @@ class TagBoardBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$html = ''; $link = 'https://post-cache.tagboard.com/search/' .$this->getInput('u');
$this->request = $this->getInput('u');
$link = 'https://post-cache.tagboard.com/search/' .$this->request;
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request TagBoard for : ' . $link); $html = $this->getSimpleHTMLDOM($link)
or $this->returnServerError('Could not request TagBoard for : ' . $link);
$parsed_json = json_decode($html); $parsed_json = json_decode($html);
foreach($parsed_json->{'posts'} as $element) { foreach($parsed_json->{'posts'} as $element) {
@ -36,7 +35,7 @@ class TagBoardBridge extends BridgeAbstract{
} }
public function getName(){ public function getName(){
return 'tagboard - ' .$this->request; return 'tagboard - ' .$this->getInput('u');
} }
public function getCacheDuration(){ public function getCacheDuration(){

View file

@ -15,21 +15,16 @@ class TbibBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$page = 0;$tags=''; $html = $this->getSimpleHTMLDOM(
if ($this->getInput('p')) { $this->uri.'index.php?page=post&s=list&'
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
$page = $page - 1; .'&tags='.urlencode($this->getInput('t'))
$page = $page * 50; ) or $this->returnServerError('Could not request Tbib.');
}
if ($this->getInput('t')) {
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("http://tbib.org/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Tbib.');
foreach($html->find('div[class=content] span') as $element) { foreach($html->find('div[class=content] span') as $element) {
$item = array(); $item = array();
$item['uri'] = 'http://tbib.org/'.$element->find('a', 0)->href; $item['uri'] = $this->uri.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time(); $item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src; $thumbnailUri = $element->find('img', 0)->src;

View file

@ -7,7 +7,8 @@ class TheCodingLoveBridge extends BridgeAbstract{
public $description = "The Coding Love"; public $description = "The Coding Love";
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM('http://thecodinglove.com/') or $this->returnServerError('Could not request The Coding Love.'); $html = $this->getSimpleHTMLDOM($this->uri)
or $this->returnServerError('Could not request The Coding Love.');
foreach($html->find('div.post') as $element) { foreach($html->find('div.post') as $element) {
$item = array(); $item = array();

View file

@ -1,7 +1,4 @@
<?php <?php
define("THE_OATMEAL", "http://theoatmeal.com/");
define("THE_OATMEAL_RSS", "http://feeds.feedburner.com/oatmealfeed");
class TheOatmealBridge extends RssExpander{ class TheOatmealBridge extends RssExpander{
public $maintainer = "Riduidel"; public $maintainer = "Riduidel";
@ -10,7 +7,7 @@ class TheOatmealBridge extends RssExpander{
public $description = "Un petit site de dessins assez rigolos"; public $description = "Un petit site de dessins assez rigolos";
public function collectData(){ public function collectData(){
parent::collectExpandableDatas(THE_OATMEAL_RSS); $this->collectExpandableDatas('http://feeds.feedburner.com/oatmealfeed');
} }

View file

@ -9,7 +9,8 @@ class ThePirateBayBridge extends BridgeAbstract{
public $parameters = array( array( public $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
) )
)); ));
@ -49,12 +50,10 @@ class ThePirateBayBridge extends BridgeAbstract{
} }
if (!$this->getInput('q'))
$this->returnClientError('You must specify keywords (?q=...)');
$keywordsList = explode(";",$this->getInput('q')); $keywordsList = explode(";",$this->getInput('q'));
foreach($keywordsList as $keywords){ foreach($keywordsList as $keywords){
$html = $this->getSimpleHTMLDOM('https://thepiratebay.org/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnServerError('Could not request TPB.'); $html = $this->getSimpleHTMLDOM($this->uri.'search/'.rawurlencode($keywords).'/0/3/0')
or $this->returnServerError('Could not request TPB.');
if ($html->find('table#searchResult', 0) == FALSE) if ($html->find('table#searchResult', 0) == FALSE)
$this->returnServerError('No result for query '.$keywords); $this->returnServerError('No result for query '.$keywords);
@ -62,7 +61,7 @@ class ThePirateBayBridge extends BridgeAbstract{
foreach($html->find('tr') as $element) { foreach($html->find('tr') as $element) {
$item = array(); $item = array();
$item['uri'] = 'https://thepiratebay.org/'.$element->find('a.detLink',0)->href; $item['uri'] = $this->uri.$element->find('a.detLink',0)->href;
$item['id'] = $item['uri']; $item['id'] = $item['uri'];
$item['timestamp'] = parseDateTimestamp($element); $item['timestamp'] = parseDateTimestamp($element);
$item['title'] = $element->find('a.detLink',0)->plaintext; $item['title'] = $element->find('a.detLink',0)->plaintext;

View file

@ -39,11 +39,9 @@ class TwitchApiBridge extends BridgeAbstract{
$context = stream_context_create($opts); $context = stream_context_create($opts);
if(!$this->getInput('limit') || $limit = $this->getInput('limit');
empty($this->getInput('limit'))){ if(!$limit){
$limit = TWITCH_LIMIT; $limit = TWITCH_LIMIT;
}else{
$limit = (int)$this->getInput('limit');
} }
// The Twitch API allows a limit between 1 .. 100. Therefore any value below must be set to 1, any greater must result in multiple requests. // The Twitch API allows a limit between 1 .. 100. Therefore any value below must be set to 1, any greater must result in multiple requests.

View file

@ -86,7 +86,7 @@ class TwitterBridge extends BridgeAbstract{
// get TweetID // get TweetID
$item['id'] = $tweet->getAttribute('data-tweet-id'); $item['id'] = $tweet->getAttribute('data-tweet-id');
// get tweet link // get tweet link
$item['uri'] = 'https://twitter.com'.$tweet->find('a.js-permalink', 0)->getAttribute('href'); $item['uri'] = $this->uri.$tweet->find('a.js-permalink', 0)->getAttribute('href');
// extract tweet timestamp // extract tweet timestamp
$item['timestamp'] = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time'); $item['timestamp'] = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time');
// generate the title // generate the title
@ -111,7 +111,7 @@ class TwitterBridge extends BridgeAbstract{
} }
// get tweet text // get tweet text
$cleanedTweet = str_replace('href="/', 'href="https://twitter.com/', $tweet->find('p.js-tweet-text', 0)->innertext); $cleanedTweet = str_replace('href="/', 'href="'.$this->uri, $tweet->find('p.js-tweet-text', 0)->innertext);
// Add picture to content // Add picture to content
$picture_html = ''; $picture_html = '';

View file

@ -9,32 +9,32 @@ class UnsplashBridge extends BridgeAbstract {
public $parameters = array( array( public $parameters = array( array(
'm'=>array( 'm'=>array(
'name'=>'Max number of photos', 'name'=>'Max number of photos',
'type'=>'number' 'type'=>'number',
'defaultValue'=>20
), ),
'w'=>array( 'w'=>array(
'name'=>'Width', 'name'=>'Width',
'exampleValue'=>'1920, 1680, …' 'exampleValue'=>'1920, 1680, …',
'defaultValue'=>'1920'
), ),
'q'=>array( 'q'=>array(
'name'=>'JPEG quality', 'name'=>'JPEG quality',
'type'=>'number' 'type'=>'number',
'defaultValue'=>75
) )
)); ));
public function collectData(){ public function collectData(){
$html = ''; $width = $this->getInput('w') ;
$baseUri = 'http://unsplash.com';
$width = $this->getInput('w') ?: '1920'; // Default width
$num = 0; $num = 0;
$max = $this->getInput('m') ?: 20; $max = $this->getInput('m');
$quality = $this->getInput('q') ?: 75; $quality = $this->getInput('q');
$lastpage = 1; $lastpage = 1;
for ($page = 1; $page <= $lastpage; $page++) { for ($page = 1; $page <= $lastpage; $page++) {
$link = $baseUri.'/grid?page='.$page; $link = $this->uri.'/grid?page='.$page;
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.'); $html = $this->getSimpleHTMLDOM($link)
or $this->returnServerError('No results for this query.');
if ($page === 1) { if ($page === 1) {
preg_match('/=(\d+)$/', $html->find('.pagination > a[!class]', -1)->href, $matches); preg_match('/=(\d+)$/', $html->find('.pagination > a[!class]', -1)->href, $matches);

View file

@ -1,5 +1,5 @@
<?php <?php
class ViadeoCompany extends BridgeAbstract{ class ViadeoCompanyBridge extends BridgeAbstract{
public $maintainer = "regisenguehard"; public $maintainer = "regisenguehard";
public $name = "Viadeo Company"; public $name = "Viadeo Company";
@ -15,9 +15,10 @@ class ViadeoCompany extends BridgeAbstract{
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$link = 'http://www.viadeo.com/fr/company/'.$this->getInput('c'); $link = $this->uri.'fr/company/'.$this->getInput('c');
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request Viadeo.'); $html = $this->getSimpleHTMLDOM($link)
or $this->returnServerError('Could not request Viadeo.');
foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) { foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) {
$title = $element->find('p', 0)->innertext; $title = $element->find('p', 0)->innertext;

View file

@ -15,9 +15,10 @@ class VineBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
$html = ''; $html = '';
$uri = 'http://vine.co/u/'.$this->getInput('u').'?mode=list'; $uri = $this->uri.'/u/'.$this->getInput('u').'?mode=list';
$html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for this query.'); $html = $this->getSimpleHTMLDOM($uri)
or $this->returnServerError('No results for this query.');
foreach($html->find('.post') as $element) { foreach($html->find('.post') as $element) {
$a = $element->find('a', 0); $a = $element->find('a', 0);

View file

@ -4,7 +4,7 @@ class VkBridge extends BridgeAbstract {
public $maintainer = "ahiles3005"; public $maintainer = "ahiles3005";
public $name = "VK.com"; public $name = "VK.com";
public $uri = "http://www.vk.com/"; public $uri = "http://vk.com/";
public $description = "Working with open pages"; public $description = "Working with open pages";
public $parameters=array( public $parameters=array(
'Url on page group or user' => array( 'Url on page group or user' => array(
@ -16,13 +16,10 @@ class VkBridge extends BridgeAbstract {
); );
public function collectData(){ public function collectData(){
$html = ''; $text_html = $this->getContents(urldecode($this->getInput('u')))
if ($this->getInput('u')) { or $this->returnServerError('No results for this query.');
$text_html = $this->getSimpleHTMLDOM(urldecode($this->getInput('u'))) $text_html = iconv('windows-1251', 'utf-8', $text_html);
or $this->returnServerError('No results for this query.'); $html = str_get_html($text_html);
$text_html = iconv('windows-1251', 'utf-8', $text_html);
$html = str_get_html($text_html);
}
foreach ($html->find('div.post_table') as $post) { foreach ($html->find('div.post_table') as $post) {
if (is_object($post->find('a.wall_post_more', 0))) { if (is_object($post->find('a.wall_post_more', 0))) {
$post->find('a.wall_post_more', 0)->outertext = ''; //delete link "show full" in content $post->find('a.wall_post_more', 0)->outertext = ''; //delete link "show full" in content
@ -36,20 +33,16 @@ class VkBridge extends BridgeAbstract {
//get video on post //get video on post
if (is_object($post->find('span.post_video_title_content', 0))) { if (is_object($post->find('span.post_video_title_content', 0))) {
$titleVideo = $post->find('span.post_video_title_content', 0)->plaintext; $titleVideo = $post->find('span.post_video_title_content', 0)->plaintext;
$linkToVideo = 'https://vk.com' . $post->find('a.page_post_thumb_video', 0)->getAttribute('href'); $linkToVideo = $this->uri . $post->find('a.page_post_thumb_video', 0)->getAttribute('href');
$item['content'] .= "\n\r {$titleVideo}: {$linkToVideo}"; $item['content'] .= "\n\r {$titleVideo}: {$linkToVideo}";
} }
$item['uri'] = 'https://vk.com' . $post->find('.reply_link_wrap', 0)->find('a', 0)->getAttribute('href'); // get post link $item['uri'] = $this->uri . $post->find('.reply_link_wrap', 0)->find('a', 0)->getAttribute('href'); // get post link
$item['date'] = $post->find('span.rel_date', 0)->plaintext; $item['date'] = $post->find('span.rel_date', 0)->plaintext;
$this->items[] = $item; $this->items[] = $item;
// var_dump($item['date']); // var_dump($item['date']);
} }
} }
public function getName() {
return(isset($this->name) ? $this->name . ' - ' : '') . 'VK Bridge';
}
public function getCacheDuration() { public function getCacheDuration() {
return 300; // 5 minutes return 300; // 5 minutes
} }

View file

@ -1,13 +1,9 @@
<?php <?php
class WallpaperStopBridge extends BridgeAbstract { class WallpaperStopBridge extends BridgeAbstract {
private $category;
private $subcategory;
private $resolution;
public $maintainer = "nel50n"; public $maintainer = "nel50n";
public $name = "WallpaperStop Bridge"; public $name = "WallpaperStop Bridge";
public $uri = "http://www.wallpaperstop.com/"; public $uri = "http://www.wallpaperstop.com";
public $description = "Returns the latests wallpapers from WallpaperStop"; public $description = "Returns the latests wallpapers from WallpaperStop";
public $parameters = array( array( public $parameters = array( array(
@ -15,64 +11,59 @@ class WallpaperStopBridge extends BridgeAbstract {
's'=>array('name'=>'subcategory'), 's'=>array('name'=>'subcategory'),
'm'=>array( 'm'=>array(
'name'=>'Max number of wallpapers', 'name'=>'Max number of wallpapers',
'type'=>'number' 'type'=>'number',
'defaultValue'=>20
), ),
'r'=>array( 'r'=>array(
'name'=>'resolution', 'name'=>'resolution',
'exampleValue'=>'1920x1200, 1680x1050,…', 'exampleValue'=>'1920x1200, 1680x1050,…',
'defaultValue'=>'1920x1200'
) )
)); ));
public function collectData(){ public function collectData(){
$html = ''; $category = $this->getInput('c');
if (!$this->getInput('c')) { $subcategory = $this->getInput('s');
$this->returnClientError('You must specify at least a category (?c=...).'); $resolution = $this->getInput('r');
} else {
$baseUri = 'http://www.wallpaperstop.com';
$this->category = $this->getInput('c'); $num = 0;
$this->subcategory = $this->getInput('s') ?: ''; $max = $this->getInput('m');
$this->resolution = $this->getInput('r') ?: '1920x1200'; // Wide wallpaper default $lastpage = 1;
$num = 0; for ($page = 1; $page <= $lastpage; $page++) {
$max = $this->getInput('m') ?: 20; $link = $this->uri.'/'.$category.'-wallpaper/'.(!empty($subcategory)?$subcategory.'-wallpaper/':'').'desktop-wallpaper-'.$page.'.html';
$lastpage = 1; $html = $this->getSimpleHTMLDOM($link)
or $this->returnServerError('No results for this query.');
for ($page = 1; $page <= $lastpage; $page++) { if ($page === 1) {
$link = $baseUri.'/'.$this->category.'-wallpaper/'.(!empty($this->subcategory)?$this->subcategory.'-wallpaper/':'').'desktop-wallpaper-'.$page.'.html'; preg_match('/-(\d+)\.html$/', $html->find('.pagination > .last', 0)->href, $matches);
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.'); $lastpage = min($matches[1], ceil($max/20));
}
if ($page === 1) { foreach($html->find('article.item') as $element) {
preg_match('/-(\d+)\.html$/', $html->find('.pagination > .last', 0)->href, $matches); $wplink = $element->getAttribute('data-permalink');
$lastpage = min($matches[1], ceil($max/20)); if (preg_match('%^'.$this->uri.'/(.+)/([^/]+)-(\d+)\.html$%', $wplink, $matches)) {
} $thumbnail = $element->find('img', 0);
foreach($html->find('article.item') as $element) { $item = array();
$wplink = $element->getAttribute('data-permalink'); $item['uri'] = $this->uri.'/wallpapers/'.str_replace('wallpaper', 'wallpapers', $matches[1]).'/'.$matches[2].'-'.$resolution.'-'.$matches[3].'.jpg';
if (preg_match('%^http://www\.wallpaperstop\.com/(.+)/([^/]+)-(\d+)\.html$%', $wplink, $matches)) { $item['id'] = $matches[3];
$thumbnail = $element->find('img', 0); $item['timestamp'] = time();
$item['title'] = $thumbnail->title;
$item['content'] = $item['title'].'<br><a href="'.$wplink.'"><img src="'.$this->uri.$thumbnail->src.'" /></a>';
$this->items[] = $item;
$item = array(); $num++;
$item['uri'] = $baseUri.'/wallpapers/'.str_replace('wallpaper', 'wallpapers', $matches[1]).'/'.$matches[2].'-'.$this->resolution.'-'.$matches[3].'.jpg'; if ($num >= $max)
$item['id'] = $matches[3]; break 2;
$item['timestamp'] = time(); }
$item['title'] = $thumbnail->title; }
$item['content'] = $item['title'].'<br><a href="'.$wplink.'"><img src="'.$baseUri.$thumbnail->src.'" /></a>'; }
$this->items[] = $item;
$num++;
if ($num >= $max)
break 2;
}
}
}
}
} }
public function getName(){ public function getName(){
return 'WallpaperStop - '.$this->category.(!empty($this->subcategory) ? ' > '.$this->subcategory : '').' ['.$this->resolution.']'; return 'WallpaperStop - '.$this->getInput('c').(!empty($this->getInput('s')) ? ' > '.$this->getInput('s') : '').' ['.$this->getInput('r').']';
} }
public function getCacheDuration(){ public function getCacheDuration(){

View file

@ -13,6 +13,8 @@ class WhydBridge extends BridgeAbstract{
) )
)); ));
private $userName='';
public function collectData(){ public function collectData(){
$html = ''; $html = '';
if (strlen(preg_replace("/[^0-9a-f]/",'', $this->getInput('u'))) == 24){ if (strlen(preg_replace("/[^0-9a-f]/",'', $this->getInput('u'))) == 24){
@ -34,7 +36,7 @@ class WhydBridge extends BridgeAbstract{
} }
} }
} }
$this->name = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext; $this->userName = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext;
for($i = 0; $i < 10; $i++) { for($i = 0; $i < 10; $i++) {
$track = $html->find('div.post', $i); $track = $html->find('div.post', $i);
@ -42,13 +44,13 @@ class WhydBridge extends BridgeAbstract{
$item['author'] = $track->find('h2', 0)->plaintext; $item['author'] = $track->find('h2', 0)->plaintext;
$item['title'] = $track->find('h2', 0)->plaintext; $item['title'] = $track->find('h2', 0)->plaintext;
$item['content'] = $track->find('a.thumb',0) . '<br/>' . $track->find('h2', 0)->plaintext; $item['content'] = $track->find('a.thumb',0) . '<br/>' . $track->find('h2', 0)->plaintext;
$item['id'] = 'http://www.whyd.com' . $track->find('a.no-ajaxy',0)->getAttribute('href'); $item['id'] = $this->uri . $track->find('a.no-ajaxy',0)->getAttribute('href');
$item['uri'] = 'http://www.whyd.com' . $track->find('a.no-ajaxy',0)->getAttribute('href'); $item['uri'] = $this->uri . $track->find('a.no-ajaxy',0)->getAttribute('href');
$this->items[] = $item; $this->items[] = $item;
} }
} }
public function getName(){ public function getName(){
return (!empty($this->name) ? $this->name .' - ' : '') .'Whyd Bridge'; return (!empty($this->userName) ? $this->userName .' - ' : '') .'Whyd Bridge';
} }
public function getCacheDuration(){ public function getCacheDuration(){

View file

@ -26,12 +26,10 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{
) )
)); ));
function getURI(){ private $title='';
$lang='fr';
if (!empty($this->getInput('lang'))) {
$lang = $this->getInput('lang');
}
function getURI(){
$lang = $this->getInput('lang');
$uri = $this->uri.$lang.'/news/'; $uri = $this->uri.$lang.'/news/';
if(!empty($this->getInput('category'))) { if(!empty($this->getInput('category'))) {
$uri .= 'pc-browser/'.$this->getInput('category')."/"; $uri .= 'pc-browser/'.$this->getInput('category')."/";
@ -39,11 +37,16 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{
return $uri; return $uri;
} }
public function getName(){
return $this->title?:$this->name;
}
public function collectData(){ public function collectData(){
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request '.$this->getURI()); $html = $this->getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Could not request '.$this->getURI());
$this->debugMessage("loaded HTML from ".$this->getURI()); $this->debugMessage("loaded HTML from ".$this->getURI());
// customize name // customize name
$this->name = $html->find('title', 0)->innertext; $this->title = $html->find('title', 0)->innertext;
foreach($html->find('.b-imgblock_ico') as $infoLink) { foreach($html->find('.b-imgblock_ico') as $infoLink) {
$this->parseLine($infoLink); $this->parseLine($infoLink);
} }

View file

@ -15,21 +15,16 @@ class XbooruBridge extends BridgeAbstract{
)); ));
public function collectData(){ public function collectData(){
$page = 0;$tags=''; $html = $this->getSimpleHTMLDOM(
if ($this->getInput('p')) { $this->uri.'index.php?page=post&s=list&'
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
$page = $page - 1; .'&tags='.urlencode($this->getInput('t'))
$page = $page * 50; ) or $this->returnServerError('Could not request Xbooru.');
}
if ($this->getInput('t')) {
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("http://xbooru.com/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Xbooru.');
foreach($html->find('div[class=content] span') as $element) { foreach($html->find('div[class=content] span') as $element) {
$item = array(); $item = array();
$item['uri'] = 'http://xbooru.com/'.$element->find('a', 0)->href; $item['uri'] = $this->uri.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time(); $item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src; $thumbnailUri = $element->find('img', 0)->src;

View file

@ -9,20 +9,19 @@ class YandereBridge extends BridgeAbstract{
public $parameters = array( array( public $parameters = array( array(
'p'=>array( 'p'=>array(
'name'=>'page', 'name'=>'page',
'type'=>'number' 'type'=>'number',
'defaultValue'=>1
), ),
't'=>array('name'=>'tags') 't'=>array('name'=>'tags')
)); ));
public function collectData(){ public function collectData(){
$page = 1; $tags = ''; $html = $this->getSimpleHTMLDOM(
if ($this->getInput('p')) { $this->uri.'post?'
$page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); .'&page='.$this->getInput('p')
} .'&tags='.urlencode($this->getInput('t'))
if ($this->getInput('t')) { ) or $this->returnServerError('Could not request Yander.');
$tags = urlencode($this->getInput('t'));
}
$html = $this->getSimpleHTMLDOM("https://yande.re/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Yandere.');
$input_json = explode('Post.register(', $html); $input_json = explode('Post.register(', $html);
foreach($input_json as $element) foreach($input_json as $element)
$data[] = preg_replace('/}\)(.*)/', '}', $element); $data[] = preg_replace('/}\)(.*)/', '}', $element);
@ -31,7 +30,7 @@ class YandereBridge extends BridgeAbstract{
foreach($data as $datai) { foreach($data as $datai) {
$json = json_decode($datai, TRUE); $json = json_decode($datai, TRUE);
$item = array(); $item = array();
$item['uri'] = 'http://yande.re/post/show/'.$json['id']; $item['uri'] = $this->uri.'post/show/'.$json['id'];
$item['postid'] = $json['id']; $item['postid'] = $json['id'];
$item['timestamp'] = $json['created_at']; $item['timestamp'] = $json['created_at'];
$item['imageUri'] = $json['file_url']; $item['imageUri'] = $json['file_url'];

View file

@ -207,16 +207,12 @@ class ZDNetBridge extends BridgeAbstract {
return $string; return $string;
} }
$baseUri = $this->getURI(); $baseUri = $this->uri;
$feed = $this->getInput('feed'); $feed = $this->getInput('feed');
if (empty($feed))
$this->returnClientError('Please select a feed to display.');
if (strpos($feed, 'downloads!') !== false) { if (strpos($feed, 'downloads!') !== false) {
$feed = str_replace('downloads!', '', $feed); $feed = str_replace('downloads!', '', $feed);
$baseUri = str_replace('www.', 'downloads.', $baseUri); $baseUri = str_replace('www.', 'downloads.', $baseUri);
} }
if ($feed !== preg_replace('/[^a-zA-Z0-9-\/]+/', '', $feed) || substr_count($feed, '/') > 1 || strlen($feed > 64))
$this->returnClientError('Invalid "feed" parameter.');
$url = $baseUri.trim($feed, '/').'/rss.xml'; $url = $baseUri.trim($feed, '/').'/rss.xml';
$html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request ZDNet: '.$url); $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request ZDNet: '.$url);
$limit = 0; $limit = 0;