Skip to content

Commit

Permalink
Add tag for itunes_title <itunes:title>
Browse files Browse the repository at this point in the history
  • Loading branch information
olikami committed Apr 21, 2020
1 parent 7ecc1e0 commit 7582e7b
Show file tree
Hide file tree
Showing 3 changed files with 22 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 @@ -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':
Expand Down
19 changes: 19 additions & 0 deletions feedgen/ext/podcast_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions tests/test_extensions/test_podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'}
Expand Down

0 comments on commit 7582e7b

Please sign in to comment.