Facebook
From asd, 4 Months ago, written in PHP.
Embed
Download Paste or View Raw
Hits: 82
  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.     array(
  37.         'login' => $login,
  38.         'pass' => $password,
  39.         'location' => $location,
  40.         'port' => $port,
  41.         'type' => 'online'
  42.     )
  43. );
  44.  
  45. $channels = getCurl($url, $data);
  46.  
  47. echo "===CHANNELS=== \n";
  48.  
  49. $channels_list = [];
  50.  
  51. foreach(json_decode($channels) as $channel)
  52. {
  53.    echo $channel->id . " - " . $channel->name . "\n";
  54.    $channels_list[$channel->id] = $channel->name;
  55. }
  56.  
  57. if(!$channel_number) {
  58.   echo "Select channel id: ";
  59.   $channel_number = trim(fgets(STDIN));
  60. }
  61.  
  62. if(!isset($channels_list[$channel_number])) {
  63.   echo "Channel not found  \n";
  64.   die();
  65. }
  66.  
  67. $url = "http://185.35.139.177/api/index.php?page=get_tv_channel";
  68.  
  69.     array(
  70.       'login' => $login,
  71.       'pass' => $password,
  72.       'location' => $location,
  73.       'port' => $port,
  74.       'id' => $channel_number
  75.     )
  76. );
  77.  
  78. $result = getCurl($url, $data);
  79.  
  80. if(!$result) {
  81.   die();  
  82. }
  83.  
  84. $result = json_decode($result);
  85.  
  86. if($quality === 'hd' && !empty($result->url_hd)) {
  87.   $r = $result->url_hd;
  88. } else {
  89.   $r = $result->url_sd;
  90. }
  91.  
  92. echo "===START=== \n";
  93.  
  94. if($rtmp_out) {
  95.   // restream by ffmpeg
  96.   $cmd = 'ffmpeg -i "' . $r . '" -acodec copy -vcodec copy -f flv '. $rtmp_out;
  97. } else {
  98.   // watch in ffplay
  99.   $cmd = 'ffplay -i "' . $r . '"';
  100. }
  101.  
  102. // start SHOW!
  103. shell_exec($cmd);
  104.  
  105. // sleep from 5 to 30 seconds
  106. sleep(rand(30, 90));
  107.  
  108. }
  109. ?>