YouTube in PHProxy

Discussion in 'PHP' started by tokyoice, Jan 7, 2008.

  1. #1
    Well I was trying to find a freaking youtube solution for PHProxy. I saw cheerios post and thought I'd modify the preg so that it would work for youtube. Here it is, it requires that base64 be on to work since I can't seem to figure out how to get it to work with out Base64. The preg is in 2 parts, and it may not be the best preg but it works.
    It requires jw media player which can be downloaded here.

    It can be edited to be better, and so on but I just plan on turning errors off Smiley
    Feedback would be good too.
    Code:

    Upload MediaPlayer.swf, then your good to go.
    Paste this right before the echo $_response_body which is at the very end of the page.
    If you want to modify stuff to be better then go ahead and do so.

    if (($_url_parts['host'] == "youtube.com") || ($_url_parts['host'] == "www.youtube.com"))
    {
    		preg_match('/fullscreenUrl\s\=\s(.*)\&sk\=/', $_response_body, $matches);
    		preg_match('/video\_id\=(.*)/',$matches[1],$matches);
    		$file = base64_encode('http://youtube.com/get_video?video_id='.$matches[1]);
    		$link = $_script_base'?q='.$file;
    		$s[] = '/var v = "7";(.*?)player_div\);/is';
    		$r[] = '';
    
    		$s[] =  '#\/\/ \<\!\[(.*?)\/\/ \]\]\>#is';
    		$r[] = "
    		var p = new SWFObject('{$_script_base}mediaplayer.swf','single','450','370','7');
    		p.addParam('allowfullscreen','true');
    		p.addVariable('file','$link');
    		p.addVariable('backcolor','0x000000');
    		p.addVariable('frontcolor','0xCCCCCC');
    		p.addVariable('lightcolor','0x996600');
    		p.addVariable('overstretch','true');
    		p.addVariable('type','flv');
    		p.addVariable('volume','50');
    		p.write('playerDiv');";
    		$_response_body = preg_replace( $s, $r, $_response_body );
    }
    
    PHP:
    Source: http://proxy.org/forum/1198884211.html
     
    tokyoice, Jan 7, 2008 IP