2016-03-12 16:50:45 +01:00
|
|
|
<?php
|
|
|
|
class VineBridge extends BridgeAbstract {
|
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "ckiw";
|
|
|
|
const NAME = "Vine bridge";
|
|
|
|
const URI = "http://vine.co/";
|
|
|
|
const DESCRIPTION = "Returns the latests vines from vine user page";
|
2016-03-12 16:50:45 +01:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'u'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'User id',
|
|
|
|
'required'=>true
|
2016-08-27 21:03:26 +02:00
|
|
|
)
|
|
|
|
));
|
2016-03-12 16:50:45 +01:00
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
2016-03-12 16:50:45 +01:00
|
|
|
$html = '';
|
2016-08-30 11:23:55 +02:00
|
|
|
$uri = self::URI.'/u/'.$this->getInput('u').'?mode=list';
|
2016-03-12 16:50:45 +01:00
|
|
|
|
2016-09-25 23:22:33 +02:00
|
|
|
$html = getSimpleHTMLDOM($uri)
|
|
|
|
or 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 = '';
|
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
|
|
|
$item['uri'] = $a->href;
|
|
|
|
$item['timestamp'] = $time;
|
|
|
|
$item['title'] = $a->plaintext;
|
|
|
|
$item['content'] = $element;
|
2016-03-12 16:50:45 +01:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 10; //seconds
|
|
|
|
}
|
|
|
|
}
|