$login, 'pass' => $password, 'location' => $location, 'port' => $port, 'type' => 'online' ) ); $channels = getCurl($url, $data); echo "===CHANNELS=== \n"; $channels_list = []; foreach(json_decode($channels) as $channel) { echo $channel->id . " - " . $channel->name . "\n"; $channels_list[$channel->id] = $channel->name; } if(!$channel_number) { echo "Select channel id: "; $channel_number = trim(fgets(STDIN)); } if(!isset($channels_list[$channel_number])) { echo "Channel not found \n"; die(); } $url = "http://185.35.139.177/api/index.php?page=get_tv_channel"; $data = http_build_query( array( 'login' => $login, 'pass' => $password, 'location' => $location, 'port' => $port, 'id' => $channel_number ) ); $result = getCurl($url, $data); if(!$result) { die(); } $result = json_decode($result); if($quality === 'hd' && !empty($result->url_hd)) { $r = $result->url_hd; } else { $r = $result->url_sd; } echo "===START=== \n"; if($rtmp_out) { // restream by ffmpeg $cmd = 'ffmpeg -i "' . $r . '" -acodec copy -vcodec copy -f flv '. $rtmp_out; } else { // watch in ffplay $cmd = 'ffplay -i "' . $r . '"'; } // start SHOW! shell_exec($cmd); // sleep from 5 to 30 seconds sleep(rand(30, 90)); } ?>