Guest User

Untitled

a guest
Aug 15th, 2023
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.96 KB | None | 0 0
  1. function get_info($url)
  2. {
  3. $video_data = array();
  4.  
  5. $target_url = $url;
  6.  
  7. $error = 0;
  8.  
  9. if(function_exists('curl_init'))
  10. {
  11. $ch = curl_init();
  12. curl_setopt($ch, CURLOPT_URL, $target_url);
  13. curl_setopt($ch, CURLOPT_HEADER, 0);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  17. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
  18. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
  19. $video_data = curl_exec($ch);
  20. $errormsg = curl_error($ch);
  21. curl_close($ch);
  22.  
  23. if($errormsg != '')
  24. {
  25. echo $errormsg;
  26. return false;
  27. }
  28. }
  29. else if(ini_get('allow_url_fopen') == 1)
  30. {
  31. $stream_options = array('http' => array(
  32. 'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0',
  33. ));
  34. $ctx = stream_context_create($stream_options);
  35. $video_data = @file_get_contents($target_url, 0, $ctx);
  36. if($video_data === false)
  37. $error = 1;
  38. }
  39.  
  40. if(!is_array($video_data))
  41. {
  42. $video_data = explode("\n", $video_data);
  43. }
  44.  
  45. return $video_data;
  46. }
  47.  
  48. function get_flv($video_data)
  49. {
  50. return '';
  51. }
  52.  
  53. function get_thumb_link($video_id)
  54. {
  55.  
  56. $thumb_link = '';
  57.  
  58. $target_url = 'https://dropload.io/'. $video_id;
  59. $video_data = get_info($target_url);
  60. $arr_length = pm_count($video_data);
  61.  
  62. for($i = 0; $i < $arr_length; $i++)
  63. {
  64. if(preg_match('/src=\"(.*?)\" style=\"width:100%;height:100%;\"(.*?)/i', $video_data[$i], $matches) != 0)
  65. {
  66. $thumb_link = $matches[1];
  67.  
  68. break;
  69. }
  70. }
  71.  
  72. return $thumb_link;
  73. }
  74.  
  75. function video_details($video_data, $url, &$info)
  76. {
  77. $title = $thumb = $id = $tags = $duration = false;
  78.  
  79. $arr_length = pm_count($video_data);
  80.  
  81. for ($i = 0; $i < $arr_length; $i++)
  82. {
  83. if (strlen($video_data[$i]) < 10)
  84. {
  85. continue;
  86. }
  87.  
  88. if ( ! $title)
  89. {
  90. if (preg_match('/<h1>(.*?)<\/h1>/i', $video_data[$i], $matches) != 0)
  91. {
  92. $info['video_title'] = $matches[1];
  93. $title = true;
  94. $title = true;
  95. }
  96. }
  97.  
  98.  
  99. if ( ! $id)
  100. {
  101. $temp_url = '';
  102. if (preg_match('/((io\/))(\S+)/', $video_data[$i], $matches) != 0)
  103. {
  104. $pieces = explode('/', $matches[1]);
  105. $info['yt_id'] = $pieces[1];
  106. $yt_id = true;
  107. }
  108. }
  109.  
  110. if ( ! $thumb)
  111. {
  112. if(preg_match('/src=\"(.*?)\" style=\"width:100%;height:100%;\"(.*?)/i', $video_data[$i], $matches) != 0)
  113. {
  114. $info['yt_thumb'] = $matches[1];
  115. $info['yt_thumb'] = str_replace('_xt','_t', $info['yt_thumb']);
  116. $thumb = true;
  117. }
  118. }
  119.  
  120. if ( ! $tags)
  121. {
  122. if (strpos($video_data[$i], 'name="keywords"'))
  123. {
  124. if (preg_match('/content="(.*?)"/', $video_data[$i], $matches) != 0)
  125. {
  126. $info['tags'] = $matches[1];
  127. $tags = true;
  128. }
  129. }
  130. }
  131.  
  132. if ( ! $duration)
  133. {
  134. if (strpos($video_data[$i], '"video:duration"'))
  135. {
  136. if (preg_match('/content="(.*?)"/', $video_data[$i], $matches) != 0)
  137. {
  138. $info['duration'] = $matches[1];
  139. $duration = true;
  140. }
  141. }
  142. }
  143.  
  144. if ( ! $direct)
  145. {
  146. if (strpos($video_data[$i], '"og:url"'))
  147. {
  148. if (preg_match('/content="(.*?)"/', $video_data[$i], $matches) != 0)
  149. {
  150. $info['direct'] = $matches[1];
  151. $thumb = true;
  152. }
  153. }
  154. }
  155.  
  156. if ($title && $id && $tags && $duration)
  157. {
  158. break;
  159. }
  160.  
  161. }
  162.  
  163. if ($info['yt_id'] == '')
  164. {
  165. preg_match("/((io\/))(\S+)/", $url, $matches);
  166. $info['yt_id'] = $matches[3];
  167. // print_r($matches);
  168. }
  169.  
  170. if ($info['direct'] == '')
  171. {
  172. $info['direct'] = 'https://dropload.io/'. $info['yt_id'];
  173. }
  174.  
  175. $info['url_flv'] = $info['direct'];
  176.  
  177. return;
  178. }
  179.  
  180.  
  181. function fetch_headers($url)
  182. {
  183. $headers = array();
  184. $url = trim($url);
  185.  
  186. $error = 0;
  187. if(function_exists('get_headers'))
  188. {
  189. $url = str_replace(' ', '%20', $url);
  190. if( ! strstr($url, "http://"))
  191. {
  192. $url = "http://" . $url;
  193. }
  194. $headers = @get_headers($url, 0);
  195. if(!$headers)
  196. {
  197. $error = 1;
  198. }
  199. }
  200.  
  201. if($error == 1 || function_exists('get_headers') === FALSE)
  202. {
  203. $error = 0;
  204.  
  205. if(function_exists('curl_init'))
  206. {
  207. $ch = curl_init();
  208. curl_setopt($ch, CURLOPT_URL, $url);
  209. curl_setopt($ch, CURLOPT_HEADER, 0);
  210. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  211. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  212. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  213. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
  214. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
  215. $data = curl_exec($ch);
  216. $errormsg = curl_error($ch);
  217. curl_close($ch);
  218.  
  219. if($errormsg != '')
  220. {
  221. echo $errormsg;
  222. return false;
  223. }
  224. $headers = explode("\n", $data);
  225. }
  226. else if(ini_get('allow_url_fopen') == 1)
  227. {
  228. $fp = @fopen($url, "r");
  229. if(!$fp)
  230. $error = 1;
  231. else
  232. {
  233. if(function_exists('stream_get_meta_data'))
  234. {
  235. $data = @stream_get_meta_data($fp);
  236. $headers = $data['wrapper_data'];
  237. }
  238. else
  239. {
  240. $headers = $http_response_header;
  241. }
  242. }
  243. @fclose($fp);
  244. }
  245. }
  246. return $headers;
  247. }
  248.  
  249. function download_thumb($thumbnail_link, $upload_path, $video_uniq_id, $overwrite_existing_file = false) {
  250.  
  251. if (strpos($thumbnail_link, '//') === 0)
  252. {
  253. $thumbnail_link = 'http:'. $thumbnail_link;
  254. }
  255.  
  256. if (strpos($thumbnail_link, 'http') !== 0)
  257. {
  258. $thumbnail_link = 'http://'. $thumbnail_link;
  259. }
  260.  
  261. $last_ch = substr($upload_path, strlen($upload_path)-1, strlen($upload_path));
  262. if($last_ch != "/")
  263. $upload_path .= "/";
  264.  
  265. $ext = ".jpg";
  266.  
  267. $thumb_name = $video_uniq_id . "-1" . $ext;
  268. //$thumb_name = str_replace('_xt','_t', $thumb_name);
  269.  
  270.  
  271. if(is_file( $upload_path . $thumb_name ) && ! $overwrite_existing_file) {
  272. return FALSE;
  273. }
  274.  
  275. $error = 0;
  276.  
  277. if ( function_exists('curl_init') )
  278. {
  279.  
  280. $ch = curl_init();
  281. $timeout = 0;
  282. curl_setopt ($ch, CURLOPT_URL, $thumbnail_link);
  283. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  284. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  285. // Getting binary data
  286. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  287. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  288. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  289.  
  290. $image = curl_exec($ch);
  291. curl_close($ch);
  292.  
  293. // create & save image;
  294. $img_res = @imagecreatefromstring($image);
  295. if($img_res === false)
  296. return FALSE;
  297.  
  298. $img_width = imagesx($img_res);
  299. $img_height = imagesy($img_res);
  300.  
  301. $resource = @imagecreatetruecolor($img_width, $img_height);
  302.  
  303. if( function_exists('imageantialias'))
  304. {
  305. @imageantialias($resource, true);
  306. }
  307.  
  308. @imagecopyresampled($resource, $img_res, 0, 0, 0, 0, $img_width, $img_height, $img_width, $img_height);
  309. @imagedestroy($img_res);
  310.  
  311. switch($ext)
  312. {
  313. case ".gif":
  314. //GIF
  315. @imagegif($resource, $upload_path . $thumb_name);
  316. break;
  317. case ".jpg":
  318. //JPG
  319. @imagejpeg($resource, $upload_path . $thumb_name);
  320. break;
  321. case ".png":
  322. //PNG
  323. @imagepng($resource, $upload_path . $thumb_name);
  324. break;
  325. }
  326. }
  327. else if( ini_get('allow_url_fopen') == 1 )
  328. {
  329. // try copying it... if it fails, go to backup method.
  330. if(!copy($thumbnail_link, $upload_path . $thumb_name ))
  331. {
  332. // create a new image
  333. list($img_width, $img_height, $img_type, $img_attr) = @getimagesize($thumbnail_link);
  334.  
  335. $image = '';
  336.  
  337. switch($img_type)
  338. {
  339. case 1:
  340. //GIF
  341. $image = imagecreatefromgif($thumbnail_link);
  342. $ext = ".gif";
  343. break;
  344. case 2:
  345. //JPG
  346. $image = imagecreatefromjpeg($thumbnail_link);
  347. $ext = ".jpg";
  348. break;
  349. case 3:
  350. //PNG
  351. $image = imagecreatefrompng($thumbnail_link);
  352. $ext = ".png";
  353. break;
  354. }
  355.  
  356. $resource = @imagecreatetruecolor($img_width, $img_height);
  357. if( function_exists('imageantialias'))
  358. {
  359. @imageantialias($resource, true);
  360. }
  361.  
  362. @imagecopyresampled($resource, $image, 0, 0, 0, 0, $img_width, $img_height, $img_width, $img_height);
  363. @imagedestroy($image);
  364. }
  365.  
  366. $thumb_name = $video_uniq_id . "-1" . $ext;
  367.  
  368. $img_type = 2;
  369. switch($img_type)
  370. {
  371. default:
  372. case 1:
  373. //GIF
  374. @imagegif($resource, $upload_path . $thumb_name);
  375. break;
  376. case 2:
  377. //JPG
  378. @imagejpeg($resource, $upload_path . $thumb_name);
  379. break;
  380. case 3:
  381. //PNG
  382. @imagepng($resource, $upload_path . $thumb_name);
  383. break;
  384. }
  385.  
  386. if($resource === '')
  387. $error = 1;
  388. }
  389.  
  390. return $upload_path . $thumb_name;
  391. }
  392. function do_main(&$video_details, $url)
  393. {
  394.  
  395. $video_data = get_info($url);
  396.  
  397. foreach ($video_data as $k=>$v){
  398.  
  399. if(stripos($v, 'Unavailable in your region') !== false){
  400. echo pm_alert_error('Your server cannot access <strong>Vevo.com</strong> videos due to regional restrictions imposed by <strong>Vevo.com</strong>.');
  401. }
  402. }
  403.  
  404. if($video_data != false)
  405. {
  406. video_details($video_data, $url, $video_details);
  407. }
  408. else
  409. {
  410. $video_details = array();
  411. }
  412. }
Advertisement
Add Comment
Please, Sign In to add comment