VineBridge.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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->update = "2016-03-12";
  9. $this->parameters[] =
  10. '[
  11. {
  12. "name" : "User id",
  13. "identifier" : "u",
  14. "type" : "text",
  15. "required" : "true"
  16. }
  17. ]';
  18. }
  19. public function collectData(array $param){
  20. $html = '';
  21. $uri = 'http://vine.co/u/'.$param['u'].'?mode=list';
  22. $html = $this->file_get_html($uri) or $this->returnError('No results for this query.', 404);
  23. foreach($html->find('.post') as $element) {
  24. $a = $element->find('a', 0);
  25. $a->href = str_replace('https://', 'http://', $a->href);
  26. $time = strtotime(ltrim($element->find('p', 0)->plaintext, " Uploaded at "));
  27. $video = $element->find('video', 0);
  28. $video->controls = "true";
  29. $element->find('h2', 0)->outertext = '';
  30. $item = new \Item();
  31. $item->uri = $a->href;
  32. $item->timestamp = $time;
  33. $item->title = $a->plaintext;
  34. $item->content = $element;
  35. $this->items[] = $item;
  36. }
  37. }
  38. public function getName(){
  39. return 'Vine';
  40. }
  41. public function getURI(){
  42. return 'http://vine.co';
  43. }
  44. public function getCacheDuration(){
  45. return 10; //seconds
  46. }
  47. }