Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. <?php
  2.  
  3. $login = "";
  4. $password = "";
  5. $channel_number = "meczenasport_2"; // channel number from list (cid), channel name or empty
  6. $rtmp_out = "rtmp://31.133.0.57/hls/canalplussport2"; // file, rtmp URL or empty to watch in vlc
  7. $quality = ""; // quality HI or empty
  8.  
  9. function getCurl($url, $postdata) {
  10.  
  11. $ch = curl_init($url);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13. curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  14. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  15. 'User-Agent: XBMC',
  16. 'ContentType: application/x-www-form-urlencoded'
  17. ));
  18.  
  19. $results = curl_exec($ch);
  20. curl_close($ch);
  21.  
  22. return $results;
  23.  
  24. }
  25.  
  26. while (1 == 1) {
  27.  
  28. $url = "http://weeb.tv/api/getChannelList";
  29.  
  30. $data = http_build_query(
  31. array(
  32. 'username' => $login,
  33. 'userpassword' => $password
  34. )
  35. );
  36.  
  37. $channels = getCurl($url, $data);
  38.  
  39. echo "===CHANNELS=== \n";
  40.  
  41. $channels_list = [];
  42.  
  43. foreach(json_decode($channels) as $channel)
  44. {
  45. echo $channel->cid . " - " . $channel->channel_title . "\n";
  46. $channels_list[$channel->cid] = $channel->channel_title;
  47. if($channel->channel_name == $channel_number){
  48. $channel_number = $channel->cid;
  49. }
  50. }
  51.  
  52. if(!$channel_number) {
  53. echo "Select channel cid: ";
  54. $channel_number = trim(fgets(STDIN));
  55. }
  56.  
  57. if(!isset($channels_list[$channel_number])) {
  58. echo "Channel not found \n";
  59. die();
  60. }
  61.  
  62. $url = "http://weeb.tv/api/setPlayer";
  63.  
  64. $data = http_build_query(
  65. array(
  66. 'platform' => 'XBMC',
  67. 'channel' => $channel_number,
  68. 'username' => $login,
  69. 'userpassword' => $password
  70. )
  71. );
  72.  
  73. $result = getCurl($url, $data);
  74.  
  75. parse_str(urldecode($result), $params);
  76.  
  77. $r = $params[10] . '/' . $params[11];
  78.  
  79. if($quality) {
  80. $r = $r . $quality;
  81. }
  82.  
  83. $p = 'token';
  84. $s = $params[73];
  85.  
  86. echo "===START=== \n";
  87.  
  88. if($rtmp_out) {
  89. // restream by ffmpeg
  90. $cmd = 'rtmpdump -q -v -r "' . $r . '" -s "' . $s . '" -p "' . $p . '" | ffmpeg -i - -acodec copy -vcodec copy -f flv '. $rtmp_out;
  91. } else {
  92. // watch in VLC
  93. $cmd = 'rtmpdump -q -v -r "'.$r.'" -s "'.$s.'" -p "'.$p.'" | vlc -';
  94. }
  95.  
  96. // start SHOW!
  97. shell_exec($cmd);
  98.  
  99. // sleep from 5 to 30 seconds
  100. sleep(rand(5, 30));
  101.  
  102. }
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement