Athlon1600 / php-proxy-app

Web Proxy Application built on php-proxy library ready to be installed on your server
https://www.php-proxy.com/
MIT License
823 stars 516 forks source link

The Pornhub plugin doesn't work. #188

Closed Milix-M closed 1 year ago

Milix-M commented 3 years ago

The Pornhub plugin doesn't work. Can you help me? Thank you for your support.

ch4rc0al1080 commented 3 years ago

I made a new one and I will make a pr later

ch4rc0al1080 commented 3 years ago
<?php

namespace Proxy\Plugin;

use Proxy\Event\ProxyEvent;
use Proxy\Html;
use Proxy\Plugin\AbstractPlugin;

class PornhubPlugin extends AbstractPlugin
{
    protected $url_pattern = 'pornhub.com';

    private function get_video_url($page_url){
        $_ch = curl_init();
        curl_setopt($_ch, CURLOPT_URL, $page_url);
        curl_setopt($_ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
        curl_setopt($_ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
        curl_setopt($_ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($_ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; Android 10; Pixel 4 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.136 Mobile Safari/537.36');
        $output = curl_exec($_ch);
        curl_close($_ch);
        preg_match('/"quality_480p":"([^"]+)/', $output, $matches);
        $url = $matches[1];
        $url = str_replace('\\', '', $url);
        return $url;
    }

    public function onCompleted(ProxyEvent $event)
    {
        $response = $event['response'];

        $content = $response->getContent();
        //fix thumb
        $content = preg_replace_callback('/<img[^>]+src="([^"]+)"[^>]+data-src = "([^"]+)/', function($matches){
            return str_replace($matches[1], $matches[2], $matches[0]);
        }, $content);
        //fix search button
        $content = preg_replace('/<div id="btnSearch" class="orangeButton"><i><\/i><\/div>/','<button id="btnSearch" class="orangeButton"><i></i></button>',$content);

        $url = $event['request']->getUrl();

        if(preg_match('/view_video/',$url)){
            $video_url = $this->get_video_url($url);
            $content = Html::remove_scripts($content);
            $userAgent = $_SERVER['HTTP_USER_AGENT'];
            if(strpos($userAgent, "Windows") || strpos($userAgent, "Mac OS X")){
            $player = vid_player($video_url, 989, 557,"mp4");
            $content = Html::replace_inner('#player', $player, $content);
            }
            else{
            $player = vid_player($video_url, 400, 216,"mp4");
            $content = Html::replace_inner('.playerWrapper', $player, $content);
            }

        }
        else {$content = Html::remove_scripts($content);}
        $response->setContent($content);
    }
}

@Athlon1600

Milix-M commented 3 years ago

Thank you for creating a new one. I appreciate it. The new plugin does not show the video player.

Milix-M commented 3 years ago

It doesn't work. Is it possible to help?

ch4rc0al1080 commented 3 years ago

It doesn't work. Is it possible to help?

Can you tell me why my code doesn't working? It works well for me

Milix-M commented 3 years ago

It doesn't work. Is it possible to help?

Can you tell me why my code doesn't working? It works well for me

The video is not displayed or the video is small.

ch4rc0al1080 commented 3 years ago

It doesn't work. Is it possible to help?

Can you tell me why my code doesn't working? It works well for me

The video is not displayed or the video is small.

I have edited the code, try again please