Vimeo.php 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class Videolist_Platform_Vimeo implements Videolist_PlatformInterface
  3. {
  4. public function getType()
  5. {
  6. return "vimeo";
  7. }
  8. public function parseUrl($url)
  9. {
  10. $parsed = parse_url($url);
  11. $path = explode('/', $parsed['path']);
  12. if ($parsed['host'] != 'vimeo.com' || !(int) $path[1]) {
  13. return false;
  14. }
  15. return array(
  16. 'video_id' => $path[1],
  17. );
  18. }
  19. public function getData($parsed)
  20. {
  21. $video_id = $parsed['video_id'];
  22. $buffer = file_get_contents("https://vimeo.com/api/v2/video/$video_id.xml");
  23. $xml = new SimpleXMLElement($buffer);
  24. $videos = $xml->children();
  25. $video = $videos[0];
  26. return array(
  27. 'title' => $video->title,
  28. // 'description' => strip_tags($video->description),
  29. 'thumbnail' => $video->thumbnail_medium,
  30. );
  31. }
  32. }