View Single Post
Old 12-19-2012, 04:26 PM   PM User | #571
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Youtube changed the way the video file URLs are displayed in the source code.

For those of you with the free version, do me a favor and test this new code out in the PHP converter class (this replaces the current SetFlvUrls method):

PHP Code:
        private function SetFlvUrls($file_contents)
        {
            
$vidUrls = array();
            
$vidSrcTypes $this->GetVidSrcTypes();
            if (
preg_match('/(yt\.playerConfig =)([^\r\n]+)/'$file_contents$matches) == 1)
            {
                
$jsonObj json_decode(trim($matches[2], ';'));
                if (isset(
$jsonObj->args->url_encoded_fmt_stream_map))
                {
                    
$urls urldecode(urldecode($jsonObj->args->url_encoded_fmt_stream_map));
                    
//die($urls);
                    
if (preg_match('/^((.+?)(=))/'$urls$matches) == 1)
                    {
                        
$urlsArr preg_split('/,'.preg_quote($matches[0], '/').'/'$urls, -1PREG_SPLIT_NO_EMPTY);
                        foreach (
$urlsArr as $url)
                        {
                            if (
$matches[0] != 'url=')
                            {
                                
$url = ($url != $urlsArr[0]) ? $matches[0].$url $url;
                                
$urlBase preg_replace('/(.+?)(url=)(.+?)(\?)(.+)/'"$3$4"$url);
                                
$urlParams preg_replace('/(.+?)(url=)(.+?)(\?)(.+)/'"$1$5"$url);
                                
$url $urlBase "&" $urlParams;
                            }
                            else
                            {
                                
$url preg_replace('/^(url=)/'""$url);
                            }
                            
$url preg_replace('/(.*)(itag=\d+&)(.*?)/''$1$3'$url1);
                            if (
preg_match('/quality=small/',$url) != 1)
                            {
                                
$url preg_replace('/sig=/'"signature="$url);
                                
$url trim($url',');
                                
$url .= '&title=' urlencode($this->ExtractSongTrackName($file_contents$vidSrcTypes[0]));
                                
$url preg_replace_callback('/(&type=)(.+?)(&)/', function($match){return $match[1].urlencode($match[2]).$match[3];}, $url);
                                
$vidUrls[] = $url;
                            }
                        }
                        
$vidUrls array_reverse($vidUrls);
                        
//die(print_r($vidUrls));
                    
}
                }
            }
            
$this->_flvUrls $vidUrls;
        } 
The same basic logic should be applicable to the paid-for version as well...but I have yet to work on the code for that version...don't worry, It's coming soon!

For now, please let me know if the above code works, and thanks again for your continued patience.
__________________
Regards, R.J.

Last edited by chump2877; 12-19-2012 at 05:00 PM..
chump2877 is offline   Reply With Quote