forked from blallo/rss-bridge
Merge pull request #10 from ArthurHoaro/master
Ajouter la requête dans le titre des bridges
This commit is contained in:
commit
f91ec300b0
5 changed files with 31 additions and 11 deletions
|
@ -15,11 +15,14 @@
|
||||||
*/
|
*/
|
||||||
class GoogleSearchBridge extends BridgeAbstract{
|
class GoogleSearchBridge extends BridgeAbstract{
|
||||||
|
|
||||||
|
private $request;
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
if (isset($param['q'])) { /* keyword search mode */
|
if (isset($param['q'])) { /* keyword search mode */
|
||||||
$html = file_get_html('http://www.google.com/search?q=' . urlencode($param['q']) . '&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnError('No results for this query.', 404);
|
$this->request = $param['q'];
|
||||||
|
$html = file_get_html('http://www.google.com/search?q=' . urlencode($this->request) . '&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnError('No results for this query.', 404);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$this->returnError('You must specify a keyword (?q=...).', 400);
|
$this->returnError('You must specify a keyword (?q=...).', 400);
|
||||||
|
@ -43,7 +46,7 @@ class GoogleSearchBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return 'Google search';
|
return (!empty($this->request) ? $this->request .' - ' : '') .'Google search';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
|
|
@ -7,11 +7,14 @@
|
||||||
* @use1(u="username")
|
* @use1(u="username")
|
||||||
*/
|
*/
|
||||||
class IdenticaBridge extends BridgeAbstract{
|
class IdenticaBridge extends BridgeAbstract{
|
||||||
|
|
||||||
|
private $request;
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
$html = '';
|
$html = '';
|
||||||
if (isset($param['u'])) { /* user timeline mode */
|
if (isset($param['u'])) { /* user timeline mode */
|
||||||
$html = file_get_html('https://identi.ca/'.urlencode($param['u'])) or $this->returnError('Requested username can\'t be found.', 404);
|
$this->request = $param['u'];
|
||||||
|
$html = file_get_html('https://identi.ca/'.urlencode($this->request)) or $this->returnError('Requested username can\'t be found.', 404);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->returnError('You must specify an Identica username (?u=...).', 400);
|
$this->returnError('You must specify an Identica username (?u=...).', 400);
|
||||||
|
@ -28,7 +31,7 @@ class IdenticaBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return 'Identica Bridge';
|
return (!empty($this->request) ? $this->request .' - ' : '') .'Identica Bridge';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
|
|
@ -9,14 +9,18 @@
|
||||||
* @use2(u="username")
|
* @use2(u="username")
|
||||||
*/
|
*/
|
||||||
class TwitterBridge extends BridgeAbstract{
|
class TwitterBridge extends BridgeAbstract{
|
||||||
|
|
||||||
|
private $request;
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
$html = '';
|
$html = '';
|
||||||
if (isset($param['q'])) { /* keyword search mode */
|
if (isset($param['q'])) { /* keyword search mode */
|
||||||
$html = file_get_html('http://twitter.com/search/realtime?q='.urlencode($param['q']).'+include:retweets&src=typd') or $this->returnError('No results for this query.', 404);
|
$this->request = $param['q'];
|
||||||
|
$html = file_get_html('http://twitter.com/search/realtime?q='.urlencode($this->request).'+include:retweets&src=typd') or $this->returnError('No results for this query.', 404);
|
||||||
}
|
}
|
||||||
elseif (isset($param['u'])) { /* user timeline mode */
|
elseif (isset($param['u'])) { /* user timeline mode */
|
||||||
$html = file_get_html('http://twitter.com/'.urlencode($param['u'])) or $this->returnError('Requested username can\'t be found.', 404);
|
$this->request = $param['u'];
|
||||||
|
$html = file_get_html('http://twitter.com/'.urlencode($this->request)) or $this->returnError('Requested username can\'t be found.', 404);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->returnError('You must specify a keyword (?q=...) or a Twitter username (?u=...).', 400);
|
$this->returnError('You must specify a keyword (?q=...) or a Twitter username (?u=...).', 400);
|
||||||
|
@ -37,7 +41,7 @@ class TwitterBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return 'Twitter Bridge';
|
return (!empty($this->request) ? $this->request .' - ' : '') .'Twitter Bridge';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
|
|
@ -8,9 +8,19 @@
|
||||||
* @use1(u="username")
|
* @use1(u="username")
|
||||||
*/
|
*/
|
||||||
class YoutubeBridge extends BridgeAbstract{
|
class YoutubeBridge extends BridgeAbstract{
|
||||||
|
|
||||||
|
private $request;
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
$html = file_get_html('https://www.youtube.com/user/'.urlencode($param['u']).'/videos') or $this->returnError('Could not request Youtube.', 404);
|
$html = '';
|
||||||
|
if (isset($param['u'])) { /* user timeline mode */
|
||||||
|
$this->request = $param['u'];
|
||||||
|
$html = file_get_html('https://www.youtube.com/user/'.urlencode($this->request).'/videos') or $this->returnError('Could not request Youtube.', 404);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->returnError('You must specify a Youtbe username (?u=...).', 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach($html->find('li.channels-content-item') as $element) {
|
foreach($html->find('li.channels-content-item') as $element) {
|
||||||
$item = new \Item();
|
$item = new \Item();
|
||||||
|
@ -23,7 +33,7 @@ class YoutubeBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return 'Youtube Bridge';
|
return (!empty($this->request) ? $this->request .' - ' : '') .'Youtube Bridge';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
|
|
@ -13,7 +13,7 @@ TODO :
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
ini_set('display_errors','1'); error_reporting(E_ALL); // For debugging only.
|
//ini_set('display_errors','1'); error_reporting(E_ALL); // For debugging only.
|
||||||
|
|
||||||
try{
|
try{
|
||||||
require_once __DIR__ . '/lib/RssBridge.php';
|
require_once __DIR__ . '/lib/RssBridge.php';
|
||||||
|
|
Loading…
Reference in a new issue