From c13dd8c18a97d6e174f093a3217df333742a7112 Mon Sep 17 00:00:00 2001 From: alexis Date: Sat, 12 Mar 2016 16:50:45 +0100 Subject: [PATCH] Add Vine.co bridge :) --- bridges/VineBridge.php | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 bridges/VineBridge.php diff --git a/bridges/VineBridge.php b/bridges/VineBridge.php new file mode 100644 index 00000000..d9482e34 --- /dev/null +++ b/bridges/VineBridge.php @@ -0,0 +1,59 @@ +maintainer = "ckiw"; + $this->name = "Vine bridge"; + $this->uri = "http://vine.co/"; + $this->description = "Returns the latests vines from vine user page"; + $this->update = "2016-03-12"; + + $this->parameters[] = + '[ + { + "name" : "User id", + "identifier" : "u", + "type" : "text", + "required" : "true" + } + ]'; + } + + public function collectData(array $param){ + $html = ''; + $uri = 'http://vine.co/u/'.$param['u'].'?mode=list'; + + $html = file_get_html($uri) or $this->returnError('No results for this query.', 404); + + 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 getName(){ + return 'Vine'; + } + + public function getURI(){ + return 'http://vine.co'; + } + + public function getCacheDuration(){ + return 10; //seconds + } +}