vimeoclass.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. ini_set("display_errors","1");
  3. error_reporting(E_ALL);
  4. function curl_load($url) {
  5. if(in_array('curl', get_loaded_extensions())){
  6. $appSettings = parse_ini_file('../config/config.ini',true);
  7. $ch = curl_init($url);
  8. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0');
  9. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  10. curl_setopt($ch, CURLOPT_HEADER, 0);
  11. if($appSettings["Proxy"]["type"]) {
  12. curl_setopt($ch, CURLOPT_PROXY, $appSettings["Proxy"]["type"]."://".$appSettings["Proxy"]["domain"].":".$appSettings["Proxy"]["port"]);
  13. curl_setopt($ch, CURLOPT_PROXYUSERPWD, $appSettings["Proxy"]["username"].":".$appSettings["Proxy"]["password"]);
  14. }
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  16. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  17. $result = curl_exec($ch);
  18. curl_close($ch);
  19. return $result;
  20. }
  21. }
  22. function vimeo($id) {
  23. $data = curl_load("https://www.vimeo.com/".$id);
  24. if(!strstr($data,"window.vimeo.exception_data")) {
  25. $data = stristr($data, 'config_url":"');
  26. $start = substr($data, strlen('config_url":"'));
  27. $stop = stripos($start, ',');
  28. $str = substr($start, 0, $stop);
  29. $data = json_decode(curl_load(rtrim(str_replace("\\", "", $str), '"')));
  30. $captions = array();
  31. if(isset($data->request->text_tracks)) {
  32. for($i=0;$i<count($data->request->text_tracks);$i++) {
  33. $caption = array();
  34. $caption["title"] = $data->request->text_tracks[$i]->label;
  35. $caption["lang"] = $data->request->text_tracks[$i]->lang;
  36. $caption["url"] = $data->request->text_tracks[$i]->url;
  37. array_push($captions,$caption);
  38. }
  39. }
  40. $info = array();
  41. $info["info"] = array();
  42. $info["info"]["Title"] = $data->video->title;
  43. $info["info"]["Thumbnail"] = $data->video->thumbs->base;
  44. $info["info"]["Captions"] = $captions;
  45. $info["info"]["Thumbs"] = array();
  46. $info["info"]["Thumbs"]["src"] = "image.php?url=".urlencode($data->request->thumb_preview->url);
  47. $info["info"]["Thumbs"]["width"] = $data->request->thumb_preview->width;
  48. $info["info"]["Thumbs"]["height"] = $data->request->thumb_preview->height;
  49. $info["info"]["Thumbs"]["fwidth"] = $data->request->thumb_preview->frame_width;
  50. $info["info"]["Thumbs"]["fheight"] = $data->request->thumb_preview->frame_height;
  51. $info["info"]["Thumbs"]["fcount"] = $data->request->thumb_preview->frames;
  52. $info["info"]["Thumbs"]["row"] = $data->request->thumb_preview->columns;
  53. $info["dl"] = array();
  54. for($i=0;$i<count($data->request->files->progressive);$i++) {
  55. $xinfo = array();
  56. $xinfo["url"] = $data->request->files->progressive[$i]->url;
  57. $xinfo["type"] = $data->request->files->progressive[$i]->quality;
  58. array_push($info["dl"],$xinfo);
  59. }
  60. return $info;
  61. }
  62. else {
  63. return false;
  64. }
  65. }
  66. ?>