smallkan

Untitled

Jan 8th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. ##################################################################################
  2. index.php
  3. ##################################################################################
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="utf-8">
  8. <title></title>
  9. </head>
  10. <body>
  11.  
  12. <div id="tmp">
  13. <input type="text" id="slug" placeholder="slug do anime" value="shingeki-no-kyojin">
  14. <input type="text" id="count" placeholder="número de eps" value="36">
  15. <button type="button" id="processar">Processar</button>
  16. <ul id="list-eps">
  17.  
  18. </ul>
  19. </div>
  20.  
  21. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
  22. <script type="text/javascript">
  23. var api = {};
  24. api.grab_gid = function(uri){
  25. $.ajax({
  26. url: 'api.php',
  27. method: 'post',
  28. async: false,
  29. data: {
  30. action: 'download',
  31. url: uri
  32. },
  33. success: function(data){
  34. window.episodios.push(data);
  35. var index = window.episodios.length;
  36. $('#list-eps').append('<li>Ep ' + index + ': <a href="' + data + '" target="_blank">' + data + '</a></li>');
  37. },
  38. error: function(data){
  39. console.log(data);
  40. }
  41. });
  42. }
  43.  
  44.  
  45. // DOM: On Ready
  46. $(document).ready(function(){
  47.  
  48. // Ação ao clicar em "Processar"
  49. $(document).on('click', '#processar', function(){
  50. var slug = $('#slug').val();
  51. var count = $('#count').val();
  52. window.episodios = [];
  53.  
  54. var index = 1;
  55. function grab(){
  56. api.grab_gid('https://www.superanimes.site/anime/' + slug + '/episodio-' + index + '/baixar');
  57. console.log('Ep ' + index + ': capturado!');
  58. if (index++ < count) setTimeout(grab, 500);
  59. if (index >= count && window.episodios.length == count){
  60. console.log('Grab finalizado!');
  61. console.log(window.episodios);
  62. }
  63. }
  64. grab();
  65. });
  66. });
  67. </script>
  68.  
  69. </body>
  70. </html>
  71.  
  72. ############################################################################################################
  73. api.php
  74. ############################################################################################################
  75. <?php
  76.  
  77. function returnJSON($content = null, $code = 200){
  78. header('Cache-Control: no-cache, must-revalidate');
  79. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  80. header('Content-type: application/json');
  81. $status = array(
  82. 200 => '200 OK',
  83. 400 => '400 Bad Request',
  84. 422 => '422 Unprocessable Entity',
  85. 500 => '500 Internal Server Error'
  86. );
  87. header('Status', true, (in_array($code, $status)) ? $code : 500);
  88. echo json_encode($content);
  89. exit(0);
  90. }
  91.  
  92. if(isset($_POST['action']) && $_POST['action'] == "download"){
  93.  
  94. $html = file_get_contents($_POST['url']);
  95. $g_id = base64_decode(explode('&token=', explode('https://www.superanimes.site/download.php?file=', $html)[1])[0]);
  96. $g_url = "https://www.blogger.com/video-play.mp4?contentId={$g_id}";
  97. returnJSON($g_url, 200);
  98. }
  99.  
  100. if(isset($_POST['action']) && $_POST['action'] == "count"){
  101.  
  102. $html = file_get_contents($_POST['url']);
  103. $count = explode('</span>', explode('<span itemprop="numberofEpisodes">', $html)[1])[0];
  104. returnJSON($count, 200);
  105. }
  106.  
  107. ?>
Advertisement
Add Comment
Please, Sign In to add comment