From d6646c4258764f0ec4de59ab553d2e1b4f405fb6 Mon Sep 17 00:00:00 2001 From: Mike Crowe Date: Thu, 5 Aug 2021 06:05:00 -0400 Subject: [PATCH] feat: adding itunes:type to podcast extension --- feedgen/__main__.py | 1 + feedgen/ext/podcast.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/feedgen/__main__.py b/feedgen/__main__.py index abc0737..91dcf76 100644 --- a/feedgen/__main__.py +++ b/feedgen/__main__.py @@ -97,6 +97,7 @@ def main(): fg.podcast.itunes_complete('no') fg.podcast.itunes_new_feed_url('http://example.com/new-feed.rss') fg.podcast.itunes_owner('John Doe', 'john@example.com') + fg.podcast.itunes_type('episodic') fg.podcast.itunes_summary('Lorem ipsum dolor sit amet, consectetur ' + 'adipiscing elit. Verba tu fingas et ea ' + 'dicas, quae non sentias?') diff --git a/feedgen/ext/podcast.py b/feedgen/ext/podcast.py index 4c7eb0b..159af21 100644 --- a/feedgen/ext/podcast.py +++ b/feedgen/ext/podcast.py @@ -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'} @@ -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: + subtitle = xml_elem('{%s}type' % ITUNES_NS, channel) + subtitle.text = self.__itunes_type + return rss_feed def itunes_author(self, itunes_author=None): @@ -318,6 +323,33 @@ 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 for the podcast. + If your show is Serial you must use this tag. + + Its values can be one of the following: + + Episodic (default). 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. + + Serial. 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 numbers + must be given for each episode. + + :param itunes_type: Type of show. + :returns: Type of show. + ''' + if itunes_type is not None: + if itunes_type not in ('episodic', 'serial'): + raise ValueError('Invalid value for complete tag') + self.__itunes_type = itunes_type + return self.__itunes_type + _itunes_categories = { 'Arts': [ 'Design', 'Fashion & Beauty', 'Food', 'Literature',