X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Foembed.php;h=5c3c595f57e910ba47577746e7afd53d89c8b1e0;hb=11871195be019bb05c7c41dbb4a980fffce41697;hp=3e86627e4dd384683a96e834bd8ec56503ce90a3;hpb=00c342e13d833fd215e5dc03a508e1abe660fe21;p=friendica.git diff --git a/include/oembed.php b/include/oembed.php old mode 100644 new mode 100755 index 3e86627e4d..5c3c595f57 --- a/include/oembed.php +++ b/include/oembed.php @@ -11,26 +11,32 @@ function oembed_replacecb($matches){ function oembed_fetch_url($embedurl){ - + $txt = Cache::get($embedurl); + + $noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm"); + $ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION); + if(is_null($txt)){ $txt = ""; - // try oembed autodiscovery - $redirects = 0; - $html_text = fetch_url($embedurl, false, $redirects, 15); - if($html_text){ - $dom = @DOMDocument::loadHTML($html_text); - if ($dom){ - $xpath = new DOMXPath($dom); - $attr = "oembed"; - - $xattr = oe_build_xpath("class","oembed"); - $entries = $xpath->query("//link[@type='application/json+oembed']"); - foreach($entries as $e){ - $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href); + if (!in_array($ext, $noexts)){ + // try oembed autodiscovery + $redirects = 0; + $html_text = fetch_url($embedurl, false, $redirects, 15, "text/*"); + if($html_text){ + $dom = @DOMDocument::loadHTML($html_text); + if ($dom){ + $xpath = new DOMXPath($dom); + $attr = "oembed"; + + $xattr = oe_build_xpath("class","oembed"); + $entries = $xpath->query("//link[@type='application/json+oembed']"); + foreach($entries as $e){ + $href = $e->getAttributeNode("href")->nodeValue; + $txt = fetch_url($href); + } } } } @@ -56,7 +62,7 @@ function oembed_fetch_url($embedurl){ function oembed_format_object($j){ $embedurl = $j->embedurl; - $jhtml = oembed_iframe($j->html,$j->width,$j->height ); + $jhtml = oembed_iframe($j->embedurl,$j->width,$j->height ); $ret=""; switch ($j->type) { case "video": { @@ -116,7 +122,9 @@ function oembed_iframe($src,$width,$height) { $height = intval($height) + 80; $width = intval($width) + 40; - $s = 'data:text/html;base64,' . base64_encode('' . $src . ''); + $a = get_app(); + + $s = $a->get_baseurl()."/oembed/".base64url_encode($src); return ''; }