Fix YouTube issues (there are more to be fixed)
This commit is contained in:
@@ -1189,12 +1189,12 @@ function parsecode(&$message)
|
||||
}
|
||||
|
||||
function parseVideo($matches) {
|
||||
$url = $matches[1];
|
||||
list ($url) = explode('#', $matches[1]);
|
||||
|
||||
// check if it's a vimeo video
|
||||
if (preg_match('~^(http://)?(www\.)?vimeo\.com/\d+?~', $url)) {
|
||||
return parseVideoVimeo($url);
|
||||
} elseif (preg_match('~^(http://)?(www\.)?youtube\.com/.*[\?&]v=~', $url)) {
|
||||
} elseif (preg_match('~^(http://)?(www\.)?youtube\.com~', $url)) {
|
||||
return parseVideoYoutube($url);
|
||||
} elseif (preg_match('~^(http://)?vids.myspace.com/~', $url)) {
|
||||
return parseVideoMyspace($url);
|
||||
@@ -1207,19 +1207,17 @@ function parseVideo($matches) {
|
||||
|
||||
function parseVideoMyspace($url)
|
||||
{
|
||||
$ttl = 0;
|
||||
$ttl = 3600;
|
||||
$html = eaccelerator_get($url);
|
||||
if ($html !== NULL) {
|
||||
return $html;
|
||||
}
|
||||
$page = file_get_contents(htmlspecialchars_decode($url));
|
||||
file_put_contents('/tmp/myspace', $page);
|
||||
$page = curl_get(htmlspecialchars_decode($url));
|
||||
$matches = array ();
|
||||
preg_match('~link type="text/xml\+oembed" href="(.+)"~imsU', $page, $matches);
|
||||
if (! empty ($matches)) {
|
||||
$xml_url = $matches[1].'&maxheight=360';
|
||||
$xml_url = $matches[1];#.'&maxheight=360';
|
||||
$html = getVideoOEmbed($xml_url);
|
||||
file_put_contents('/tmp/myspace.oembed', $xml_url);
|
||||
} else {
|
||||
$html = false;
|
||||
}
|
||||
@@ -1228,13 +1226,13 @@ function parseVideoMyspace($url)
|
||||
$html = '<a href="'.$url.'">Посмотреть видео</a>';
|
||||
$ttl = 60;
|
||||
}
|
||||
eaccelerator_put($url, $html, 60);
|
||||
eaccelerator_put($url, $html, $ttl);
|
||||
return $html;
|
||||
}
|
||||
|
||||
function parseVideoDailymotion($url)
|
||||
{
|
||||
$ttl = 0;
|
||||
$ttl = 3600;
|
||||
$html = eaccelerator_get($url);
|
||||
if ($html !== NULL) {
|
||||
return $html;
|
||||
@@ -1248,24 +1246,28 @@ function parseVideoDailymotion($url)
|
||||
$html = '<a href="'.$url.'">Посмотреть видео</a>';
|
||||
$ttl = 60;
|
||||
}
|
||||
eaccelerator_put($url, $html, 60);
|
||||
eaccelerator_put($url, $html, $ttl);
|
||||
return $html;
|
||||
}
|
||||
function parseVideoYoutube($url)
|
||||
{
|
||||
$ttl = 0;
|
||||
$ttl = 3600;
|
||||
$html = eaccelerator_get($url);
|
||||
if ($html !== NULL) {
|
||||
return $html;
|
||||
}
|
||||
$oembed_endpoint = 'http://www.youtube.com/oembed';
|
||||
$_q = array ();
|
||||
$q = parse_url($url, PHP_URL_QUERY);
|
||||
parse_str($q, $_q);
|
||||
$theURL = "http://www.youtube.com/watch?".$q; #v=".$_q['v'];
|
||||
// Create the URLs
|
||||
$xml_url = $oembed_endpoint.'?url='.rawurlencode($url).
|
||||
$xml_url = $oembed_endpoint.'?url='.rawurlencode($theURL).
|
||||
'&format=xml';
|
||||
#&maxwidth=640&maxheight=360';
|
||||
$html = getVideoOEmbed($xml_url);
|
||||
if ($html == false) {
|
||||
$html = '<a href="'.$url.'">Посмотреть видео</a>';
|
||||
$html = '<a href="'.$theURL.'">Посмотреть видео</a>';
|
||||
$ttl = 60;
|
||||
}
|
||||
eaccelerator_put($url, $html, $ttl);
|
||||
@@ -1274,7 +1276,7 @@ function parseVideoYoutube($url)
|
||||
|
||||
function parseVideoVimeo($url)
|
||||
{
|
||||
$ttl = 0;
|
||||
$ttl = 3600;
|
||||
$html = eaccelerator_get($url);
|
||||
if ($html !== NULL) {
|
||||
return $html;
|
||||
|
||||
Reference in New Issue
Block a user