php-proxy-app icon indicating copy to clipboard operation
php-proxy-app copied to clipboard

The Pornhub plugin doesn't work.

Open Milix-M opened this issue 4 years ago • 7 comments

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

Milix-M avatar Sep 16 '20 15:09 Milix-M

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

ch4rc0al1080 avatar Sep 17 '20 04:09 ch4rc0al1080

<?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

ch4rc0al1080 avatar Sep 17 '20 05:09 ch4rc0al1080

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

Milix-M avatar Sep 17 '20 12:09 Milix-M

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

Milix-M avatar Sep 22 '20 20:09 Milix-M

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

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

ch4rc0al1080 avatar Sep 30 '20 16:09 ch4rc0al1080

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.

Milix-M avatar Sep 30 '20 18:09 Milix-M

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

ch4rc0al1080 avatar Nov 17 '20 06:11 ch4rc0al1080