ruby / rss

RSS reading and writing
BSD 2-Clause "Simplified" License
185 stars 36 forks source link

Allow non-formated seconds to be included as a value of the itunes:duration element #5

Closed aitor closed 5 years ago

aitor commented 5 years ago

As mentioned in ruby/rss#4 the iTunes Podcast Spec supports the use of nonformated seconds as the value for itunes:duration elements:

If you specify a single number as a value (without colons), Apple Podcasts displays the value as seconds.

source: RSS tags for Podcasts Connect

I've updated the regex used in ITunesDuration#parse to accept any string of digits and reflect the spec point in the code by calculating from the seconds the corresponding components if no colons are present.

I've followed the "be conservative in what you send, be liberal in what you accept" principle and if a maker creates a feed by speciying just seconds:

      item.itunes_duration = "315"

It will still output formatted values (eg. 05:15).

aitor commented 5 years ago

@kou check the PR… I think I've updated all the requested changes.

aitor commented 5 years ago

@kou Let me know if everything looks good now.