]> git.wh0rd.org Git - tt-rss.git/commitdiff
Follow the spec for <media:group>s
authorJeffrey Tolar <tolar.jeffrey@gmail.com>
Sun, 17 Nov 2013 23:58:43 +0000 (17:58 -0600)
committerJeffrey Tolar <tolar.jeffrey@gmail.com>
Sun, 17 Nov 2013 23:58:43 +0000 (17:58 -0600)
Each <media:group> section specifies multiple representations of the
same content.

classes/feeditem/atom.php
classes/feeditem/rss.php

index b7a228aed406c88615fc13bbfd0ea1a2abd81f56..5f0400feacd00574c30b1a005818373af5cc873c 100644 (file)
@@ -137,7 +137,7 @@ class FeedItem_Atom extends FeedItem_Common {
                        }
                }
 
-               $enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem);
+               $enclosures = $this->xpath->query("media:content", $this->elem);
 
                foreach ($enclosures as $enclosure) {
                        $enc = new FeedEnclosure();
@@ -152,6 +152,29 @@ class FeedItem_Atom extends FeedItem_Common {
                        array_push($encs, $enc);
                }
 
+
+               $enclosures = $this->xpath->query("media:group", $this->elem);
+
+               foreach ($enclosures as $enclosure) {
+                       $enc = new FeedEnclosure();
+
+                       $content = $this->xpath->query("media:content", $enclosure)->item(0);
+
+                       $enc->type = $content->getAttribute("type");
+                       $enc->link = $content->getAttribute("url");
+                       $enc->length = $content->getAttribute("length");
+
+                       $desc = $this->xpath->query("media:description", $content)->item(0);
+                       if ($desc) {
+                               $enc->title = strip_tags($desc->nodeValue);
+                       } else {
+                               $desc = $this->xpath->query("media:description", $enclosure)->item(0);
+                               if ($desc) $enc->title = strip_tags($desc->nodeValue);
+                       }
+
+                       array_push($encs, $enc);
+               }
+
                return $encs;
        }
 
index 1f59f0612b104a7c589890e209860899af8641ee..b5d9695e28ccf30ea988db445cbc222176861e1e 100644 (file)
@@ -112,7 +112,7 @@ class FeedItem_RSS extends FeedItem_Common {
                        array_push($encs, $enc);
                }
 
-               $enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem);
+               $enclosures = $this->xpath->query("media:content", $this->elem);
 
                foreach ($enclosures as $enclosure) {
                        $enc = new FeedEnclosure();
@@ -127,6 +127,29 @@ class FeedItem_RSS extends FeedItem_Common {
                        array_push($encs, $enc);
                }
 
+
+               $enclosures = $this->xpath->query("media:group", $this->elem);
+
+               foreach ($enclosures as $enclosure) {
+                       $enc = new FeedEnclosure();
+
+                       $content = $this->xpath->query("media:content", $enclosure)->item(0);
+
+                       $enc->type = $content->getAttribute("type");
+                       $enc->link = $content->getAttribute("url");
+                       $enc->length = $content->getAttribute("length");
+
+                       $desc = $this->xpath->query("media:description", $content)->item(0);
+                       if ($desc) {
+                               $enc->title = strip_tags($desc->nodeValue);
+                       } else {
+                               $desc = $this->xpath->query("media:description", $enclosure)->item(0);
+                               if ($desc) $enc->title = strip_tags($desc->nodeValue);
+                       }
+
+                       array_push($encs, $enc);
+               }
+
                return $encs;
        }