Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * GOLDVOD by stream-recorder.pl
  5.  */
  6.  
  7. $login = "";
  8. $password = "";
  9. $port = "80";
  10. $location = "Holandia";
  11. $quality = "hd";
  12.  
  13. // Statyczny numer kanału
  14. $channel_number = "";
  15.  
  16. // Nadawanie
  17. $rtmp_out = "";
  18.  
  19. function getCurl($url, $postdata) {
  20.   $ch = curl_init($url);
  21.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  22.   curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  23.   curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  24.     'User-Agent: XBMC',
  25.     'ContentType: application/x-www-form-urlencoded'
  26.   ));
  27.   $results = curl_exec($ch);
  28.   curl_close($ch);
  29.   return $results;
  30. }
  31.  
  32. while (1 == 1) {
  33.  
  34. $url = "http://185.35.139.177/api/index.php?page=get_tv_channels";
  35.  
  36. $data = http_build_query(
  37.     array(
  38.         'login' => $login,
  39.         'pass' => $password,
  40.         'location' => $location,
  41.         'port' => $port,
  42.         'type' => 'online'
  43.     )
  44. );
  45.  
  46. $channels = getCurl($url, $data);
  47.  
  48. echo "===CHANNELS=== \n";
  49.  
  50. $channels_list = [];
  51.  
  52. foreach(json_decode($channels) as $channel)
  53. {
  54.    echo $channel->id . " - " . $channel->name . "\n";
  55.    $channels_list[$channel->id] = $channel->name;
  56. }
  57.  
  58. if(!$channel_number) {
  59.   echo "Select channel id: ";
  60.   $channel_number = trim(fgets(STDIN));
  61. }
  62.  
  63. if(!isset($channels_list[$channel_number])) {
  64.   echo "Channel not found  \n";
  65.   die();
  66. }
  67.  
  68. $url = "http://185.35.139.177/api/index.php?page=get_tv_channel";
  69.  
  70. $data = http_build_query(
  71.     array(
  72.       'login' => $login,
  73.       'pass' => $password,
  74.       'location' => $location,
  75.       'port' => $port,
  76.       'id' => $channel_number
  77.     )
  78. );
  79.  
  80. $result = getCurl($url, $data);
  81.  
  82. if(!$result) {
  83.   die();  
  84. }
  85.  
  86. $result = json_decode($result);
  87.  
  88. if($quality === 'hd' && !empty($result->url_hd)) {
  89.   $r = $result->url_hd;
  90. } else {
  91.   $r = $result->url_sd;
  92. }
  93.  
  94. echo "===START=== \n";
  95.  
  96. if($rtmp_out) {
  97.   // restream by ffmpeg
  98.   $cmd = 'ffmpeg -i "' . $r . '" -acodec copy -vcodec copy -f flv '. $rtmp_out;
  99. } else {
  100.   // watch in ffplay
  101.   $cmd = 'ffplay -i "' . $r . '"';
  102. }
  103.  
  104. // start SHOW!
  105. shell_exec($cmd);
  106.  
  107. // sleep from 30 to 90 seconds
  108. sleep(rand(30, 90));
  109.  
  110. }
  111. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement