Skip to content

Commit

Permalink
Add itunes tag type <itunes:type>
Browse files Browse the repository at this point in the history
  • Loading branch information
olikami committed Apr 21, 2020
1 parent 50d2b27 commit 7ecc1e0
Show file tree
Hide file tree
Showing 3 changed files with 36 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 @@ -100,6 +100,7 @@ def main():
fg.podcast.itunes_summary('Lorem ipsum dolor sit amet, consectetur ' +
'adipiscing elit. Verba tu fingas et ea ' +
'dicas, quae non sentias?')
fg.podcast.itunes_type('episodic')
fe.podcast.itunes_author('Lars Kiesow')
fe.podcast.itunes_season(1)
fe.podcast.itunes_episode(1)
Expand Down
33 changes: 33 additions & 0 deletions feedgen/ext/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self):
self.__itunes_owner = None
self.__itunes_subtitle = None
self.__itunes_summary = None
self.__itunes_type = None

def extend_ns(self):
return {'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'}
Expand Down Expand Up @@ -96,6 +97,10 @@ def extend_rss(self, rss_feed):
summary = xml_elem('{%s}summary' % ITUNES_NS, channel)
summary.text = self.__itunes_summary

if self.__itunes_type:
type = xml_elem('{%s}type' % ITUNES_NS, channel)
type.text = self.__itunes_type

return rss_feed

def itunes_author(self, itunes_author=None):
Expand Down Expand Up @@ -318,6 +323,34 @@ def itunes_summary(self, itunes_summary=None):
self.__itunes_summary = itunes_summary
return self.__itunes_summary

def itunes_type(self, itunes_type=None):
'''Get or set the itunes:type value of the podcast. This tag should
be used to indicate the type of your podcast.
The two values for this tag are "episodic" and "serial".
If your show is Serial you must use this tag.
Specify episodic when episodes are intended to be consumed without any
specific order. Apple Podcasts will present newest episodes first and
display the publish date (required) of each episode. If organized into
seasons, the newest season will be presented first - otherwise,
episodes will be grouped by year published, newest first.
Specify serial when episodes are intended to be consumed in sequential
order. Apple Podcasts will present the oldest episodes first and
display the episode numbers (required) of each episode. If organized
into seasons, the newest season will be presented first and
<itunes:episode> numbers must be given for each episode.
:param itunes_type: The type of the podcast
:returns: type of the pdocast.
'''
if itunes_type is not None:
if itunes_type not in ('episodic', 'serial'):
raise ValueError('Invalid value for type tag')
self.__itunes_type = itunes_type
return self.__itunes_type

_itunes_categories = {
'Arts': [
'Design', 'Fashion & Beauty', 'Food', 'Literature',
Expand Down
2 changes: 2 additions & 0 deletions tests/test_extensions/test_podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ def test_podcastItems(self):
fg.podcast.itunes_image('x.png')
fg.podcast.itunes_subtitle('x')
fg.podcast.itunes_summary('x')
fg.podcast.itunes_type('episodic')
assert fg.podcast.itunes_author() == 'Lars Kiesow'
assert fg.podcast.itunes_block() == 'x'
assert fg.podcast.itunes_complete() == 'no'
assert fg.podcast.itunes_explicit() == 'no'
assert fg.podcast.itunes_image() == 'x.png'
assert fg.podcast.itunes_subtitle() == 'x'
assert fg.podcast.itunes_summary() == 'x'
assert fg.podcast.itunes_type() == 'episodic'

# 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 7ecc1e0

Please sign in to comment.