Keresés

Új hozzászólás Aktív témák

  • Locsi

    senior tag

    válasz Doink #19574 üzenetére

    Köszönöm. Közben megoldódott, kaptam egy újabb verziót, az már leszedi ezt a kulcsot is.

  • 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