Skip to content

Commit

Permalink
Add episodeType tag <itunes:episodeType>
Browse files Browse the repository at this point in the history
  • Loading branch information
olikami committed Apr 21, 2020
1 parent 493bfd9 commit 2777ee9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions feedgen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
28 changes: 28 additions & 0 deletions feedgen/ext/podcast_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions tests/test_extensions/test_podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'}
Expand Down

0 comments on commit 2777ee9

Please sign in to comment.