2014-07-18 15:19:02 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WhydBridge
|
|
|
|
* Returns the newest music from user
|
|
|
|
*
|
|
|
|
* @name Whyd Bridge
|
|
|
|
* @homepage http://www.whyd.com/
|
|
|
|
* @description Returns 10 newest music from user profile
|
|
|
|
* @maintainer kranack
|
|
|
|
* @update 2014-07-18
|
2014-07-18 16:06:39 +04:00
|
|
|
* @use1(u="username/id")
|
2014-07-18 15:19:02 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
class WhydBridge extends BridgeAbstract{
|
|
|
|
|
|
|
|
private $request;
|
|
|
|
private $name;
|
|
|
|
|
|
|
|
public function collectData(array $param){
|
|
|
|
$html = '';
|
|
|
|
if (isset($param['u']))
|
|
|
|
{
|
|
|
|
$this->request = $param['u'];
|
2014-07-18 16:06:39 +04:00
|
|
|
if (strlen(preg_replace("/[^0-9a-f]/",'', $this->request)) == 24) // is input the userid ?
|
|
|
|
$html = file_get_html('http://www.whyd.com/u/'.preg_replace("/[^0-9a-f]/",'', $this->request)) or $this->returnError('No results for this query.', 404);
|
|
|
|
else // input may be the username
|
|
|
|
$html = file_get_html('http://www.whyd.com/'.urlencode($this->request)) or $this->returnError('No results for this query.', 404);
|
|
|
|
|
2014-07-18 15:19:02 +04:00
|
|
|
$this->name = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-18 16:06:39 +04:00
|
|
|
$this->returnError('You must specify username or id', 400);
|
2014-07-18 15:19:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for($i = 0; $i < 10; $i++) {
|
|
|
|
$track = $html->find('div.post', $i);
|
|
|
|
$item = new \Item();
|
|
|
|
$item->name = $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->id = 'http://www.whyd.com' . $track->find('a.no-ajaxy',0)->getAttribute('href');
|
|
|
|
$item->uri = 'http://www.whyd.com' . $track->find('a.no-ajaxy',0)->getAttribute('href');
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function getName(){
|
2014-07-18 15:31:40 +04:00
|
|
|
return (!empty($this->name) ? $this->name .' - ' : '') .'Whyd Bridge';
|
2014-07-18 15:19:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI(){
|
2014-07-18 15:33:54 +04:00
|
|
|
return 'http://www.whyd.com/';
|
2014-07-18 15:19:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 1; // 10 minutes
|
|
|
|
}
|
|
|
|
}
|