Created
January 12, 2016 04:29
-
-
Save phpfiddle/a4f28bb0d8948f294245 to your computer and use it in GitHub Desktop.
[ Posted by Coder ] cc-parser - final ver. - Jan11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Usage example | |
| // | |
| // http_location_of_php_file?surl=http_location_of_page_containing_m3u8_link | |
| // | |
| // valid examples: | |
| // http://main.xfiddle.com/50a77b49/parser.php?surl=http://stream.anluong.info/xemlivetv/starmovies_ntv.php | |
| // http://main.xfiddle.com/50a77b49/parser.php?surl=https://www.arconaitv.me/cn/ | |
| // http://main.xfiddle.com/50a77b49/parser.php?surl=https://www.youtube.com/watch?v=y60wDzZt8yg | |
| // | |
| // for testing set the url below | |
| $testUrl = 'http://www.streamlive.to/view/71137/NBC_Sport_Network'; | |
| // when this php page url is accessed without any params eg. http://main.xfiddle.com/50a77b49/parser.php | |
| // it should decode and print the m3u8 link of the test webpage and can be used to test the parser | |
| // is cURL installed yet? | |
| if (!function_exists('curl_init')){ | |
| die('Sorry cURL is not installed!'); | |
| } | |
| $surl = ''; | |
| try { | |
| if (count($_GET)>0) { | |
| $surl = htmlspecialchars($_GET["surl"]); | |
| } else { | |
| $surl = $testUrl; | |
| } | |
| } catch (Exception $e) { | |
| } | |
| if (strpos($surl, 'stream.anluong.info')) { | |
| $output = get_data_anluong($surl); | |
| } else if (strpos($surl, 'youtube.com')) { | |
| $output = get_data_youtube($surl); | |
| } else if (strpos($surl, 'arconaitv.me')) { | |
| $output = get_data_arconaitv($surl); | |
| } else if (strpos($surl, 'streamlive.to')) { | |
| $output = get_data_streamlive($surl); | |
| } else { | |
| $output = get_data_generic($surl); | |
| } | |
| if (count($_GET)>0) { | |
| $h_out = "Location: ".$output; | |
| header("Referer: no-referrer"); | |
| header("HTTP/1.1 301 Moved Permanently"); | |
| header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 | |
| header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past | |
| if(strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false) { | |
| header("Cache-Control: no-cache"); | |
| header("Pragma: no-cache"); | |
| } | |
| header($h_out); | |
| die(); | |
| //echo '<html><meta name="referrer" content="no-referrer" /><meta http-equiv="Location" content="'.$h_out.'" /></html>'; | |
| //$out = get_page($output); | |
| //echo $out; | |
| } else { | |
| //$out = get_page($output); | |
| echo '<script> | |
| //if(top.location!=self.location){ | |
| top.location=self.location; | |
| } | |
| </script> | |
| <html>'.$output.'</html>'; | |
| } | |
| //header("Location: ".$output); | |
| //exit; | |
| function get_data_anluong($url) { | |
| $ch = curl_init(); | |
| $timeout = 5; | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
| $ip = get_client_ip(); | |
| //echo $ip.'<br/><br/>'; | |
| $rem_addr = "REMOTE_ADDR: ".$ip; | |
| $http_fwd = "HTTP_X_FORWARDED_FOR: ".$ip; | |
| //$http_host = "Host: www.anluong.info"; | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array($rem_addr, $http_fwd)); | |
| //curl_setopt($ch, CURLOPT_INTERFACE, $ip); | |
| // Include header in result? (0 = yes, 1 = no) | |
| curl_setopt($ch, CURLOPT_HEADER, 0); | |
| // User agent | |
| curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"); | |
| // Set a referer | |
| curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com"); | |
| $input_lines = curl_exec($ch); | |
| curl_close($ch); | |
| $input_lines = substr($input_lines, strpos($input_lines,'deviceType')-50); | |
| preg_match_all("/http\:\/\/123.*.(location\=)/s", $input_lines, $output_array); | |
| $out = $output_array[0][0].'&from=anluongtv'; | |
| return $out; | |
| } | |
| function get_data_youtube($url) { | |
| $ch = curl_init(); | |
| $timeout = 5; | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
| $ip = get_client_ip(); | |
| //echo $ip.'<br/><br/>'; | |
| $rem_addr = "REMOTE_ADDR: ".$ip; | |
| $http_fwd = "HTTP_X_FORWARDED_FOR: ".$ip; | |
| //$http_host = "Host: www.anluong.info"; | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array($rem_addr, $http_fwd)); | |
| //curl_setopt($ch, CURLOPT_INTERFACE, $ip); | |
| // Include header in result? (0 = yes, 1 = no) | |
| curl_setopt($ch, CURLOPT_HEADER, 0); | |
| // User agent | |
| curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"); | |
| // Set a referer | |
| curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com"); | |
| $input_lines = curl_exec($ch); | |
| curl_close($ch); | |
| $input_lines = substr($input_lines, strpos($input_lines,'hls_variant')-50); | |
| $input_lines = substr($input_lines, 0, strpos($input_lines,'.m3u8')+20); | |
| preg_match_all("/manifest\.googlevideo.*.(\.m3u8)/s", $input_lines, $output_array); | |
| $out = 'https://'.$output_array[0][0]; | |
| $out = str_replace("\\", "", $out); | |
| return $out; | |
| } | |
| function get_data_arconaitv($url) { | |
| $ch = curl_init(); | |
| $timeout = 5; | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
| $ip = get_client_ip(); | |
| //echo $ip.'<br/><br/>'; | |
| $rem_addr = "REMOTE_ADDR: ".$ip; | |
| $http_fwd = "HTTP_X_FORWARDED_FOR: ".$ip; | |
| //$http_host = "Host: www.anluong.info"; | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array($rem_addr, $http_fwd)); | |
| //curl_setopt($ch, CURLOPT_INTERFACE, $ip); | |
| // Include header in result? (0 = yes, 1 = no) | |
| curl_setopt($ch, CURLOPT_HEADER, 0); | |
| // User agent | |
| curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"); | |
| // Set a referer | |
| curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com"); | |
| $input_lines = curl_exec($ch); | |
| curl_close($ch); | |
| $input_lines = substr($input_lines, strpos($input_lines,'m3u8')-150); | |
| preg_match_all("/http.*.(\.m3u8)/s", $input_lines, $output_array); | |
| $out = $output_array[0][0]; | |
| return $out; | |
| } | |
| function get_data_streamlive($url) { | |
| $ch = curl_init(); | |
| $timeout = 5; | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
| $ip = get_client_ip(); | |
| //echo $ip.'<br/><br/>'; | |
| $rem_addr = "REMOTE_ADDR: ".$ip; | |
| $http_fwd = "HTTP_X_FORWARDED_FOR: ".$ip; | |
| $http_host = "Host: www.streamlive.to"; | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array($rem_addr, $http_fwd, $http_host)); | |
| //curl_setopt($ch, CURLOPT_INTERFACE, $ip); | |
| // Include header in result? (0 = yes, 1 = no) | |
| curl_setopt($ch, CURLOPT_HEADER, 0); | |
| // User agent | |
| curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"); | |
| // Set a referer | |
| curl_setopt($ch, CURLOPT_REFERER, "http://www.streamlive.to/"); | |
| $input_lines = curl_exec($ch); | |
| curl_close($ch); | |
| //$input_lines = str_replace("top.location == self.location", "false", $input_lines); | |
| //echo $input_lines; | |
| //exit; | |
| $input_lines = substr($input_lines, strpos($input_lines,'.m3u8')-100); | |
| preg_match_all("/http.*.(provider)/s", $input_lines, $output_array); | |
| $out = $output_array[0][0]; | |
| $out = str_replace("watch4", "mplay", $out); | |
| $out = str_replace("provider", "", $out); | |
| $out = str_replace(",", "", $out); | |
| $out = str_replace("'", "", $out); | |
| return $out; | |
| } | |
| function get_data_generic($url) { | |
| $ch = curl_init(); | |
| $timeout = 5; | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
| $ip = get_client_ip(); | |
| //echo $ip.'<br/><br/>'; | |
| $rem_addr = "REMOTE_ADDR: ".$ip; | |
| $http_fwd = "HTTP_X_FORWARDED_FOR: ".$ip; | |
| //$http_host = "Host: www.anluong.info"; | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array($rem_addr, $http_fwd)); | |
| //curl_setopt($ch, CURLOPT_INTERFACE, $ip); | |
| // Include header in result? (0 = yes, 1 = no) | |
| curl_setopt($ch, CURLOPT_HEADER, 0); | |
| // User agent | |
| curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"); | |
| // Set a referer | |
| curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com"); | |
| $input_lines = curl_exec($ch); | |
| curl_close($ch); | |
| //$input_lines = substr($input_lines, strpos($input_lines,'.m3u8')-150); | |
| preg_match_all("/http.*.(\.m3u8)/s", $input_lines, $output_array); | |
| $out = $output_array[0][0]; | |
| return $out; | |
| } | |
| // Function to get the client IP address | |
| function get_client_ip() { | |
| $ipaddress = ''; | |
| if (getenv('HTTP_CLIENT_IP')) | |
| $ipaddress = getenv('HTTP_CLIENT_IP'); | |
| else if(getenv('HTTP_X_FORWARDED_FOR')) | |
| $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); | |
| else if(getenv('HTTP_X_FORWARDED')) | |
| $ipaddress = getenv('HTTP_X_FORWARDED'); | |
| else if(getenv('HTTP_FORWARDED_FOR')) | |
| $ipaddress = getenv('HTTP_FORWARDED_FOR'); | |
| else if(getenv('HTTP_FORWARDED')) | |
| $ipaddress = getenv('HTTP_FORWARDED'); | |
| else if(getenv('REMOTE_ADDR')) | |
| $ipaddress = getenv('REMOTE_ADDR'); | |
| else | |
| $ipaddress = 'UNKNOWN'; | |
| return $ipaddress; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment