From 7582e7b1d6d73e32082248e7cd468252c7d05ff7 Mon Sep 17 00:00:00 2001 From: Oli Kamer Date: Tue, 21 Apr 2020 11:48:49 +0200 Subject: [PATCH] Add tag for itunes_title --- feedgen/__main__.py | 1 + feedgen/ext/podcast_entry.py | 19 +++++++++++++++++++ tests/test_extensions/test_podcast.py | 2 ++ 3 files changed, 22 insertions(+) diff --git a/feedgen/__main__.py b/feedgen/__main__.py index 855c8a7..77da67b 100644 --- a/feedgen/__main__.py +++ b/feedgen/__main__.py @@ -104,6 +104,7 @@ def main(): fe.podcast.itunes_author('Lars Kiesow') fe.podcast.itunes_season(1) fe.podcast.itunes_episode(1) + fe.podcast.itunes_title('First podcast episode') print_enc(fg.rss_str(pretty=True)) elif arg == 'torrent': diff --git a/feedgen/ext/podcast_entry.py b/feedgen/ext/podcast_entry.py index cd746e3..2d201b5 100644 --- a/feedgen/ext/podcast_entry.py +++ b/feedgen/ext/podcast_entry.py @@ -32,6 +32,7 @@ def __init__(self): self.__itunes_summary = None self.__itunes_season = None self.__itunes_episode = None + self.__itunes_title = None def extend_rss(self, entry): '''Add additional fields to an RSS item. @@ -87,6 +88,10 @@ def extend_rss(self, entry): if self.__itunes_episode: episode = xml_elem('{%s}episode' % ITUNES_NS, entry) episode.text = str(self.__itunes_episode) + + if self.__itunes_title: + title = xml_elem('{%s}title' % ITUNES_NS, entry) + title.text = self.__itunes_title return entry def itunes_author(self, itunes_author=None): @@ -272,3 +277,17 @@ def itunes_episode(self, itunes_episode=None): if itunes_episode is not None: self.__itunes_episode = int(itunes_episode) return self.__itunes_episode + + def itunes_title(self, itunes_title=None): + '''Get or set the itunes:title value for the podcast episode. + + An episode title specific for Apple Podcasts. Don’t specify the episode + number or season number in this tag. Also, don’t repeat the title of + your show within your episode title. + + :param itunes_title: Episode title specific for Apple Podcasts + :returns: Title specific for Apple Podcast + ''' + if itunes_title is not None: + self.__itunes_title = itunes_title + return self.__itunes_title diff --git a/tests/test_extensions/test_podcast.py b/tests/test_extensions/test_podcast.py index f81f773..4b7770b 100644 --- a/tests/test_extensions/test_podcast.py +++ b/tests/test_extensions/test_podcast.py @@ -82,6 +82,7 @@ def test_podcastEntryItems(self): fe.podcast.itunes_summary('x') fe.podcast.itunes_season(1) fe.podcast.itunes_episode(1) + fe.podcast.itunes_title('Podcast Title') assert fe.podcast.itunes_author() == 'Lars Kiesow' assert fe.podcast.itunes_block() == 'x' assert fe.podcast.itunes_duration() == '00:01:30' @@ -93,6 +94,7 @@ def test_podcastEntryItems(self): assert fe.podcast.itunes_summary() == 'x' assert fe.podcast.itunes_season() == 1 assert fe.podcast.itunes_episode() == 1 + assert fe.podcast.itunes_title() == 'Podcast Title' # Check that we have the item in the resulting XML ns = {'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'}