Skip Menu |

This queue is for tickets about the XML-RSS CPAN distribution.

Report information
The Basics
Id: 7920
Status: resolved
Priority: 10/
Queue: XML-RSS

People
Owner: Nobody in particular
Requestors: CPAN [...] mikew.net
James_Armstrong [...] cox.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.05
Fixed in: (no value)



Subject: Enclosure parsing
The current version (1.05) and in the latest version 1.33 doesn't parse <enclosure /> in an <item> element of a RSS2.0. XML::RSS supports enclosure in output. The following quick hack adds support for enclosure parsing. 1558a1559,1564 Show quoted text
> elsif ( $el eq 'enclosure' and > $self->current_element eq 'item') { > foreach my $attrib (keys(%attribs)){ > $self->{'items'}->[$self->{num_items}-1]->{$el}->{$attrib} = $attribs{$attrib}; > } > }
From: Teemu Arina
Also a patch to implement this is available here: http://bulknews.net/lib/archives/patches/xml-rss-enclosure.patch
Subject: XML::RSS not returning enclosures
XML::RSS VERSION: 1.05 XML::RSS::Feed VERSION: 2.04 XML::UM VERSION: 0.01 XML::RSS::Feed VERSION: 1.22 libxml-perl VERSION: 0.08 XML::Parser::EasyTree VERSION: 0.01 XML::LibXSLT VERSION: 1.57 XML::Registry VERSION: 0.02 XML::Node VERSION: 0.11 XML::QL VERSION: 0.07 XML::Schematron VERSION: 0.98 XML::SemanticDif VERSION: 0.95 XML::Simple VERSION: 2.14 XML::Twig VERSION: 3.17 XML::XPath VERSION: 1.13 XML::miniXQL VERSION: 0.04 XML::XSLT VERSION: 0.48 XML::Handler::YAWriter VERSION: 0.23 XML::DTDParser VERSION: 2.01 XML::DT VERSION: 0.40 Using Data::Dumper on items returned by XML::RSS shows no data from enclosure elements is present. The attached patch makes the data appear but is not offered as a permanent fix since I am sure I did not understand the sub that I put it in.
--- RSS.pm 2004-04-21 00:14:43.000000000 -0700 +++ /home/jda2000/XML/RSS.pm 2005-05-06 09:07:09.935742219 -0700 @@ -5,6 +5,7 @@ use Carp; use XML::Parser; use vars qw($VERSION $AUTOLOAD @ISA $modules $AUTO_ADD); +#~ use Data::Dumper; $VERSION = '1.05'; @ISA = qw(XML::Parser); @@ -1439,6 +1440,12 @@ my $self = shift; my $el = shift; my %attribs = @_; + + if ($el eq 'enclosure') { + $self->{'items'}->[$self->{num_items}-1]->{ $el } = \%attribs; + #~ print "ENCLOSURE "; + #~ print Dumper(\%attribs); + } # beginning of RSS 0.91 if ($el eq 'rss') {
From: pcyeo [...] yahoo.com
[guest - Sat Apr 23 18:14:52 2005]: Show quoted text
> Also a patch to implement this is available here: > http://bulknews.net/lib/archives/patches/xml-rss-enclosure.patch
Hi, Can someone please give me some clue on how to apply this patch? I am pretty new to perl programming and is in desparate need to get the enclosure parsing done correctly. Thanks! Patrick
On Sat Apr 23 18:14:52 2005, guest wrote: Show quoted text
> Also a patch to implement this is available here: > http://bulknews.net/lib/archives/patches/xml-rss-enclosure.patch
Attached is a reworked and more correct patch that can be applied as is to the repository. ABH, please apply it. Regards, Shlomi Fish
On Wed Oct 18 10:11:29 2006, SHLOMIF wrote: Show quoted text
> On Sat Apr 23 18:14:52 2005, guest wrote:
> > Also a patch to implement this is available here: > > http://bulknews.net/lib/archives/patches/xml-rss-enclosure.patch
> > Attached is a reworked and more correct patch that can be applied as
is Show quoted text
> to the repository. ABH, please apply it. >
Oops! The patch was not attached. Here it is. Regards, Shlomi Fish Show quoted text
> Regards, > > Shlomi Fish
=== t/enclosures.t ================================================================== --- t/enclosures.t (revision 333) +++ t/enclosures.t (revision 334) @@ -0,0 +1,48 @@ +use strict; +use Test::More; + +use constant RSS_VERSION => "2.0"; +use constant RSS_CHANNEL_TITLE => "Example 2.0 Channel"; + +use constant RSS_DOCUMENT => qq(<?xml version="1.0"?> +<rss version="2.0"> + <channel> + <title>Example 2.0 Channel</title> + <link>http://example.com/</link> + <description>To lead by example</description> + <language>en-us</language> + <copyright>All content Public Domain, except comments which remains copyright the author</copyright> + <managingEditor>editor\@example.com</managingEditor> + <webMaster>webmaster\@example.com</webMaster> + <docs>http://backend.userland.com/rss</docs> + <category domain="http://www.dmoz.org">Reference/Libraries/Library_and_Information_Science/Technical_Services/Cataloguing/Metadata/RDF/Applications/RSS/</category> + <generator>The Superest Dooperest RSS Generator</generator> + <lastBuildDate>Mon, 02 Sep 2002 03:19:17 GMT</lastBuildDate> + <ttl>60</ttl> + + <item> + <title>News for September the Second</title> + <link>http://example.com/2002/09/02</link> + <description>other things happened today</description> + <comments>http://example.com/2002/09/02/comments.html</comments> + <author>joeuser\@example.com</author> + <pubDate>Mon, 02 Sep 2002 03:19:00 GMT</pubDate> + <guid isPermaLink="true">http://example.com/2002/09/02</guid> + <enclosure url="http://example.com/test.mp3" length="5352283" type="audio/mpeg" /> + </item> + + </channel> +</rss>); + +plan tests => 4; + +use_ok("XML::RSS"); + +my $xml = XML::RSS->new(); +isa_ok($xml,"XML::RSS"); + +eval { $xml->parse(RSS_DOCUMENT); }; +is($@,'',"Parsed RSS feed"); + +is_deeply($xml->{items}->[0]->{enclosure}, { url => "http://example.com/test.mp3", length => "5352283", type => "audio/mpeg" }, "got enclosure"); + === t/test_manifest ================================================================== --- t/test_manifest (revision 333) +++ t/test_manifest (revision 334) @@ -10,5 +10,6 @@ 2.0-permalink.t 2.0-wo-title.t encode-output.t +enclosures.t auto_add_modules.t rss2-gt-encoding.t === MANIFEST ================================================================== --- MANIFEST (revision 333) +++ MANIFEST (revision 334) @@ -41,6 +41,7 @@ t/2.0-permalink.t t/2.0-wo-title.t t/auto_add_modules.t +t/enclosures.t t/encode-output.t t/encoding.t t/load.t === lib/XML/RSS.pm ================================================================== --- lib/XML/RSS.pm (revision 333) +++ lib/XML/RSS.pm (revision 334) @@ -416,6 +416,10 @@ }; } +my %empty_ok_elements = ( + enclosure => 1, +); + sub new { my $class = shift; @@ -1487,7 +1491,7 @@ my $self = shift; my $el = shift; my %attribs = @_; - + # beginning of RSS 0.91 if ($el eq 'rss') { if (exists($attribs{version})) { @@ -1610,6 +1614,10 @@ } } } + elsif ( $empty_ok_elements{$el} and $self->current_element eq 'item' ) + { + $self->{items}->[$self->{num_items}-1]->{$el} = \%attribs; + } } sub append {
On Sat Apr 23 18:14:52 2005, guest wrote: Show quoted text
> Also a patch to implement this is available here: > http://bulknews.net/lib/archives/patches/xml-rss-enclosure.patch
Applied (r7971) - it will be part of a 1.12 bugfix release one of the next few days.