Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class kickass implements ISite, ISearch {
- /*
- * kickass()
- * @param {string} $url
- * @param {string} $username
- * @param {string} $password
- * @param {string} $meta
- */
- public function __construct($url = null, $username = null, $password = null, $meta = null) {
- }
- /*
- * Search()
- * @param {string} $keyword
- * @param {integer} $limit
- * @param {string} $category
- * @return {array} SearchLink array
- */
- public function Search($keyword, $limit, $category) {
- $page = 0;
- $request = array(
- "url" => "https://kat.cr/json.php",
- "body" => true,
- "params" => array(
- "q" => $keyword,
- "page" => &$page,
- "field" => "seeders",
- "order" => "desc"
- )
- );
- $ajax = new Ajax();
- $found = array();
- $duplicate = array();
- $success = function ($_, $_, $_, $body, $_) use(&$page, &$found, &$duplicate, &$limit) {
- if (!($result = json_decode($body, true))) {
- $page = false;
- return;
- }
- $result = &$result["list"];
- if (count($result) == 0) {
- $page = false;
- return;
- }
- foreach ($result as $index => $item) {
- if (isset($duplicate[$item["link"]])) {
- continue;
- }
- $tlink = new SearchLink;
- $tlink->src = "kickass.to";
- $tlink->link = $item["link"];
- $tlink->name = $item["title"];
- $tlink->size = $item["size"] + 0;
- $tlink->time = DateTime::createFromFormat("l d M Y H:i:s O", $item["pubDate"]);
- $tlink->seeds = $item["seeds"] + 0;
- $tlink->peers = $item["peers"] + 0;
- $tlink->category = strtolower($item["category"]);
- $tlink->enclosure_url = $item["torrentLink"];
- $duplicate[$item["link"]] = true;
- $found []= $tlink;
- if (count($found) >= $limit) {
- $page = false;
- return;
- }
- }
- ++$page;
- };
- while ($page !== false && count($found) < $limit) {
- if (!$ajax->request($request, $success)) {
- break;
- }
- }
- return $found;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement