Advertisement
Jsaez

KickKass.to.php

Mar 7th, 2017
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. <?php
  2. class kickass implements ISite, ISearch {
  3. /*
  4. * kickass()
  5. * @param {string} $url
  6. * @param {string} $username
  7. * @param {string} $password
  8. * @param {string} $meta
  9. */
  10. public function __construct($url = null, $username = null, $password = null, $meta = null) {
  11. }
  12.  
  13. /*
  14. * Search()
  15. * @param {string} $keyword
  16. * @param {integer} $limit
  17. * @param {string} $category
  18. * @return {array} SearchLink array
  19. */
  20. public function Search($keyword, $limit, $category) {
  21. $page = 0;
  22.  
  23. $request = array(
  24. "url" => "https://kat.cr/json.php",
  25. "body" => true,
  26. "params" => array(
  27. "q" => $keyword,
  28. "page" => &$page,
  29. "field" => "seeders",
  30. "order" => "desc"
  31. )
  32. );
  33.  
  34. $ajax = new Ajax();
  35. $found = array();
  36. $duplicate = array();
  37. $success = function ($_, $_, $_, $body, $_) use(&$page, &$found, &$duplicate, &$limit) {
  38. if (!($result = json_decode($body, true))) {
  39. $page = false;
  40. return;
  41. }
  42.  
  43. $result = &$result["list"];
  44.  
  45. if (count($result) == 0) {
  46. $page = false;
  47. return;
  48. }
  49.  
  50. foreach ($result as $index => $item) {
  51. if (isset($duplicate[$item["link"]])) {
  52. continue;
  53. }
  54.  
  55. $tlink = new SearchLink;
  56.  
  57. $tlink->src = "kickass.to";
  58. $tlink->link = $item["link"];
  59. $tlink->name = $item["title"];
  60. $tlink->size = $item["size"] + 0;
  61. $tlink->time = DateTime::createFromFormat("l d M Y H:i:s O", $item["pubDate"]);
  62. $tlink->seeds = $item["seeds"] + 0;
  63. $tlink->peers = $item["peers"] + 0;
  64. $tlink->category = strtolower($item["category"]);
  65. $tlink->enclosure_url = $item["torrentLink"];
  66.  
  67. $duplicate[$item["link"]] = true;
  68.  
  69. $found []= $tlink;
  70.  
  71. if (count($found) >= $limit) {
  72. $page = false;
  73. return;
  74. }
  75. }
  76.  
  77. ++$page;
  78. };
  79.  
  80. while ($page !== false && count($found) < $limit) {
  81. if (!$ajax->request($request, $success)) {
  82. break;
  83. }
  84. }
  85.  
  86. return $found;
  87. }
  88. }
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement