VineBridge.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. class VineBridge extends BridgeAbstract {
  3. public function loadMetadatas() {
  4. $this->maintainer = "ckiw";
  5. $this->name = "Vine bridge";
  6. $this->uri = "http://vine.co/";
  7. $this->description = "Returns the latests vines from vine user page";
  8. $this->parameters[] = array(
  9. 'u'=>array(
  10. 'name'=>'User id',
  11. 'required'=>true
  12. )
  13. );
  14. }
  15. public function collectData(array $param){
  16. $html = '';
  17. $uri = 'http://vine.co/u/'.$param['u'].'?mode=list';
  18. $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for this query.');
  19. foreach($html->find('.post') as $element) {
  20. $a = $element->find('a', 0);
  21. $a->href = str_replace('https://', 'http://', $a->href);
  22. $time = strtotime(ltrim($element->find('p', 0)->plaintext, " Uploaded at "));
  23. $video = $element->find('video', 0);
  24. $video->controls = "true";
  25. $element->find('h2', 0)->outertext = '';
  26. $item = array();
  27. $item['uri'] = $a->href;
  28. $item['timestamp'] = $time;
  29. $item['title'] = $a->plaintext;
  30. $item['content'] = $element;
  31. $this->items[] = $item;
  32. }
  33. }
  34. public function getCacheDuration(){
  35. return 10; //seconds
  36. }
  37. }