public function start() { $t1 = microtime(true); $db = db_connect(DBHOST, DBUSER, DBPASS, DBNAME); $sdb = db_connect('localhost:9306', '', '', 'rtindex'); $total_urls = count($this->urls); for ($i = 0; $i < $total_urls; $i++) { unset($res); file_put_contents('status.txt', 'Limetorrents::...' . $this->urls[$i]); $res = gethtml($this->urls[$i]); if (strstr($this->urls[$i], 'Movies')) { $category = 'movies'; } elseif (strstr($this->urls[$i], 'TV')) { $category = 'tv'; } elseif (strstr($this->urls[$i], 'Music')) { $category = 'music'; } elseif (strstr($this->urls[$i], 'Games')) { $category = 'games'; } elseif (strstr($this->urls[$i], 'Applications')) { $category = 'software'; } elseif (strstr($this->urls[$i], 'Anime')) { $category = 'anime'; } else { $category = 'other'; } $type = Rivr::getType($category); $this->index($res, $type, $db, $sdb); } $time = microtime(true) - $t1; $db->query("INSERT INTO crawls SET source_id = '{$this->source_id}', added_torrents = '{$this->added}', updated_torrents = '{$this->updated}', time = '{$time}';"); return array($this->added, $this->updated); }
private function index($data, $db, $sdb) { $data = str_get_html($data); foreach ($data->find('.even, .odd') as $result) { $title = $result->find('.cellMainLink', 0)->plaintext; $url = 'https://kat.cr' . $result->find('.cellMainLink', 0)->href; $m = $result->find('div.iaconbox', 0); $hash = strtoupper(between($m, 'magnet:?xt=urn:btih:', '&dn=')); $size = round(strToBytes($result->find('td.nobr', 0)->plaintext) / 1024); $seeds = $result->find('td.green', 0)->plaintext; $peers = $result->find('td.red', 0)->plaintext; $date = strtotime($result->find('td', 3)->title); $uploader = $result->find('a.plain', 1)->plaintext; $files = $result->find('td', 2)->plaintext; if (!$result->find('span.block')) { continue; } $cdata = $result->find('span.block', 0)->find('strong', 0)->plaintext; if (strstr($cdata, 'Movies')) { $type = 'movies'; } elseif (strstr($cdata, 'Games')) { $type = 'games'; } elseif (strstr($cdata, 'Music')) { $type = 'music'; } elseif (strstr($cdata, 'Applications')) { $type = 'software'; } elseif (strstr($cdata, 'TV')) { $type = 'tv'; } elseif (strstr($cdata, 'XXX')) { $type = 'p**n'; } elseif (strstr($cdata, 'Anime')) { $type = 'anime'; } elseif (strstr($cdata, 'Books')) { $type = 'books'; } else { $type = 'other'; } $type = Rivr::getType($type); $cdate = time(); $query = $db->query("SELECT id FROM rtindex WHERE url = '{$url}' LIMIT 1;"); if ($query->num_rows) { $this->updated++; $info = $query->fetch_assoc(); Rivr::updateTorrent($db, $sdb, $info['id'], $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } else { $this->added++; Rivr::addTorrent($db, $sdb, $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } } $data->clear(); unset($data); }
private function index($data, $db, $sdb) { $data = str_get_html($data); if (!$data->find('#searchResult')) { return; } $data = $data->find('#searchResult', 0); foreach ($data->find('tr') as $result) { if (!$result->find('.detLink')) { continue; } $title = $result->find('.detLink', 0)->plaintext; $url = explode('/', 'https://thepiratebay.se' . $result->find('.detLink', 0)->href); array_pop($url); $url = implode('/', $url); $magnet = $result->find('td', 1); $magnet = $magnet->find('a', 1)->href; $hash = strtoupper(between($magnet, 'magnet:?xt=urn:btih:', '&dn=')); $size = str_replace(' ', ' ', $result->find('.detDesc', 0)->plaintext); $words = mb_split('iB', $size); $words2 = mb_split('\\s', $words[0]); $length = count($words2); $size = $words2[$length - 2] . ' ' . $words2[$length - 1] . 'B'; $size = round(strToBytes($size) / 1024); $seeds = $result->find('td', 2)->plaintext; $peers = $result->find('td', 3)->plaintext; $date = str_replace(' ', ' ', $result->find('.detDesc', 0)->plaintext); $date = str_replace('-', '/', between($date, 'Uploaded ', ', Size')); $date = strtotime($date); $uploader = $result->find('a.detDesc'); if ($uploader) { $uploader = $uploader[0]->plaintext; } $cdata = $result->find('a', 1)->href; $cdata2 = $result->find('a', 0)->href; if (strstr($cdata, 'browse/201') || strstr($cdata, 'browse/207')) { $type = 'movies'; } elseif (strstr($cdata2, 'browse/400')) { $type = 'games'; } elseif (strstr($cdata, 'browse/101')) { $type = 'music'; } elseif (strstr($cdata2, 'browse/300')) { $type = 'software'; } elseif (strstr($cdata, 'browse/205') || strstr($cdata, 'browse/208')) { $type = 'tv'; } elseif (strstr($cdata2, 'browse/500')) { $type = 'p**n'; } else { $type = 'other'; } $type = Rivr::getType($type); $cdate = time(); $query = $db->query("SELECT id FROM rtindex WHERE url = '{$url}' LIMIT 1;"); if ($query->num_rows) { $this->updated++; $info = $query->fetch_assoc(); Rivr::updateTorrent($db, $sdb, $info['id'], $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } else { $this->added++; Rivr::addTorrent($db, $sdb, $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } } $data->clear(); unset($data); }
private function index($data, $db, $sdb) { $data = str_get_html($data); if (!$data->find('.table-torrents')) { return; } $data = $data->find('.table-torrents', 0); foreach ($data->find('tr') as $result) { if (!$result->find('td.title-row')) { continue; } $title = $result->find('td.title-row', 0)->find('a', 0)->plaintext; $url = 'https://isohunt.to' . $result->find('td.title-row', 0)->find('a', 0)->href; $size = round(strToBytes($result->find('td.size-row', 0)->plaintext) / 1024); $seeds = $result->find('td.sy', 0)->plaintext; $peers = 0; $hash = ''; $date = strtotime($result->find('td.date-row', 0)->plaintext); $cdata = strtolower($result->find('span.torrent-icon', 0)->title); if (strstr($cdata, 'movies')) { $type = 'movies'; } elseif (strstr($cdata, 'games')) { $type = 'games'; } elseif (strstr($cdata, 'music')) { $type = 'music'; } elseif (strstr($cdata, 'software')) { $type = 'software'; } elseif (strstr($cdata, 'tv')) { $type = 'tv'; } elseif (strstr($cdata, 'adult')) { $type = 'p**n'; } elseif (strstr($cdata, 'anime')) { $type = 'anime'; } elseif (strstr($cdata, 'books')) { $type = 'books'; } else { $type = 'other'; } $type = Rivr::getType($type); $cdate = time(); $query = $db->query("SELECT id FROM rtindex WHERE url = '{$url}' LIMIT 1;"); if ($query->num_rows) { $this->updated++; $info = $query->fetch_assoc(); Rivr::updateTorrent($db, $sdb, $info['id'], $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } else { $this->added++; Rivr::addTorrent($db, $sdb, $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } } $data->clear(); unset($data); }
private function index($data, $db, $sdb) { $data = str_get_html($data); if (!$data->find('div.tab-detail')) { return; } $data = $data->find('div.tab-detail', 0); foreach ($data->find('li') as $result) { if (!$result->find('a')) { continue; } $title = $result->find('a', 1)->plaintext; $url = 'https://1337x.to' . $result->find('a', 1)->href; $size = round(strToBytes($result->find('div.coll-4', 0)->plaintext) / 1024); $seeds = $result->find('span.green', 0)->plaintext; $peers = $result->find('span.red', 0)->plaintext; $hash = ''; $uploader = $result->find('.uploader, .vip', 0)->plaintext; $cdata = $result->find('.coll-1', 0)->find('i', 0)->class; if (strstr($cdata, 'Movies')) { $type = 'movies'; } elseif (strstr($cdata, 'Games')) { $type = 'games'; } elseif (strstr($cdata, 'Music')) { $type = 'music'; } elseif (strstr($cdata, 'Apps')) { $type = 'software'; } elseif (strstr($cdata, 'TV')) { $type = 'tv'; } elseif (strstr($cdata, 'XXX')) { $type = 'p**n'; } elseif (strstr($cdata, 'Anime')) { $type = 'anime'; } else { $type = 'other'; } $type = Rivr::getType($type); $cdate = time(); $query = $db->query("SELECT id FROM rtindex WHERE url = '{$url}' LIMIT 1;"); if ($query->num_rows) { $this->updated++; $info = $query->fetch_assoc(); Rivr::updateTorrent($db, $sdb, $info['id'], $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } else { $this->added++; Rivr::addTorrent($db, $sdb, $title, $hash, $this->source_id, $seeds, $peers, $date, $url, $cdate, $type, $size, $files, $uploader); } } $data->clear(); unset($data); }