X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Foembed.php;h=5c3c595f57e910ba47577746e7afd53d89c8b1e0;hb=11871195be019bb05c7c41dbb4a980fffce41697;hp=7c0da459409c2859ac543cfa88cf79f6a4450cf4;hpb=58ba7c3969ce51d0f0f67d602886035230c1f3ae;p=friendica.git diff --git a/include/oembed.php b/include/oembed.php old mode 100644 new mode 100755 index 7c0da45940..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); + } } } }