public static function download_torrent($url, $hash, $old_torrent) { if (preg_match('`^https?://rutracker\\.(org|cr|net)/forum/viewtopic\\.php\\?t=(?P<id>\\d+)$`', $url, $matches)) { $topic_id = $matches["id"]; $req_url = "http://api.rutracker.cr/v1/get_tor_hash?by=topic_id&val=" . $topic_id; $client = ruTrackerChecker::makeClient($req_url); if ($client->status != 200) { return ruTrackerChecker::STE_CANT_REACH_TRACKER; } $ret = json_decode($client->results, true); if (array_key_exists("result", $ret)) { $ret = $ret["result"]; } if ($ret && array_key_exists($topic_id, $ret) && strtoupper($ret[$topic_id]) == $hash) { return ruTrackerChecker::STE_UPTODATE; } $client->setcookies(); $client->fetchComplex("http://dl.rutracker.cr/forum/dl.php?t=" . $topic_id); if ($client->status != 200) { return $client->status < 0 ? ruTrackerChecker::STE_CANT_REACH_TRACKER : ruTrackerChecker::STE_DELETED; } return ruTrackerChecker::createTorrent($client->results, $hash); } return ruTrackerChecker::STE_NOT_NEED; }
public static function download_torrent($url, $hash, $old_torrent) { if (preg_match('`^http://tr\\.anidub\\.com/\\?newsid=(?P<id>\\d+)$`', $url, $matches)) { $topic_id = $matches["id"]; $torrent_name = $old_torrent->name(); $torrent_quality = null; $torrent_quality_type = ""; # checking torrent quality from torrent file name if (preg_match('/\\_\\[((?<vq>\\d{1,3})p)|(?<vq1>PSP)|(?<vq2>HWP)|(bdrip(?<vq3>\\d{1,3})p)\\]\\_/i', $torrent_name, $qmatches)) { if (array_key_exists("vq", $qmatches)) { $torrent_quality = $qmatches["vq"]; # tv quality $torrent_quality_type = "tv"; } if (array_key_exists("vq3", $qmatches)) { $torrent_quality = strtolower($qmatches["vq3"]); # bd quality $torrent_quality_type = "bd"; } if (array_key_exists("vq1", $qmatches)) { $torrent_quality = strtolower($qmatches["vq1"]); } if (array_key_exists("vq2", $qmatches)) { $torrent_quality = strtolower($qmatches["vq2"]); } } // ToDo: if torrent doesn't contain any quality tag, try to guess in other ways # exit, no way to get torrent file without this if ($torrent_quality === null) { return ruTrackerChecker::STE_NOT_NEED; } $client = ruTrackerChecker::makeClient($url); if ($client->status != 200) { return ruTrackerChecker::STE_CANT_REACH_TRACKER; } $resp = preg_replace("/\r|\n/", "", $client->results); $q = $torrent_quality_type . $torrent_quality; // e.g. tv.720 $pattern = sprintf('/\\<div\\sid\\=\\"%s\\"\\>\\<div\\sid=\'[\\d\\w\\_]+\'\\>\\s+\\<div\\sclass=\\"torrent\\_h\\"\\>\\s+\\<a\\shref=\\"(?P<url>[\\w\\d\\_\\/\\.\\=\\?]+)\\"\\s/i', $q); if (!preg_match($pattern, $resp, $url_matches)) { ruTrackerChecker::STE_CANT_REACH_TRACKER; } if (!preg_match('/\\/engine\\/download\\.php\\?id=\\d{1,10}/i', $url_matches["url"], $m)) { ruTrackerChecker::STE_CANT_REACH_TRACKER; } $client->setcookies(); $client->fetchComplex("http://tr.anidub.com" . $url_matches["url"]); if (intval($client->status) != 200) { return $client->status < 0 ? ruTrackerChecker::STE_CANT_REACH_TRACKER : ruTrackerChecker::STE_DELETED; } return ruTrackerChecker::createTorrent($client->results, $hash); } return ruTrackerChecker::STE_NOT_NEED; }
public static function download_torrent($url, $hash, $old_torrent) { if (preg_match('`^http://(?P<tracker>kinozal)\\.tv/details\\.php\\?id=(?P<id>\\d+)$`', $url, $matches)) { $topic_id = $matches["id"]; $client = ruTrackerChecker::makeClient("http://kinozal.tv/get_srv_details.php?action=2&id=" . $topic_id); if ($client->status == 200 && preg_match('`<li>.*(?P<hash>[0-9A-Fa-f]{40})</li>`', $client->results, $matches1)) { if (strtoupper($matches1["hash"]) == $hash) { return ruTrackerChecker::STE_UPTODATE; } } $client->setcookies(); $client->fetchComplex("http://dl.kinozal.tv/download.php?id=" . $matches["id"]); if ($client->status != 200) { return $client->status < 0 ? ruTrackerChecker::STE_CANT_REACH_TRACKER : ruTrackerChecker::STE_DELETED; } return ruTrackerChecker::createTorrent($client->results, $hash); } return ruTrackerChecker::STE_NOT_NEED; }
public static function download_torrent($url, $hash, $old_torrent) { $client = ruTrackerChecker::makeClient($url); if ($client->status != 200) { return ruTrackerChecker::STE_CANT_REACH_TRACKER; } if (preg_match('`Info hash:</td><td><strong>(?P<hash>[0-9A-Fa-f]{40})</strong></td>`', $client->results, $matches)) { if (strtoupper($matches["hash"]) == $hash) { return ruTrackerChecker::STE_UPTODATE; } if (preg_match('`\\"download.php\\?id=(?P<id>\\d+)`', $client->results, $matches)) { $client->setcookies(); $client->fetchComplex("http://tfile.co/forum/download.php?id=" . $matches["id"]); if ($client->status != 200) { return $client->status < 0 ? ruTrackerChecker::STE_CANT_REACH_TRACKER : ruTrackerChecker::STE_DELETED; } return ruTrackerChecker::createTorrent($client->results, $hash); } } return ruTrackerChecker::STE_NOT_NEED; }
<?php if (!chdir(dirname(__FILE__))) { exit; } if (count($argv) > 1) { $_SERVER['REMOTE_USER'] = $argv[1]; } require_once "check.php"; $req = new rXMLRPCRequest(new rXMLRPCCommand("d.multicall", array("seeding", getCmd("d.get_hash="), getCmd("d.get_custom=") . "chk-state", getCmd("d.get_custom=") . "chk-time", getCmd("d.get_custom=") . "chk-stime", getCmd("cat") . '="$' . getCmd("t.multicall=") . getCmd("d.get_hash=") . "," . getCmd("t.get_url") . "=," . getCmd("cat=#") . '"'))); if ($req->success()) { for ($i = 0; $i < count($req->val); $i += 5) { if (strpos($req->val[$i + 4], ".rutracker.org/") !== false || strpos($req->val[$i + 4], ".kinozal.tv/") !== false) { if (!ruTrackerChecker::run($req->val[$i], $req->val[$i + 1], $req->val[$i + 2], $req->val[$i + 3])) { break; } } } }
<?php if (count($argv) > 2) { $_SERVER['REMOTE_USER'] = $argv[2]; } if (count($argv) > 1 && chdir(dirname(__FILE__))) { require_once "check.php"; $hashes = unserialize(file_get_contents($argv[1])); if (is_array($hashes)) { foreach ($hashes as $hash) { ruTrackerChecker::run($hash); } } unlink($argv[1]); }