X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Foembed.php;h=118f7fa4a39f45fdb5b91819f864f199df40365b;hb=3e162bcf8f4c08d197f9507dd6daa56cf6104a4e;hp=7c0da459409c2859ac543cfa88cf79f6a4450cf4;hpb=1ff8cddeb6b9eb53c2714893c61e378e8efc2768;p=friendica.git diff --git a/include/oembed.php b/include/oembed.php index 7c0da45940..118f7fa4a3 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -13,24 +13,30 @@ 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); + } } } }