aboutsummaryrefslogtreecommitdiffstats
path: root/include/oembed.php
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-11-17 13:40:11 +0100
committerFabio Comuni <fabrix.xm@gmail.com>2011-11-17 13:40:11 +0100
commit02281be0c3b19bcab3ae3a96475846104af11e92 (patch)
tree167c2697fc1a6749786fe1ab252b9fdab827e90a /include/oembed.php
parentd77c87f42ae1e6906de4a087e752a7babef11421 (diff)
downloadvolse-hubzilla-02281be0c3b19bcab3ae3a96475846104af11e92.tar.gz
volse-hubzilla-02281be0c3b19bcab3ae3a96475846104af11e92.tar.bz2
volse-hubzilla-02281be0c3b19bcab3ae3a96475846104af11e92.zip
oembed: don't try to fetch media files and add Accept request header to fetch_url
Diffstat (limited to 'include/oembed.php')
-rw-r--r--include/oembed.php34
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);
+ }
}
}
}