• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Help with my gp script to new php?

vl4d

Member
Jul 14, 2018
30
6
8
Hello i need a little help to fix my current code for google photos streaming links, is working on 7.4 but with new php 8++ is just show error and when i fix 1 error after show another etc.
my first error is on line 152 @$dom->loadHTML(curl($url)); .

Is any one who know how to fix this code or maybe is another updated code? thanks :)

this is my code:

PHP:
function checkCode($url)
{
    $process = curl_init();
    curl_setopt($process, CURLOPT_URL, $url);
    curl_setopt(
        $process,
        CURLOPT_USERAGENT,
        "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
    );
    curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($process, CURLOPT_MAXREDIRS, 10);
    curl_setopt($process, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($process, CURLOPT_TIMEOUT, 20);
    $rt = curl_exec($process);
    $info = curl_getinfo($process);
    return $info["http_code"];
}
function curl($url)
{
    $ch = @curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $head[] = "Connection: keep-alive";
    $head[] = "Keep-Alive: 300";
    $head[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    $head[] = "Accept-Language: en-us,en;q=0.5";
    curl_setopt(
        $ch,
        CURLOPT_USERAGENT,
        "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36"
    );
    curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ["Expect:"]);
    $page = curl_exec($ch);
    curl_close($ch);
    return $page;
}
function posterImg($url, $size = "1280,720")
{
    //poster size width,height
    $internalErrors = libxml_use_internal_errors(true);
    $ch = curl_init();
    $timeout = 30;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $html = curl_exec($ch);

    // Print or log the HTML content for debugging
    echo $html;

    $error = curl_error($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);

    if (!empty($error)) {
        // Log or handle the curl error
        echo "Curl Error: $error";
        return false;
    }

    if ($info['http_code'] !== 200) {
        // Log or handle non-200 HTTP response
        echo "HTTP Error: {$info['http_code']}";
        return false;
    }

    $sizes = explode(",", $size);
    $dom = new DOMDocument();
    @$dom->loadHTML($html);
    libxml_use_internal_errors($internalErrors);
    $maximgx = 1;
    $imgx = "";
    foreach ($dom->getElementsByTagName("img") as $element) {
        $maximgx <= 1
            ? $maximgx++ && ($imgx = $element->getAttribute("src"))
            : "";
    }
    $xim = str_replace(
        "=w214-h120-k-no",
        "=w" . $sizes[0] . "-h" . $sizes[1] . "-no",
        $imgx
    );
    return $xim;
}
PHP:
function linkGrab($link)
{
    echo '<meta name="referrer" content="no-referrer" />';
    $get = curl($link);
    $files = "";
    $shigi = explode('data-url="', $get ?? "")[1];
    $ishig090 = explode('" data-widt', $shigi ?? "");
    $linkDownload = [];

    if (isset($ishig090[1])) {
        $v1080p = $ishig090[0] . "=m37";
        $v720p = $ishig090[0] . "=m22";
        $v360p = $ishig090[0] . "=m18";

        $linkDownload["direct"] = dwnload($get);

        if (checkCode($v1080p) != 404) {
            $sources = [
                ["label" => "1080p", "type" => "video/mp4", "file" => $v1080p],
                ["label" => "720p", "type" => "video/mp4", "file" => $v720p],
                ["label" => "360p", "type" => "video/mp4", "file" => $v360p]
            ];
        } elseif (checkCode($v720p) != 404) {
            $sources = [
                ["label" => "720p", "type" => "video/mp4", "file" => $v720p],
                ["label" => "360p", "type" => "video/mp4", "file" => $v360p]
            ];
        } elseif (checkCode($v360p) != 404) {
            $sources = [["label" => "360p", "type" => "video/mp4", "file" => $v360p]];
        } else {
            $sources = [
                ["label" => "direct", "type" => "video/mp4", "file" => $linkDownload["direct"]]
            ];
        }
    } else {
        // Handle the case where the delimiter is not found
        $errorMessage = "Delimiter not found in \$shigi";
        $sources = [
            ["label" => "error", "type" => "text", "file" => $errorMessage]
        ];

        // Return the error message without trying to encode it
        return $errorMessage;
    }

    return json_encode($sources);
}


//download video directly or stream in player without range request headers.
function dwnload($url)
{
    $scriptx = "";
    $internalErrors = libxml_use_internal_errors(true);
    $dom = new DOMDocument();
    @$dom->loadHTML(curl($url));
    foreach ($dom->getElementsByTagName("script") as $k => $js) {
        $scriptx .= $js->nodeValue;
    }
    preg_match_all(
        "#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#",
        $scriptx,
        $match
    );
    $vlink = "";
    foreach ($match[0] as $c) {
        if (strpos($c, "video-downloads") !== false) {
            $vlink = $c;
        }
    }

    return $vlink; //video-downloads.googleusercontent.com - no range headers
}
 
Last edited:
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock