diff --git a/feedgen/__main__.py b/feedgen/__main__.py index 77da67b..8388dbc 100644 --- a/feedgen/__main__.py +++ b/feedgen/__main__.py @@ -105,6 +105,7 @@ def main(): fe.podcast.itunes_season(1) fe.podcast.itunes_episode(1) fe.podcast.itunes_title('First podcast episode') + fe.podcast.itunes_episode_type('full') 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 2d201b5..2d60c2d 100644 --- a/feedgen/ext/podcast_entry.py +++ b/feedgen/ext/podcast_entry.py @@ -33,6 +33,7 @@ def __init__(self): self.__itunes_season = None self.__itunes_episode = None self.__itunes_title = None + self.__itunes_episode_type = None def extend_rss(self, entry): '''Add additional fields to an RSS item. @@ -92,6 +93,10 @@ def extend_rss(self, entry): if self.__itunes_title: title = xml_elem('{%s}title' % ITUNES_NS, entry) title.text = self.__itunes_title + + if self.__itunes_episode_type in ('full', 'trailer', 'bonus'): + episode_type = xml_elem('{%s}episodeType' % ITUNES_NS, entry) + episode_type.text = self.__itunes_episode_type return entry def itunes_author(self, itunes_author=None): @@ -291,3 +296,26 @@ def itunes_title(self, itunes_title=None): if itunes_title is not None: self.__itunes_title = itunes_title return self.__itunes_title + + def itunes_episode_type(self, itunes_episode_type=None): + '''Get or set the itunes:episodeType value of the item. This tag should + be used to indicate the episode type. + The three values for this tag are "full", "trailer" and "bonus". + + If an episode is a trailer or bonus content, use this tag. + + Specify full when you are submitting the complete content of your show. + Specify trailer when you are submitting a short, promotional piece of + content that represents a preview of your current show. + Specify bonus when you are submitting extra content for your show (for + example, behind the scenes information or interviews with the cast) or + cross-promotional content for another show. + + :param itunes_episode_type: The episode type + :returns: type of the episode. + ''' + if itunes_episode_type is not None: + if itunes_episode_type not in ('full', 'trailer', 'bonus'): + raise ValueError('Invalid value for episodeType tag') + self.__itunes_episode_type = itunes_episode_type + return self.__itunes_episode_type diff --git a/tests/test_extensions/test_podcast.py b/tests/test_extensions/test_podcast.py index 4b7770b..cb7085e 100644 --- a/tests/test_extensions/test_podcast.py +++ b/tests/test_extensions/test_podcast.py @@ -83,6 +83,7 @@ def test_podcastEntryItems(self): fe.podcast.itunes_season(1) fe.podcast.itunes_episode(1) fe.podcast.itunes_title('Podcast Title') + fe.podcast.itunes_episode_type('full') assert fe.podcast.itunes_author() == 'Lars Kiesow' assert fe.podcast.itunes_block() == 'x' assert fe.podcast.itunes_duration() == '00:01:30' @@ -95,6 +96,7 @@ def test_podcastEntryItems(self): assert fe.podcast.itunes_season() == 1 assert fe.podcast.itunes_episode() == 1 assert fe.podcast.itunes_title() == 'Podcast Title' + assert fe.podcast.itunes_episode_type() == 'full' # Check that we have the item in the resulting XML ns = {'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'}