From: Simon Wistow Date: Mon, 24 Nov 2008 00:47:26 +0000 (+0000) Subject: Add enclosure code. X-Git-Tag: v0.42~2^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FXML-Feed.git;a=commitdiff_plain;h=af6b00a4ce8ac8a444e04599af9b1b4b6b198162 Add enclosure code. --- diff --git a/lib/XML/Feed/Format/Atom.pm b/lib/XML/Feed/Format/Atom.pm index 4846947..071e9f7 100644 --- a/lib/XML/Feed/Format/Atom.pm +++ b/lib/XML/Feed/Format/Atom.pm @@ -287,4 +287,16 @@ sub long { } } + +sub add_enclosure { + my($entry, $enclosure) = @_; + my $link = XML::Atom::Link->new; + $link->rel('enclosure'); + $link->type($enclosure->type); + $link->href($enclosure->url); + $link->length($enclosure->length); + $entry->{entry}->add_link($link); +}; + + 1; diff --git a/lib/XML/Feed/Format/RSS.pm b/lib/XML/Feed/Format/RSS.pm index b9f29f8..c5c11b7 100644 --- a/lib/XML/Feed/Format/RSS.pm +++ b/lib/XML/Feed/Format/RSS.pm @@ -324,5 +324,15 @@ sub long { } } +sub add_enclosure { + my($entry, $enclosure) = @_; + $entry->{entry}->{enclosure} = XML::RSS::LibXML::MagicElement->new( + attributes => { + url => $enclosure->{url}, + type => $enclosure->{type}, + length => $enclosure->{length} + }, + ); +} 1;