Új hozzászólás Aktív témák
-
Locsi
senior tag
Sziasztok. Van egy Ncore kereső, a Synology Nas-hoz de már nem igazán működik, még akkor sem, ha jól van beállítva. Azt szeretném, hogy magát a kereső plugint átalakítani, hogy azt a kulcsot is hozzá illessze az url végére, amit a torrent letöltésékor kapunk. Valahogy így néz ki, amit a dlm generál.
http://ncore.cc/torrents.php?action=download&id=xxxxxxx
és így kellene, hogy kinézzen
http://ncore.cc/torrents.php?action=download&id=xxxxxxx&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Maga a kereső, az így néz ki, de nem tudom, hova kellene beírni, hogy helyes legyen.
<?php
class SynoDLMSearchNCore {
private $qurl = 'http://ncore.cc/torrents.php';
private $purl = 'http://ncore.cc/torrents.php?action=download&id=';
private $NCORE_COOKIE = "/tmp/ncore.cookie";
private $NCORE_LOGIN_URL = 'https://ncore.cc/login.php';
public function __construct() {
}
public function prepare($curl, $query, $username, $password) {
if (!file_exists($this->NCORE_COOKIE) && $username !== NULL && $password !== NULL) {
$this->VerifyAccount($username, $password);
}
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_USERAGENT, DOWNLOAD_STATION_USER_AGENT);
curl_setopt($curl, CURLOPT_COOKIEFILE, $this->NCORE_COOKIE);
curl_setopt($curl, CURLOPT_HEADER, TRUE);
curl_setopt($curl, CURLOPT_REFERER, $this->qurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_URL, $this->qurl."?miben=name&tipus=all_own&miszerint=fid&hogyan=DESC&mire=".urlencode("[###]" != $query ? $query : ""));
}
public function VerifyAccount($Username, $Password) {
$ret = FALSE;
$PostData = array('ne_leptessen_ki'=>'1',
'Submit'=>'Belépés!',
'nev'=>$Username,
'pass'=>$Password,
'set_lang'=>'hu',
'submitted'=>1,
);
$PostData = http_build_query($PostData);
$queryUrl = $this->NCORE_LOGIN_URL;
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_USERAGENT, DOWNLOAD_STATION_USER_AGENT);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $PostData);
curl_setopt($curl, CURLOPT_COOKIEJAR, $this->NCORE_COOKIE);
curl_setopt($curl, CURLOPT_HEADER, TRUE);
curl_setopt($curl, CURLOPT_REFERER, $this->NCORE_LOGIN_URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_URL, $queryUrl);
$LoginInfo = curl_exec($curl);
curl_close($curl);
if (FALSE != $LoginInfo && preg_match("/Set-Cookie: nick=".$Username."/iU", $LoginInfo) && file_exists($this->NCORE_COOKIE)) {
$ret = TRUE;
} else {
$ret = FALSE;
}
return $ret;
}
public function parse(&$plugin, $response) {
preg_match("/<div.*?box_torrent_all.*?>/iU", $response, $match);
$beginPos = strpos($response, $match[0]);
preg_match("/<div.*?lista_lab.*?>/iU", $response, $match);
$endPos = strpos($response, $match[0]);
$response = substr($response, $beginPos, $endPos-$beginPos);
preg_match("/<div.*\"box_torrent_all\".*>(.*?)<\/div>/isU", $response, $match);
$response = $match[1];
$res=0;
if(preg_match_all("/<div class=\"box_torrent\">(.*)<div class=\"torrent_lenyilo/siU", $response, $matches2, PREG_SET_ORDER)) {
foreach($matches2 as $match2) {
$title="Unknown title";
$download="Unknown download";
$size=0;
$datetime="1978-09-28";
$page="Default page";
$hash="Hash unknown";
$seeds=0;
$leechs=0;
$category="Unknown category";
$torrentData = $match2[1];
preg_match("/"
."<div class=\"box_alap_img\">.*<a.*<img.*alt=['\"](.*)['\"].*"
."<div class=\"torrent_txt2?\">.*<a.*href=['\"].*id=(\d+)['\"].*(title=['\"](.*)['\"].*)<nobr>(.*)<\/nobr>.*"
."box_feltoltve.*>(.*)<\/.*"
."box_meret.*>(.*)<\/.*"
."box_s.*<a.*>(\d+)<\/.*"
."box_l.*<a.*>(\d+)<\/.*"
."/isU", $torrentData, $matchDetail);
if (count($matchDetail) > 0){
$title = $this->getTitle($matchDetail);
$download = $this->qurl."?action=download&id=".$matchDetail[2];
$size = $this->getSize($matchDetail);
$datetime = $this->getDate($matchDetail);
$page = $this->qurl."?action=details&id=".$matchDetail[2];
$hash = md5($title.$download);
$seeds = $matchDetail[8];
$leechs = $matchDetail[9];
// $category = utf8_encode($matchDetail[1]);
$category = $matchDetail[1];
$plugin->addResult($title, $download, $size, $datetime, $page, $hash, $seeds, $leechs, $category);
$res++;
} else {
ob_start();
var_dump($torrentData);
file_put_contents("/tmp/dlm_parse_error_".date("YmdHis")."_".rand(100000).".txt", ob_get_clean()."\n");
}
}
}
return $res;
}
private function getTitle ($matches) {
return ("..." == substr($matches[5], -3) && trim($matches[4]) != "" ? $matches[4] : $matches[5]);
}
private function getSize ($matches) {
$size = str_replace(array("<br>", "<br />", "<br/>"), array(" "), $matches[7]);
preg_match("/(.*) (.*)/i", $size, $sizeParts);
$multiplier = 1;
switch ($sizeParts[2]){
case "TB": $multiplier *= 1024;
case "GB": $multiplier *= 1024;
case "MB": $multiplier *= 1024;
case "kB": $multiplier *= 1024; break;
}
return $sizeParts[1] * $multiplier;
}
private function getDate($matches) {
$date = $matches[6];
if(preg_match("/(\d+)-(\d+)-(\d+).*?(\d+):(\d+):(\d+)/i", $date, $matchDate)){
$date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $matchDate[1], $matchDate[2], $matchDate[3], $matchDate[4], $matchDate[5], $matchDate[6]);
}
return $date;
}
}
?>
Új hozzászólás Aktív témák
- Nem indul és mi a baja a gépemnek topik
- Milyen billentyűzetet vegyek?
- exHWSW - Értünk mindenhez IS
- OFF TOPIC 44 - Te mondd, hogy offtopic, a te hangod mélyebb!
- iPhone topik
- Xiaomi 15T Pro - a téma nincs lezárva
- Intel Core i3 / i5 / i7 / i9 10xxx "Comet Lake" és i3 / i5 / i7 / i9 11xxx "Rocket Lake" (LGA1200)
- Éjszakai műszak
- Kompakt vízhűtés
- TCL LCD és LED TV-k
- További aktív témák...
- Gigabyte Geforce RTX 3090 Eagle OC
- Budget Gamer - i5 7600 / GTX 1070 8GB / 16GB DDR4 / 512GB SSD
- Eladó Apple Watch SE 2 Rose Gold
- Bomba ár! Lenovo ThinkPad L13 G3 - i5-1245U I 16GB I 256SSD I 13,3" WUXGA I Cam I W11 I Garancia!
- Bomba ár! Fujitsu LifeBook U904 - i5-4G I 10GB I 500GB I 14" QHD+ I Cam I W10 I Gari!
- Jó áron eladó Lenovo ThinkPad T14s Gen 3/i5-1240P/16 GB/256 SSD/FHD+/IPS/Garancia/
- 27% - LG UltraGear 27GS93QE-B OLED Monitor! 2560x1440 / 240Hz / 0.03ms / G-SYNC / FreeSync
- 27% - Dell S2721NX IPS Monitor! 1920x1080 / 75Hz / 4ms / FreeSync
- Lenovo ThinkPad W541,15.6,FHD,i7-4810MQ,32GB DDR3,256GB SSD,K1100 2GB VGA,WIN10
- Toshiba KIOXIA XG8 4TB M.2 Gen4 SSD (7,000 MB/s and 5,800 MB/s)
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
