From d8af317edda20462c83880c35c5daebf23d13454 Mon Sep 17 00:00:00 2001 From: Ryan Brunner Date: Tue, 4 Jul 2023 11:08:09 -0400 Subject: [PATCH] Add ITunes Title The itunes: namespace and Apple Podcasts support a `` element. This is mostly redundant with ``, but is intended to be used to strip out episode and season numbers when using `<itunes:episode>` and `<itunes:season>`. This adds support for `<itunes:title>` on RSS items through the `item.itunes_item` method. Reference for including itunes:title: https://help.omnystudio.com/en/articles/3219724-setting-a-separate-itunes-title-and-title-in-your-rss-feed-for-episode-titles Sample feed including an itunes:title: https://raw.githubusercontent.com/bcomnes/jsonfeed-to-rss/master/reference/podcast.xml --- lib/rss/itunes.rb | 1 + test/test-itunes.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/rss/itunes.rb b/lib/rss/itunes.rb index 87178b8..58c48d3 100644 --- a/lib/rss/itunes.rb +++ b/lib/rss/itunes.rb @@ -264,6 +264,7 @@ def append_features(klass) ["image", :attribute, "href"], ["season", :positive_integer], ["episode", :positive_integer], + ["title"] ] class ITunesImage < Element diff --git a/test/test-itunes.rb b/test/test-itunes.rb index 10e338d..0c6fc64 100644 --- a/test/test-itunes.rb +++ b/test/test-itunes.rb @@ -117,6 +117,12 @@ def test_episode end end + def test_title + assert_itunes_title(%w(items last)) do |content, xmlns| + make_rss20(make_channel20(make_item20(content)), xmlns) + end + end + private def itunes_rss20_parse(content, &maker) xmlns = {"itunes" => "http://www.itunes.com/dtds/podcast-1.0.dtd"} @@ -133,6 +139,15 @@ def assert_itunes_author(readers, &rss20_maker) end end + def assert_itunes_title(readers, &rss20_maker) + _wrap_assertion do + title = "Interview with John Lennon" + rss20 = itunes_rss20_parse(tag("itunes:title", title), &rss20_maker) + target = chain_reader(rss20, readers) + assert_equal(title, target.itunes_title) + end + end + def _assert_itunes_block(value, boolean_value, readers, &rss20_maker) rss20 = itunes_rss20_parse(tag("itunes:block", value), &rss20_maker) target = chain_reader(rss20, readers)