Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #usage: sbs_cmd.php search_text=<id>
- # Version 1.00 - inital working release as a command line variant
- # Version 1.01 - modified to work with more SBS shows by better matching the "html:link" URL
- # Version 1.03 - strip out any offending characters from title & write to tmp files
- # Version 1.04 - change output filename string (written to file) to ".mp4" instead of ".ts"
- # Version 1.05 - add ouput of URL to download subtitles
- # Version 1.06 - fix for downloads that didn't include any video stream
- function curl_get($url, array $get = NULL, array $options = array())
- /**
- * Send a GET requst using cURL
- * @param string $url to request
- * @param array $get values to send
- * @param array $options for cURL
- * @return string
- */
- {
- $defaults = array(
- CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''),
- CURLOPT_HEADER => 0,
- CURLOPT_RETURNTRANSFER => TRUE,
- # Might need to uncomment below two lines on some Windows PHP installs
- # Not good for security, but if it works, "Meh" it's only SBS downloads
- #CURLOPT_SSL_VERIFYHOST => 0,
- #CURLOPT_SSL_VERIFYPEER => 0,
- CURLOPT_TIMEOUT => 4
- );
- $ch = curl_init();
- curl_setopt_array($ch, ($options + $defaults));
- if( ! $result = curl_exec($ch))
- { trigger_error(curl_error($ch)); }
- curl_close($ch);
- return $result;
- }
- parse_str(implode('&', array_slice($argv, 1)), $_POST);
- $st = isset($_POST['search_text']) ? $_POST['search_text'] : false;
- $init_url = "www.sbs.com.au/ondemand/video/single/" . $st . "?context=web";
- $data = curl_get($init_url);
- preg_match("/\"html\"\:\".{4}link\.theplatform\.com.*?m3u/", $data, $matches);
- $first_url = str_replace("\/", "/", $matches[0]);
- $first_url = str_replace('"html":"//', "", $first_url);
- $second_data = curl_get($first_url);
- #echo "\n\n"; echo $second_data; echo "\n\n";
- preg_match("/http:\/\/videocdn\.sbs\.com\.au\/u\/video\/SBS\/managed\/closedcaptions.*?.SRT/", $second_data, $subs_url);
- echo $subs_url[0]; echo "\n";
- preg_match("/https?:\/\/(sbsvodns|sbsvodco-vh).*?=off/", $second_data, $second_url);
- preg_match('/title="([^"]+)"/', $second_data, $title);
- $third_data = curl_get($second_url[0]);
- preg_match("/http.*?index_3_av.*\n/", $third_data, $third_url);
- echo "\n"; echo $third_url[0]; echo "\n";
- $ffmpeg_1280 = str_replace("index_3", "index_0", $third_url[0]);
- $fftitle = str_replace("title=","", $title[0]);
- $bad_chars = array("\\", "/", ":", "*", "?", "\"", "<", ">", "|", "'");
- $fftitle = str_replace($bad_chars, "", $fftitle);
- echo $title[0]; echo "\n";
- echo "The command string to download via ffmpeg is: \n\n";
- echo 'ffmpeg -i "'; echo $ffmpeg_1280; echo '" -c copy "'; echo $fftitle; echo '.ts"';
- echo "\n\n";
- $fd_u = fopen("sbsurl.tmp","w"); fwrite($fd_u,"\"$ffmpeg_1280\""); fclose($fd_u);
- $fd_v = fopen("sbsvideo.tmp","w"); fwrite($fd_v,"\"$fftitle.mp4\""); fclose($fd_v);
- $fd_su = fopen("sbsurlsubs.tmp","w"); fwrite($fd_su,"\"$subs_url[0]\""); fclose($fd_su);
- $fd_sv = fopen("sbsvideosubs.tmp","w"); fwrite($fd_sv,"\"$fftitle.srt\""); fclose($fd_sv);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement