2016-03-12 16:50:45 +01: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-17 14:45:08 +02:00
|
|
|
$this->update = '2016-08-17';
|
2016-03-12 16:50:45 +01:00
|
|
|
|
|
|
|
$this->parameters[] =
|
|
|
|
'[
|
|
|
|
{
|
|
|
|
"name" : "User id",
|
|
|
|
"identifier" : "u",
|
|
|
|
"type" : "text",
|
2016-08-15 01:19:16 +02:00
|
|
|
"required" : true
|
2016-03-12 16:50:45 +01:00
|
|
|
}
|
|
|
|
]';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData(array $param){
|
|
|
|
$html = '';
|
|
|
|
$uri = 'http://vine.co/u/'.$param['u'].'?mode=list';
|
|
|
|
|
2016-08-17 14:45:08 +02:00
|
|
|
$html = $this->file_get_html($uri) or $this->returnServerError('No results for this query.');
|
2016-03-12 16:50:45 +01: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 = '';
|
|
|
|
|
|
|
|
$item = new \Item();
|
|
|
|
$item->uri = $a->href;
|
|
|
|
$item->timestamp = $time;
|
|
|
|
$item->title = $a->plaintext;
|
|
|
|
$item->content = $element;
|
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 10; //seconds
|
|
|
|
}
|
|
|
|
}
|