[DailymotionBridge] fix + code simplification
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
f1a3ed297e
commit
2238e8998a
1 changed files with 13 additions and 6 deletions
|
@ -35,8 +35,11 @@ class DailymotionBridge extends BridgeAbstract{
|
|||
|
||||
function getMetadata($id) {
|
||||
$metadata=array();
|
||||
$html2 = $this->getSimpleHTMLDOM('http://www.dailymotion.com/video/'.$id)
|
||||
or $this->returnServerError('Could not request Dailymotion.');
|
||||
$html2 = $this->getSimpleHTMLDOM($this->uri.'video/'.$id);
|
||||
if(!$html2){
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$metadata['title'] = $html2->find('meta[property=og:title]', 0)->getAttribute('content');
|
||||
$metadata['timestamp'] = strtotime($html2->find('meta[property=video:release_date]', 0)->getAttribute('content') );
|
||||
$metadata['thumbnailUri'] = $html2->find('meta[property=og:image]', 0)->getAttribute('content');
|
||||
|
@ -57,6 +60,9 @@ class DailymotionBridge extends BridgeAbstract{
|
|||
$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'];
|
||||
|
@ -84,19 +90,20 @@ class DailymotionBridge extends BridgeAbstract{
|
|||
}
|
||||
|
||||
public function getURI(){
|
||||
$uri=$this->uri;
|
||||
switch($this->queriedContext){
|
||||
case 'By username':
|
||||
$uri='http://www.dailymotion.com/user/'
|
||||
$uri.='user/'
|
||||
.urlencode($this->getInput('u')).'/1';
|
||||
break;
|
||||
case 'By playlist id':
|
||||
$uri='http://www.dailymotion.com/playlist/'
|
||||
$uri.='playlist/'
|
||||
.urlencode(strtok($this->getInput('p'), '_'));
|
||||
break;
|
||||
case 'From search results':
|
||||
$uri='http://www.dailymotion.com/search/'
|
||||
$uri.='search/'
|
||||
.urlencode($this->getInput('s'));
|
||||
if(isset($this->getInput('pa'))){
|
||||
if($this->getInput('pa')){
|
||||
$uri.='/'.$this->getInput('pa');
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue