2016-03-12 18:50:45 +03:00
|
|
|
<?php
|
|
|
|
class VineBridge extends BridgeAbstract {
|
|
|
|
|
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "ckiw";
|
|
|
|
$this->name = "Vine bridge";
|
|
|
|
$this->uri = "http://vine.co/";
|
|
|
|
$this->description = "Returns the latests vines from vine user page";
|
|
|
|
|
2016-08-22 02:25:56 +03:00
|
|
|
$this->parameters[] = array(
|
|
|
|
'u'=>array(
|
|
|
|
'name'=>'User id',
|
|
|
|
'required'=>true
|
|
|
|
)
|
|
|
|
);
|
2016-03-12 18:50:45 +03:00
|
|
|
}
|
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
|
|
|
$param=$this->parameters[$this->queriedContext];
|
2016-03-12 18:50:45 +03:00
|
|
|
$html = '';
|
2016-08-25 02:24:53 +03:00
|
|
|
$uri = 'http://vine.co/u/'.$param['u']['value'].'?mode=list';
|
2016-03-12 18:50:45 +03:00
|
|
|
|
2016-07-08 20:06:35 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for this query.');
|
2016-03-12 18:50:45 +03:00
|
|
|
|
|
|
|
foreach($html->find('.post') as $element) {
|
|
|
|
$a = $element->find('a', 0);
|
|
|
|
$a->href = str_replace('https://', 'http://', $a->href);
|
|
|
|
$time = strtotime(ltrim($element->find('p', 0)->plaintext, " Uploaded at "));
|
|
|
|
$video = $element->find('video', 0);
|
|
|
|
$video->controls = "true";
|
|
|
|
$element->find('h2', 0)->outertext = '';
|
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
|
|
|
$item['uri'] = $a->href;
|
|
|
|
$item['timestamp'] = $time;
|
|
|
|
$item['title'] = $a->plaintext;
|
|
|
|
$item['content'] = $element;
|
2016-03-12 18:50:45 +03:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 10; //seconds
|
|
|
|
}
|
|
|
|
}
|