From 4289b68f0d4e4bcf5e9c09cf03367be3e638ccba Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 5 Aug 2013 10:33:13 +0400 Subject: parser: support media:content elements within media:group --- classes/feeditem/rss.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index e5960243c..a2e9f01a2 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -124,6 +124,18 @@ class FeedItem_RSS extends FeedItem_Common { array_push($encs, $enc); } + $enclosures = $this->xpath->query("media:group/media:content", $this->elem); + + foreach ($enclosures as $enclosure) { + $enc = new FeedEnclosure(); + + $enc->type = $enclosure->getAttribute("type"); + $enc->link = $enclosure->getAttribute("url"); + $enc->length = $enclosure->getAttribute("length"); + + array_push($encs, $enc); + } + return $encs; } -- cgit v1.2.3-54-g00ecf From 6bf61bdc639f60957ce4edc9e0160de3e78dc7df Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 5 Aug 2013 11:50:15 +0400 Subject: simplify media:content xpath --- classes/feeditem/atom.php | 14 +------------- classes/feeditem/rss.php | 14 +------------- 2 files changed, 2 insertions(+), 26 deletions(-) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index e88b5ec1d..b1251e6d3 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -137,19 +137,7 @@ class FeedItem_Atom extends FeedItem_Common { } } - $enclosures = $this->xpath->query("media:content", $this->elem); - - foreach ($enclosures as $enclosure) { - $enc = new FeedEnclosure(); - - $enc->type = $enclosure->getAttribute("type"); - $enc->link = $enclosure->getAttribute("url"); - $enc->length = $enclosure->getAttribute("length"); - - array_push($encs, $enc); - } - - $enclosures = $this->xpath->query("media:group/media:content", $this->elem); + $enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem); foreach ($enclosures as $enclosure) { $enc = new FeedEnclosure(); diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index a2e9f01a2..095225a2a 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -112,19 +112,7 @@ class FeedItem_RSS extends FeedItem_Common { array_push($encs, $enc); } - $enclosures = $this->xpath->query("media:content", $this->elem); - - foreach ($enclosures as $enclosure) { - $enc = new FeedEnclosure(); - - $enc->type = $enclosure->getAttribute("type"); - $enc->link = $enclosure->getAttribute("url"); - $enc->length = $enclosure->getAttribute("length"); - - array_push($encs, $enc); - } - - $enclosures = $this->xpath->query("media:group/media:content", $this->elem); + $enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem); foreach ($enclosures as $enclosure) { $enc = new FeedEnclosure(); -- cgit v1.2.3-54-g00ecf From 5c54e6838870498134bbfb2994c25d2140b43bad Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 5 Aug 2013 12:26:09 +0400 Subject: support media:description for media: enclosures --- classes/feedenclosure.php | 1 + classes/feeditem/atom.php | 3 +++ classes/feeditem/rss.php | 3 +++ css/tt-rss.css | 5 +++++ include/functions.php | 12 +++++++++++- include/rssfuncs.php | 8 ++++++-- 6 files changed, 29 insertions(+), 3 deletions(-) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feedenclosure.php b/classes/feedenclosure.php index d610dd7c8..b57100b06 100644 --- a/classes/feedenclosure.php +++ b/classes/feedenclosure.php @@ -3,5 +3,6 @@ class FeedEnclosure { public $link; public $type; public $length; + public $title; } ?> diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index b1251e6d3..b7a228aed 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -146,6 +146,9 @@ class FeedItem_Atom extends FeedItem_Common { $enc->link = $enclosure->getAttribute("url"); $enc->length = $enclosure->getAttribute("length"); + $desc = $this->xpath->query("media:description", $enclosure)->item(0); + if ($desc) $enc->title = strip_tags($desc->nodeValue); + array_push($encs, $enc); } diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 095225a2a..1f59f0612 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -121,6 +121,9 @@ class FeedItem_RSS extends FeedItem_Common { $enc->link = $enclosure->getAttribute("url"); $enc->length = $enclosure->getAttribute("length"); + $desc = $this->xpath->query("media:description", $enclosure)->item(0); + if ($desc) $enc->title = strip_tags($desc->nodeValue); + array_push($encs, $enc); } diff --git a/css/tt-rss.css b/css/tt-rss.css index 3392c3c7a..9e500a759 100644 --- a/css/tt-rss.css +++ b/css/tt-rss.css @@ -1177,3 +1177,8 @@ span.highlight { background-color : #ffff00; color : #cc90cc; } + +div.enclosure_title { + +} + diff --git a/include/functions.php b/include/functions.php index 56361472e..6bc52e9d9 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3776,6 +3776,7 @@ $url = $line["content_url"]; $ctype = $line["content_type"]; + $title = $line["title"]; if (!$ctype) $ctype = __("unknown type"); @@ -3798,6 +3799,7 @@ $entry["type"] = $ctype; $entry["filename"] = $filename; $entry["url"] = $url; + $entry["title"] = $title; array_push($entries, $entry); } @@ -3819,7 +3821,10 @@ $rv .= "

" .htmlspecialchars($entry["url"]) . "

"; + } + if ($entry['title']) { + $rv.= "
${entry['title']}
"; } } } @@ -3836,7 +3841,12 @@ ""; foreach ($entries as $entry) { - $rv .= ""; + if ($entry["title"]) + $title = "— " . truncate_string($entry["title"], 30); + else + $title = ""; + + $rv .= ""; }; diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 4b1b30c4b..dbe5c8bc9 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -954,7 +954,7 @@ if (is_array($encs)) { foreach ($encs as $e) { $e_item = array( - $e->link, $e->type, $e->length); + $e->link, $e->type, $e->length, $e->title); array_push($enclosures, $e_item); } } @@ -966,10 +966,14 @@ db_query("BEGIN"); +// debugging +// db_query("DELETE FROM ttrss_enclosures WHERE post_id = '$entry_ref_id'"); + foreach ($enclosures as $enc) { $enc_url = db_escape_string($enc[0]); $enc_type = db_escape_string($enc[1]); $enc_dur = db_escape_string($enc[2]); + $enc_title = db_escape_string($enc[3]); $result = db_query("SELECT id FROM ttrss_enclosures WHERE content_url = '$enc_url' AND post_id = '$entry_ref_id'"); @@ -977,7 +981,7 @@ if (db_num_rows($result) == 0) { db_query("INSERT INTO ttrss_enclosures (content_url, content_type, title, duration, post_id) VALUES - ('$enc_url', '$enc_type', '', '$enc_dur', '$entry_ref_id')"); + ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id')"); } } -- cgit v1.2.3-54-g00ecf From ed449a9aaa08d507b92dad934239f4c371f5ca3e Mon Sep 17 00:00:00 2001 From: Jeffrey Tolar Date: Sun, 17 Nov 2013 17:58:43 -0600 Subject: Follow the spec for s Each section specifies multiple representations of the same content. --- classes/feeditem/atom.php | 25 ++++++++++++++++++++++++- classes/feeditem/rss.php | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index b7a228aed..5f0400fea 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -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; } diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 1f59f0612..b5d9695e2 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -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; } -- cgit v1.2.3-54-g00ecf From e23aedd402a0621e3f92f9325b77952968aadbe7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 15 Dec 2013 12:35:30 +0400 Subject: parser: add basic support for media:thumbnail --- classes/feeditem/atom.php | 11 +++++++++++ classes/feeditem/rss.php | 11 +++++++++++ 2 files changed, 22 insertions(+) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 5f0400fea..244fb1f84 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -175,6 +175,17 @@ class FeedItem_Atom extends FeedItem_Common { array_push($encs, $enc); } + $enclosures = $this->xpath->query("media:thumbnail", $this->elem); + + foreach ($enclosures as $enclosure) { + $enc = new FeedEnclosure(); + + $enc->type = "image/generic"; + $enc->link = $enclosure->getAttribute("url"); + + array_push($encs, $enc); + } + return $encs; } diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index b5d9695e2..f632d3bbf 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -150,6 +150,17 @@ class FeedItem_RSS extends FeedItem_Common { array_push($encs, $enc); } + $enclosures = $this->xpath->query("media:thumbnail", $this->elem); + + foreach ($enclosures as $enclosure) { + $enc = new FeedEnclosure(); + + $enc->type = "image/generic"; + $enc->link = $enclosure->getAttribute("url"); + + array_push($encs, $enc); + } + return $encs; } -- cgit v1.2.3-54-g00ecf From f6c61b2d55ff70819bc1582791fdc8df149eb22f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 19 Dec 2013 13:19:30 +0400 Subject: rss: choose between description and content:encoded based on which one is longer because publishers are idiots and can't use tags properly --- classes/feeditem/rss.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index f632d3bbf..7d445a6c3 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -59,16 +59,21 @@ class FeedItem_RSS extends FeedItem_Common { } function get_content() { - $content = $this->xpath->query("content:encoded", $this->elem)->item(0); + $contentA = $this->xpath->query("content:encoded", $this->elem)->item(0); + $contentB = $this->elem->getElementsByTagName("description")->item(0); - if ($content) { - return $content->nodeValue; + if ($contentA && !$contentB) { + return $contentA->nodeValue; } - $content = $this->elem->getElementsByTagName("description")->item(0); - if ($content) { - return $content->nodeValue; + if ($contentB && !$contentA) { + return $contentB->nodeValue; + } + + if ($contentA && $contentB) { + return mb_strlen($contentA->nodeValue) > mb_strlen($contentB->nodeValue) ? + $contentA->nodeValue : $contentB->nodeValue; } } -- cgit v1.2.3-54-g00ecf From 2ab7ccb695fa690ee56100304b93d20e2c20debc Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 12 Jan 2014 08:53:30 +0400 Subject: parser: fix failing on empty media:group tags --- classes/feeditem/atom.php | 26 ++++++++++++++------------ classes/feeditem/rss.php | 26 ++++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 244fb1f84..74be03d80 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -160,19 +160,21 @@ class FeedItem_Atom extends FeedItem_Common { $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); - } + if ($content) { + $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); + array_push($encs, $enc); + } } $enclosures = $this->xpath->query("media:thumbnail", $this->elem); diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 7d445a6c3..28f4a388d 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -140,19 +140,21 @@ class FeedItem_RSS extends FeedItem_Common { $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); + if ($content) { + $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); } - - array_push($encs, $enc); } $enclosures = $this->xpath->query("media:thumbnail", $this->elem); -- cgit v1.2.3-54-g00ecf From 31bd6f7643bf139802a224f4584caca3cbbcc9b8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 4 Mar 2014 16:38:04 +0400 Subject: parser: trim some some feed-extracted data link titles and links --- classes/feeditem/atom.php | 10 +++++----- classes/feeditem/rss.php | 12 ++++++------ classes/feedparser.php | 8 ++++++-- 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 74be03d80..48e3aa567 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -43,9 +43,9 @@ class FeedItem_Atom extends FeedItem_Common { $base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link); if ($base) - return rewrite_relative_url($base, $link->getAttribute("href")); + return rewrite_relative_url($base, trim($link->getAttribute("href"))); else - return $link->getAttribute("href"); + return trim($link->getAttribute("href")); } } @@ -55,7 +55,7 @@ class FeedItem_Atom extends FeedItem_Common { $title = $this->elem->getElementsByTagName("title")->item(0); if ($title) { - return $title->nodeValue; + return trim($title->nodeValue); } } @@ -106,13 +106,13 @@ class FeedItem_Atom extends FeedItem_Common { foreach ($categories as $cat) { if ($cat->hasAttribute("term")) - array_push($cats, $cat->getAttribute("term")); + array_push($cats, trim($cat->getAttribute("term"))); } $categories = $this->xpath->query("dc:subject", $this->elem); foreach ($categories as $cat) { - array_push($cats, $cat->nodeValue); + array_push($cats, trim($cat->nodeValue)); } return $cats; diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 28f4a388d..bf08a1dfe 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -33,20 +33,20 @@ class FeedItem_RSS extends FeedItem_Common { || $link->getAttribute("rel") == "alternate" || $link->getAttribute("rel") == "standout")) { - return $link->getAttribute("href"); + return trim($link->getAttribute("href")); } } $link = $this->elem->getElementsByTagName("guid")->item(0); if ($link && $link->hasAttributes() && $link->getAttribute("isPermaLink") == "true") { - return $link->nodeValue; + return trim($link->nodeValue); } $link = $this->elem->getElementsByTagName("link")->item(0); if ($link) { - return $link->nodeValue; + return trim($link->nodeValue); } } @@ -54,7 +54,7 @@ class FeedItem_RSS extends FeedItem_Common { $title = $this->elem->getElementsByTagName("title")->item(0); if ($title) { - return $title->nodeValue; + return trim($title->nodeValue); } } @@ -90,13 +90,13 @@ class FeedItem_RSS extends FeedItem_Common { $cats = array(); foreach ($categories as $cat) { - array_push($cats, $cat->nodeValue); + array_push($cats, trim($cat->nodeValue)); } $categories = $this->xpath->query("dc:subject", $this->elem); foreach ($categories as $cat) { - array_push($cats, $cat->nodeValue); + array_push($cats, trim($cat->nodeValue)); } return $cats; diff --git a/classes/feedparser.php b/classes/feedparser.php index 187875b5f..239fdb7a6 100644 --- a/classes/feedparser.php +++ b/classes/feedparser.php @@ -205,6 +205,10 @@ class FeedParser { break; } + + if ($this->title) $this->title = trim($this->title); + if ($this->link) $this->link = trim($this->link); + } else { if( !isset($this->error) ){ $this->error = "Unknown/unsupported feed type"; @@ -252,7 +256,7 @@ class FeedParser { foreach ($links as $link) { if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) { - array_push($rv, $link->getAttribute('href')); + array_push($rv, trim($link->getAttribute('href'))); } } break; @@ -261,7 +265,7 @@ class FeedParser { foreach ($links as $link) { if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) { - array_push($rv, $link->getAttribute('href')); + array_push($rv, trim($link->getAttribute('href'))); } } break; -- cgit v1.2.3-54-g00ecf From 523bd90bafffee18d9c7652c68f4c08d25be339e Mon Sep 17 00:00:00 2001 From: Felix Eckhofer Date: Tue, 15 Jul 2014 15:32:28 +0200 Subject: Store size of enclosure to database --- classes/feedenclosure.php | 2 ++ classes/feeditem/atom.php | 6 ++++++ classes/feeditem/rss.php | 8 ++++++++ include/rssfuncs.php | 8 +++++--- 4 files changed, 21 insertions(+), 3 deletions(-) (limited to 'classes/feeditem/rss.php') diff --git a/classes/feedenclosure.php b/classes/feedenclosure.php index b57100b06..64f1a0616 100644 --- a/classes/feedenclosure.php +++ b/classes/feedenclosure.php @@ -4,5 +4,7 @@ class FeedEnclosure { public $type; public $length; public $title; + public $height; + public $width; } ?> diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 48e3aa567..dfac7149f 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -145,6 +145,8 @@ class FeedItem_Atom extends FeedItem_Common { $enc->type = $enclosure->getAttribute("type"); $enc->link = $enclosure->getAttribute("url"); $enc->length = $enclosure->getAttribute("length"); + $enc->height = $enclosure->getAttribute("height"); + $enc->width = $enclosure->getAttribute("width"); $desc = $this->xpath->query("media:description", $enclosure)->item(0); if ($desc) $enc->title = strip_tags($desc->nodeValue); @@ -164,6 +166,8 @@ class FeedItem_Atom extends FeedItem_Common { $enc->type = $content->getAttribute("type"); $enc->link = $content->getAttribute("url"); $enc->length = $content->getAttribute("length"); + $enc->height = $content->getAttribute("height"); + $enc->width = $content->getAttribute("width"); $desc = $this->xpath->query("media:description", $content)->item(0); if ($desc) { @@ -184,6 +188,8 @@ class FeedItem_Atom extends FeedItem_Common { $enc->type = "image/generic"; $enc->link = $enclosure->getAttribute("url"); + $enc->height = $enclosure->getAttribute("height"); + $enc->width = $enclosure->getAttribute("width"); array_push($encs, $enc); } diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index bf08a1dfe..c9a7467cd 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -113,6 +113,8 @@ class FeedItem_RSS extends FeedItem_Common { $enc->type = $enclosure->getAttribute("type"); $enc->link = $enclosure->getAttribute("url"); $enc->length = $enclosure->getAttribute("length"); + $enc->height = $enclosure->getAttribute("height"); + $enc->width = $enclosure->getAttribute("width"); array_push($encs, $enc); } @@ -125,6 +127,8 @@ class FeedItem_RSS extends FeedItem_Common { $enc->type = $enclosure->getAttribute("type"); $enc->link = $enclosure->getAttribute("url"); $enc->length = $enclosure->getAttribute("length"); + $enc->height = $enclosure->getAttribute("height"); + $enc->width = $enclosure->getAttribute("width"); $desc = $this->xpath->query("media:description", $enclosure)->item(0); if ($desc) $enc->title = strip_tags($desc->nodeValue); @@ -144,6 +148,8 @@ class FeedItem_RSS extends FeedItem_Common { $enc->type = $content->getAttribute("type"); $enc->link = $content->getAttribute("url"); $enc->length = $content->getAttribute("length"); + $enc->height = $content->getAttribute("height"); + $enc->width = $content->getAttribute("width"); $desc = $this->xpath->query("media:description", $content)->item(0); if ($desc) { @@ -164,6 +170,8 @@ class FeedItem_RSS extends FeedItem_Common { $enc->type = "image/generic"; $enc->link = $enclosure->getAttribute("url"); + $enc->height = $enclosure->getAttribute("height"); + $enc->width = $enclosure->getAttribute("width"); array_push($encs, $enc); } diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 60cb3b2d2..cdc490cb0 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -989,7 +989,7 @@ if (is_array($encs)) { foreach ($encs as $e) { $e_item = array( - $e->link, $e->type, $e->length, $e->title); + $e->link, $e->type, $e->length, $e->title, $e->width, $e->height); array_push($enclosures, $e_item); } } @@ -1009,14 +1009,16 @@ $enc_type = db_escape_string($enc[1]); $enc_dur = db_escape_string($enc[2]); $enc_title = db_escape_string($enc[3]); + $enc_width = intval($enc[4]); + $enc_height = intval($enc[5]); $result = db_query("SELECT id FROM ttrss_enclosures WHERE content_url = '$enc_url' AND post_id = '$entry_ref_id'"); if (db_num_rows($result) == 0) { db_query("INSERT INTO ttrss_enclosures - (content_url, content_type, title, duration, post_id) VALUES - ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id')"); + (content_url, content_type, title, duration, post_id, width, height) VALUES + ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id', $enc_width, $enc_height)"); } } -- cgit v1.2.3-54-g00ecf