[ pull request #86 ]

This commit is contained in:
Mitsukarenai 2014-07-23 13:11:55 +02:00
parent 4f61ac06af
commit bf2303ead8
4 changed files with 89 additions and 25 deletions

44
bridges/ABCTabsBridge.php Normal file
View file

@ -0,0 +1,44 @@
<?php
/**
* ABCTabsBridge
* Returns the newest tabs
*
* @name ABC Tabs Bridge
* @homepage http://www.abc-tabs.com/
* @description Returns 22 newest tabs
* @maintainer kranack
* @update 2014-07-23
*
*/
class ABCTabsBridge extends BridgeAbstract{
private $request;
public function collectData(array $param){
$html = '';
$html = file_get_html('http://www.abc-tabs.com/tablatures/nouveautes.html') or $this->returnError('No results for this query.', 404);
$table = $html->find('table#myTable', 0)->children(1);
foreach ($table->find('tr') as $tab)
{
$item = new \Item();
$item->name = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext;
$item->title = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext;
$item->content = 'Le ' . $tab->find('td', 0)->plaintext . '<br> Par: ' . $tab->find('td', 5)->plaintext . '<br> Type: ' . $tab->find('td', 3)->plaintext;
$item->id = 'http://www.abc-tabs.com' . $tab->find('td', 2)->find('a', 0)->getAttribute('href');
$item->uri = 'http://www.abc-tabs.com' . $tab->find('td', 2)->find('a', 0)->getAttribute('href');
$this->items[] = $item;
}
}
public function getName(){
return 'ABC Tabs Bridge';
}
public function getURI(){
return 'http://www.abc-tabs.com/';
}
public function getCacheDuration(){
return 3600; // 1 hour
}
}

View file

@ -10,29 +10,42 @@
* @description Returns most recent results from MondeDiplo. * @description Returns most recent results from MondeDiplo.
* @maintainer Pitchoule * @maintainer Pitchoule
*/ */
class MondeDiploBridge extends BridgeAbstract{ class MondeDiploBridge extends BridgeAbstract{
public function collectData(array $param){ public function collectData(array $param){
$link = 'http://www.monde-diplomatique.fr'; $link = 'http://www.monde-diplomatique.fr';
$html = file_get_html($link) or $this->returnError('Could not request MondeDiplo. for : ' . $link , 404); $html = file_get_html($link) or $this->returnError('Could not request MondeDiplo. for : ' . $link , 404);
foreach($html->find('div[class=grid_10 alpha omega laune]') as $element) { foreach($html->find('div.laune') as $element) {
$item = new Item(); $item = new Item();
$item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href; $item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href;
$NumArticle = explode("/", $element->find('a', 0)->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[class=crayon article-intro-'.$NumArticle[4].' intro]', 0)->plaintext; $this->items[] = $item;
$this->items[] = $item; }
}
$liste = $html->find('div.listes', 0); // First list
foreach($html->find('div.titraille') as $element) { foreach ($liste->find('li') as $e) {
$item = new Item();
$item = new Item();
$item->uri = 'http://www.monde-diplomatique.fr' . $e->find('a', 0)->href;
$item->title = $e->find('a', 0)->plaintext;
$item->content = $e->find('div.dates_auteurs', 0)->plaintext;
$this->items[] = $item;
}
foreach($html->find('div.liste ul li') as $element) {
if ($element->getAttribute('class') != 'intrapub') {
$item = new Item();
$item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href; $item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href;
$item->title = $element->find('h3', 0)->plaintext; $item->title = $element->find('h3', 0)->plaintext;
$item->content = $element->find('div.dates_auteurs', 0)->plaintext; $item->content = $element->find('div.dates_auteurs', 0)->plaintext . ' <br> ' . $element->find('div.intro', 0)->plaintext;
$this->items[] = $item; $this->items[] = $item;
} }
}
} }
public function getName(){ public function getName(){
@ -47,4 +60,5 @@ class MondeDiploBridge extends BridgeAbstract{
return 21600; // 6 hours return 21600; // 6 hours
} }
} }

View file

@ -15,17 +15,21 @@ class ScoopItBridge extends BridgeAbstract{
public function collectData(array $param){ public function collectData(array $param){
$html = ''; $html = '';
$this->request = $param['u']; if ($param['u'] != '') {
$link = 'http://scoop.it/search?q=' .urlencode($this->request); $this->request = $param['u'];
$link = 'http://scoop.it/search?q=' .urlencode($this->request);
$html = file_get_html($link) or $this->returnError('Could not request ScoopIt. for : ' . $link , 404);
$html = file_get_html($link) or $this->returnError('Could not request ScoopIt. for : ' . $link , 404);
foreach($html->find('div.post-view') as $element) {
foreach($html->find('div.post-view') as $element) {
$item = new Item(); $item = new Item();
$item->uri = $element->find('a', 0)->href; $item->uri = $element->find('a', 0)->href;
$item->title = $element->find('div.tCustomization_post_title',0)->plaintext; $item->title = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext);
$item->content = $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->returnError('You must specify a keyword', 404);
} }
} }
@ -41,3 +45,4 @@ class ScoopItBridge extends BridgeAbstract{
return 21600; // 6 hours return 21600; // 6 hours
} }
} }

View file

@ -8,7 +8,7 @@
* @description Returns 10 newest music from user profile * @description Returns 10 newest music from user profile
* @maintainer kranack * @maintainer kranack
* @update 2014-07-18 * @update 2014-07-18
* @use1(u="username") * @use1(u="username/id")
* *
*/ */
class WhydBridge extends BridgeAbstract{ class WhydBridge extends BridgeAbstract{
@ -63,3 +63,4 @@ class WhydBridge extends BridgeAbstract{
} }
} }