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):
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.
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, -1, PREG_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', $url, 1);
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;
}
For now, please let me know if the above code works, and thanks again for your continued patience.
Comment