vimeoclass.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. function curl_load($url) {
  3. if(in_array('curl', get_loaded_extensions())){
  4. $appSettings = parse_ini_file('../config/config.ini',true);
  5. $ch = curl_init($url);
  6. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0');
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8. curl_setopt($ch, CURLOPT_HEADER, 0);
  9. if($appSettings["Proxy"]["type"]) {
  10. curl_setopt($ch, CURLOPT_PROXY, $appSettings["Proxy"]["type"]."://".$appSettings["Proxy"]["domain"].":".$appSettings["Proxy"]["port"]);
  11. curl_setopt($ch, CURLOPT_PROXYUSERPWD, $appSettings["Proxy"]["username"].":".$appSettings["Proxy"]["password"]);
  12. }
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  14. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  15. $result = curl_exec($ch);
  16. curl_close($ch);
  17. return $result;
  18. }
  19. }
  20. function vimeo($id) {
  21. $data = curl_load("https://www.vimeo.com/".$id);
  22. if(!strstr($data,"window.vimeo.exception_data")) {
  23. $data = stristr($data, 'config_url":"');
  24. $start = substr($data, strlen('config_url":"'));
  25. $stop = stripos($start, ',');
  26. $str = substr($start, 0, $stop);
  27. $data = json_decode(curl_load(rtrim(str_replace("\\", "", $str), '"')));
  28. $info = array();
  29. $info["info"] = array();
  30. $info["info"]["Title"] = $data->video->title;
  31. $info["info"]["Thumbnail"] = $data->video->thumbs->base;
  32. $info["dl"] = array();
  33. for($i=0;$i<count($data->request->files->progressive);$i++) {
  34. $xinfo = array();
  35. $xinfo["url"] = $data->request->files->progressive[$i]->url;
  36. $xinfo["type"] = $data->request->files->progressive[$i]->quality;
  37. array_push($info["dl"],$xinfo);
  38. }
  39. return $info;
  40. }
  41. else {
  42. return false;
  43. }
  44. }
  45. ?>