SHARE
TWEET

Untitled

a guest Apr 2nd, 2017 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. #usage: sbs_cmd.php search_text=<id>
  4.  
  5. # Version 1.00 - inital working release as a command line variant
  6. # Version 1.01 - modified to work with more SBS shows by better matching the "html:link" URL
  7. # Version 1.03 - strip out any offending characters from title & write to tmp files
  8. # Version 1.04 - change output filename string (written to file) to ".mp4" instead of ".ts"
  9. # Version 1.05 - add ouput of URL to download subtitles
  10. # Version 1.06 - fix for downloads that didn't include any video stream
  11.  
  12. function curl_get($url, array $get = NULL, array $options = array())
  13. /**
  14. * Send a GET requst using cURL
  15. * @param string $url to request
  16. * @param array $get values to send
  17. * @param array $options for cURL
  18. * @return string
  19. */
  20. {
  21.     $defaults = array(
  22.         CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''),
  23.         CURLOPT_HEADER => 0,
  24.         CURLOPT_RETURNTRANSFER => TRUE,
  25. # Might need to uncomment below two lines on some Windows PHP installs
  26. # Not good for security, but if it works, "Meh" it's only SBS downloads
  27. #CURLOPT_SSL_VERIFYHOST => 0,
  28. #CURLOPT_SSL_VERIFYPEER => 0,
  29.         CURLOPT_TIMEOUT => 4
  30.     );
  31.  
  32.     $ch = curl_init();
  33.     curl_setopt_array($ch, ($options + $defaults));
  34.     if( ! $result = curl_exec($ch))
  35.       { trigger_error(curl_error($ch)); }
  36.     curl_close($ch);
  37.     return $result;
  38. }
  39.  
  40. parse_str(implode('&', array_slice($argv, 1)), $_POST);
  41. $st = isset($_POST['search_text']) ? $_POST['search_text'] : false;
  42. $init_url = "www.sbs.com.au/ondemand/video/single/" . $st . "?context=web";
  43. $data = curl_get($init_url);
  44. preg_match("/\"html\"\:\".{4}link\.theplatform\.com.*?m3u/", $data, $matches);
  45. $first_url = str_replace("\/", "/", $matches[0]);
  46. $first_url = str_replace('"html":"//', "", $first_url);
  47. $second_data = curl_get($first_url);
  48. #echo "\n\n"; echo $second_data; echo "\n\n";
  49. preg_match("/http:\/\/videocdn\.sbs\.com\.au\/u\/video\/SBS\/managed\/closedcaptions.*?.SRT/", $second_data, $subs_url);
  50. echo $subs_url[0]; echo "\n";
  51. preg_match("/https?:\/\/(sbsvodns|sbsvodco-vh).*?=off/", $second_data, $second_url);
  52. preg_match('/title="([^"]+)"/', $second_data, $title);
  53. $third_data = curl_get($second_url[0]);
  54. preg_match("/http.*?index_3_av.*\n/", $third_data, $third_url);
  55. echo "\n"; echo $third_url[0]; echo "\n";
  56. $ffmpeg_1280 = str_replace("index_3", "index_0", $third_url[0]);
  57. $fftitle = str_replace("title=","", $title[0]);
  58. $bad_chars = array("\\", "/", ":", "*", "?", "\"", "<", ">", "|", "'");
  59. $fftitle = str_replace($bad_chars, "", $fftitle);
  60.  
  61. echo $title[0]; echo "\n";
  62. echo "The command string to download via ffmpeg is: \n\n";
  63. echo 'ffmpeg -i "'; echo $ffmpeg_1280; echo '" -c copy "'; echo $fftitle; echo '.ts"';
  64. echo "\n\n";
  65.  
  66. $fd_u = fopen("sbsurl.tmp","w"); fwrite($fd_u,"\"$ffmpeg_1280\""); fclose($fd_u);
  67. $fd_v = fopen("sbsvideo.tmp","w"); fwrite($fd_v,"\"$fftitle.mp4\""); fclose($fd_v);
  68. $fd_su = fopen("sbsurlsubs.tmp","w"); fwrite($fd_su,"\"$subs_url[0]\""); fclose($fd_su);
  69. $fd_sv = fopen("sbsvideosubs.tmp","w"); fwrite($fd_sv,"\"$fftitle.srt\""); fclose($fd_sv);
  70. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top