diff --git a/src/main/java/org/rometools/feed/module/mediarss/io/MediaModuleParser.java b/src/main/java/org/rometools/feed/module/mediarss/io/MediaModuleParser.java index 604cdc4..bb8a774 100644 --- a/src/main/java/org/rometools/feed/module/mediarss/io/MediaModuleParser.java +++ b/src/main/java/org/rometools/feed/module/mediarss/io/MediaModuleParser.java @@ -50,6 +50,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.rometools.utils.Integers; +import com.rometools.utils.Longs; import com.rometools.utils.Strings; import com.sun.syndication.feed.module.Module; import com.sun.syndication.io.ModuleParser; @@ -129,7 +130,7 @@ public class MediaModuleParser implements ModuleParser { } try { if (content.getAttributeValue("duration") != null) { - mc.setDuration(Long.valueOf(content.getAttributeValue("duration"))); + mc.setDuration(Longs.parseDecimal(content.getAttributeValue("duration"))); } } catch (final Exception ex) { LOG.warn("Exception parsing content tag.", ex); diff --git a/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java b/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java index 796186c..3927c6e 100644 --- a/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java +++ b/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java @@ -109,6 +109,24 @@ public class MediaModuleTest extends AbstractTestCase { } + /** + * tests parsing a decimal duration (https://github.com/rometools/rome-modules/issues/8). + * + * @throws IOException if file not found or not accessible + * @throws FeedException when the feed can't be parsed + * + */ + public void testParseDecimalDuration() throws FeedException, IOException { + + final SyndFeed feed = getSyndFeed("org/rometools/feed/module/mediarss/issue-08.xml"); + final SyndEntry entry = feed.getEntries().get(0); + final MediaEntryModule module = (MediaEntryModule) entry.getModule(MediaEntryModule.URI); + final Thumbnail[] thumbnails = module.getMetadata().getThumbnail(); + + assertThat(thumbnails, is(notNullValue())); + + } + /** * tests parsing rating without scheme (https://github.com/rometools/rome-modules/issues/12). * diff --git a/src/test/resources/org/rometools/feed/module/mediarss/issue-08.xml b/src/test/resources/org/rometools/feed/module/mediarss/issue-08.xml new file mode 100644 index 0000000..846afea --- /dev/null +++ b/src/test/resources/org/rometools/feed/module/mediarss/issue-08.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file