Guest User

Untitled

a guest
Oct 5th, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. include 'functions.php';
  15. set_time_limit(0);
  16. ini_set('default_socket_timeout', 15);
  17. ini_set('memory_limit', -1);
  18. if (isset($argv[1]) && (strtoupper($argv[1]) == 'START')) {
  19. gc_enable();
  20. $rWait = 10000;
  21. $rFailWait = 15;
  22. $rKeyWait = 5;
  23. if (isset($argv[2]) && (strlen($argv[2]) == 32)) {
  24. $rChannel = $argv[2];
  25. plog('Shutting down previous instances.');
  26. exec('kill -9 `ps -ef | grep \'DRM_' . $rChannel . '\' | grep -v grep | awk \'{print $2}\'`');
  27. cli_set_process_title('DRM_' . $rChannel);
  28. $rDatabase = deleteCache($rChannel);
  29. $rDatabase = setCache($rDatabase, 'php_pid', getmypid());
  30. saveCache($rChannel, $rDatabase);
  31.  
  32. while (true) {
  33. plog('Starting: ' . $rChannel);
  34. plog('Killing directory if exists.');
  35. exec('rm -rf ' . MAIN_DIR . 'video/' . $rChannel);
  36. exec('rm -rf ' . MAIN_DIR . 'hls/' . $rChannel);
  37. $rDatabase = setCache($rDatabase, 'php_pid', getmypid());
  38. saveCache($rChannel, $rDatabase);
  39. plog('Creating new directory.');
  40. mkdir(MAIN_DIR . 'video/' . $rChannel);
  41. mkdir(MAIN_DIR . 'video/' . $rChannel . '/aria');
  42. mkdir(MAIN_DIR . 'video/' . $rChannel . '/decrypted');
  43. mkdir(MAIN_DIR . 'video/' . $rChannel . '/encrypted');
  44. mkdir(MAIN_DIR . 'video/' . $rChannel . '/final');
  45. mkdir(MAIN_DIR . 'hls/' . $rChannel);
  46. mkdir(MAIN_DIR . 'hls/' . $rChannel . '/hls');
  47. plog('Grabbing DASH playlist.');
  48. $rData = getBellChannel($rChannel);
  49.  
  50. if ($rData['status']) {
  51. $rChannelData = $rData['data'];
  52. }
  53. else {
  54. $rChannelData = NULL;
  55. }
  56.  
  57. unset($rData);
  58.  
  59. if ($rChannelData) {
  60. $rStarted = false;
  61. $rMemoryUsage = 0;
  62. $rFFPID = NULL;
  63. $rStreamInfo = NULL;
  64.  
  65. while (true) {
  66. plog('Start loop handler.');
  67. $rMemoryUsage = memory_get_usage();
  68. plog('Memory usage: ' . round($rMemoryUsage / 1024 / 1024, 2) . ' MB');
  69. plog('DRM Processes: ' . getProcessCount());
  70. $rKeyFail = false;
  71. $rStart = round(microtime(true) * 1000);
  72.  
  73. if (!is_dir(MAIN_DIR . 'video/' . $rChannel . '/final')) {
  74. plog('Force stopped.');
  75. break;
  76. }
  77.  
  78. plog('Fetching segments...');
  79. $rSegments = getBellSegments($rChannelData, $rConfig['segments_bell']);
  80. if ($rSegments && (0 < strlen($rSegments['video']))) {
  81. $rKeys = getKeyCache(md5($rSegments['video']));
  82.  
  83. if (!$rKeys) {
  84. foreach (range(1, 3) as $rRetry) {
  85. plog('Get keys for ID: ' . $rChannel);
  86. $rData = getKey('bell', base64_encode($rSegments['pssh']));
  87.  
  88. if ($rData['status']) {
  89. plog('Got keys: ' . json_encode($rData['key']));
  90. $rKeys = $rData['key'];
  91.  
  92. if (!setKeyCache(md5($rSegments['video']), json_encode($rData['key']))) {
  93. plog('[FATAL] Cannot write to keystore! Exiting to conserve server integrity.');
  94. exit();
  95. }
  96.  
  97. break;
  98. }
  99. else {
  100. plog('[ERROR] Failed to get key. Retry.');
  101. }
  102.  
  103. unset($rRetry, $rData);
  104. }
  105. }
  106. else {
  107. plog('Key already cached.');
  108. $rKeys = json_decode($rKeys, true);
  109. }
  110.  
  111. if ($rKeys) {
  112. $rCompleted = processSegments($rKeys, $rSegments, $rVideoDir . '/' . $rChannel, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36');
  113.  
  114. if (0 < $rCompleted[1]) {
  115. plog('Finished processing segments.');
  116.  
  117. if ($rCompleted[1] != $rCompleted[0]) {
  118. plog('Skip sleep period.');
  119. $rStart = 0;
  120. }
  121.  
  122. file_put_contents(MAIN_DIR . 'video/' . $rChannel . '/.update', '1');
  123. plog('Updating segment text list.');
  124. updateSegments($rVideoDir . '/' . $rChannel, 10, false, 21600, $rSegments['add']);
  125. if (!$rFFPID || !file_exists('/proc/' . $rFFPID) || (file_exists(MAIN_DIR . ('hls/' . $rChannel . '/hls/playlist.m3u8')) && (60 <= time() - filemtime(MAIN_DIR . ('hls/' . $rChannel . '/hls/playlist.m3u8'))))) {
  126. if (file_exists(MAIN_DIR . 'video/' . $rChannel . '/.ffmpeg')) {
  127. plog('[ERROR] Ffmpeg failure! Increase fail limit.');
  128. .....................................................................
  129. ............................................
  130. ...................
Add Comment
Please, Sign In to add comment