How can I get Racaty direct link?

  • Autor Autor InfinityFree
  • Fecha de inicio Fecha de inicio
I

InfinityFree

Curioso
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
I'm currently using a base to try to get the Racaty.io link directly, but I'm not succeeding, see my formula below.


PHP:
<?php
class racaty
{
    public $name = 'Racaty';
    private $id = '';
    private $title = '';
    private $image = '';
    private $referer = '';
    private $status = 'fail';
    private $url = 'https://racaty.net/';
    private $cookies = [];
    private $ch;
    private $proxy = false;

    function __construct($id = '')
    {
        session_write_close();
        if (!empty($id)) {
            $this->id = $id;
            $this->url .= $this->id . '.html';

            $scheme = parse_url($this->url, PHP_URL_SCHEME);
            $host = parse_url($this->url, PHP_URL_HOST);
            $port = parse_URL($this->url, PHP_URL_PORT);
            if (empty($port)) $port = $scheme == 'https' ? 443 : 80;
            $ipv4 = gethostbyname($host);
            $resolveHost = implode(':', array($host, $port, $ipv4));

            session_write_close();
            $this->ch = curl_init();
            curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($this->ch, CURLOPT_MAXREDIRS, 5);
            curl_setopt($this->ch, CURLOPT_ENCODING, '');
            curl_setopt($this->ch, CURLOPT_TIMEOUT, 30);
            curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
            curl_setopt($this->ch, CURLOPT_RESOLVE, array($resolveHost));
            curl_setopt($this->ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
            curl_setopt($this->ch, CURLOPT_DNS_SERVERS, dns_servers());
            curl_setopt($this->ch, CURLOPT_NOSIGNAL, true);
            curl_setopt($this->ch, CURLOPT_DNS_CACHE_TIMEOUT, 300);
            curl_setopt($this->ch, CURLOPT_TCP_KEEPALIVE, true);
            if (defined('CURLOPT_TCP_FASTOPEN')) {
                curl_setopt($this->ch, CURLOPT_TCP_FASTOPEN, true);
            }
            curl_setopt($this->ch, CURLOPT_TCP_NODELAY, true);
            curl_setopt($this->ch, CURLOPT_FORBID_REUSE, true);
            curl_setopt($this->ch, CURLOPT_FAILONERROR, true);
            curl_setopt($this->ch, CURLOPT_HTTPHEADER, array(
                'host: racaty.net',
                'origin: https://racaty.net',
            ));
            curl_setopt($this->ch, CURLOPT_REFERER, $this->url);
            curl_setopt($this->ch, CURLOPT_USERAGENT, USER_AGENT);
            curl_setopt($this->ch, CURLOPT_HEADERFUNCTION, function ($ch, $headerLine) {
                if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) && !empty($cookie[1])) {
                    $this->cookies[] = $cookie[1];
                }
                return strlen($headerLine);
            });
        }
    }

    private function embedSources()
    {
        session_write_close();
        curl_setopt($this->ch, CURLOPT_URL, 'https://racaty.net/embed-' . $this->id . '.html');
        curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'GET');
        $response = curl_exec($this->ch);
        $status = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
        $err = curl_error($this->ch);
        if ($status >= 200 && $status < 400) {
            $dom = \KubAT\PhpSimple\HtmlDomParser::str_get_html($response);
            $vjs = $dom->find('#vjsplayer');
            if ($vjs) {
                $this->status = 'ok';
                $this->image = $vjs[0]->poster;

                $result[] = [
                    'file' => $vjs[0]->find('source', 0)->src,
                    'type' => 'video/mp4',
                    'label' => 'Original'
                ];
                return $result;
            } else {
                $player = $dom->find('#player_code', 0);
                if (!empty($player)) {
                    $eval = $player->find('script', 0)->innertext;
                    if (strpos($eval, 'eval(function(p,a,c,k,e,d)') !== FALSE) {
                        $unpacker = new \JavascriptUnpacker\JavascriptUnpacker();
                        $decode = $unpacker->unpack($eval);

                        $dom = \KubAT\PhpSimple\HtmlDomParser::str_get_html($decode);
                        $embed = $dom->find('#np_vid', 0);
                        if (!empty($embed)) {
                            $this->status = 'ok';
                            $this->image = $dom->find('param[name="previewImage"]', 0)->value;

                            $result[] = [
                                'file' => $embed->src,
                                'type' => 'video/mp4',
                                'label' => 'Original'
                            ];
                            return $result;
                        } else {
                            error_log("racaty embedSources {$this->id} => np_vid not found");
                        }
                    } else {
                        error_log("racaty embedSources {$this->id} => eval not found");
                    }
                } else {
                    error_log("racaty embedSources {$this->id} => player_code not found");
                }
            }
        } else {
            error_log("racaty embedSources {$this->id} => $status: $err");
        }
        return [];
    }

    function get_sources()
    {
        session_write_close();
        if (!empty($this->id)) {
            $data = $this->embedSources();
            if (!empty($data)) {
                return $data;
            } else {
                session_write_close();
                curl_setopt($this->ch, CURLOPT_URL, $this->url);
                curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'POST');
                curl_setopt($this->ch, CURLOPT_POSTFIELDS, 'op=download2&id=' . $this->id . '&rand=&referer=&method_free=&method_premium=');
                $response = curl_exec($this->ch);
                $status = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
                $err = curl_error($this->ch);

                if ($status >= 200 && $status < 400) {
                    $dom = \KubAT\PhpSimple\HtmlDomParser::str_get_html($response);
                    $dl = $dom->find('#uniqueExpirylink');
                    if ($dl) {
                        $this->status = 'ok';
                        $this->referer = $this->url;
                        $this->title = trim($dom->find('.name', 0)->find('strong', 0)->plaintext);

                        $result[] = [
                            'file' => $dl[0]->href,
                            'type' => 'video/mp4',
                            'label' => 'Original'
                        ];
                        return $result;
                    } else {
                        error_log("racaty get_sources {$this->id} => uniqueExpirylink not found");
                    }
                } else {
                    error_log("racaty get_sources {$this->id} => $status: $err");
                }
            }
        }
        return [];
    }

    function get_cookies()
    {
        session_write_close();
        return $this->cookies;
    }

    function get_status()
    {
        session_write_close();
        return $this->status;
    }

    function get_title()
    {
        session_write_close();
        return $this->title;
    }

    function get_image()
    {
        session_write_close();
        return $this->image;
    }

    function get_referer()
    {
        session_write_close();
        return $this->referer;
    }

    function get_id()
    {
        session_write_close();
        return $this->id;
    }

    function __destruct()
    {
        session_write_close();
        curl_close($this->ch);
    }
}

I would like to know if there is a simpler way, could someone help me?

I tried to use the mentioned code as an example, but I couldn't get the original source of the video, I believe I'm forgetting some important factor, I would like to get only the direct link of the video, using GET of the ID.
 
Damn, PHP is so horrible. Look how simple it is to do it in Node.js without dependencies.

JavaScript:
const foo = async (id) => {
  const request = await fetch(`https://racaty.io/embed-${id}.html`);
  const html = await request.text();
  const mp4 = html.match(/source src=".*"/gm)[0].split('="')[1].split('"')[0];
  console.log(mp4);
};
foo("some-id-like-fuck-php");

Enjoy...
 
Última edición:
Damn, PHP is so horrible. Look how simple it is to do it in Node.js without dependencies.

JavaScript:
const foo = async (id) => {
  const request = await fetch(`https://racaty.io/embed-${id}.html`);
  const html = await request.text();
  const mp4 = html.match(/source src=".*"/gm)[0].split('="')[1].split('"')[0];
  console.log(mp4);
};
foo("some-id-like-fuck-php");

Enjoy...
I don't understand much about this language brother!
But your code is very interesting, it passes a vision of being something simple and very intuitive.
 

Temas similares

Atrás
Arriba