diff options
author | friendica <info@friendica.com> | 2011-11-18 22:04:41 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2011-11-18 22:04:41 -0800 |
commit | fd4fe24406edb277814c7a45a6094a8eec0850d7 (patch) | |
tree | 7db5bceb30a569b035c600313a9dbbf66b14abac /include/oembed.php | |
parent | 485f97b3d8937f219e2b9f3c662ee0e1966130eb (diff) | |
parent | 6893df991edfe971871a5db45055b40b871a7a4f (diff) | |
download | volse-hubzilla-fd4fe24406edb277814c7a45a6094a8eec0850d7.tar.gz volse-hubzilla-fd4fe24406edb277814c7a45a6094a8eec0850d7.tar.bz2 volse-hubzilla-fd4fe24406edb277814c7a45a6094a8eec0850d7.zip |
Merge branch 'master' into groups
Diffstat (limited to 'include/oembed.php')
-rw-r--r-- | include/oembed.php | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/include/oembed.php b/include/oembed.php index 7c0da4594..118f7fa4a 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); + } } } } |