From 14d52e501cdda9cdefd6f15d52a68663b250e783 Mon Sep 17 00:00:00 2001 From: technocake Date: Fri, 21 Jul 2017 18:53:34 +0200 Subject: [PATCH] - Added the optional itunes:summary tag within the channel element. - Wrote tests that pass. why? The itunes:summary might be useful if you want a specific description on the itunes store and a different one in other channels. (You would in that case be aditionally using the description tag). It is in most cases quite redundant, as a populated description tag will be used if there is no itunes:summary on the channel level. However in some scenarioes it could still be usefull. --- podgen/podcast.py | 17 +++++++++++++++++ podgen/tests/test_podcast.py | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/podgen/podcast.py b/podgen/podcast.py index 66ce0dc..d3e2356 100644 --- a/podgen/podcast.py +++ b/podgen/podcast.py @@ -219,6 +219,20 @@ def __init__(self, **kwargs): :RSS: itunes:block """ + self.summary = None + """The itunes store specific description of the podcast. It might be + useful if you want a specific description on the itunes store and a + different one in other channels. (You would in that case be aditionally + using the description tag). + + It is in most cases quite redundant, as a populated description tag will + be used if there is no itunes:summary on the channel level. However in + some scenarioes it could still be usefull. + + :type: :obj:`str` + :RSS: itunes:summary + """ + self.__category = None self.__image = None @@ -455,6 +469,9 @@ def _create_rss(self): explicit = etree.SubElement(channel, '{%s}explicit' % ITUNES_NS) explicit.text = "yes" if self.explicit else "no" + if self.summary: + summary = etree.SubElement(channel, '{%s}summary' % ITUNES_NS) + summary.text = self.summary if self.__cloud: cloud = etree.SubElement(channel, 'cloud') cloud.attrib['domain'] = self.__cloud.get('domain') diff --git a/podgen/tests/test_podcast.py b/podgen/tests/test_podcast.py index a256db6..71a86aa 100644 --- a/podgen/tests/test_podcast.py +++ b/podgen/tests/test_podcast.py @@ -42,6 +42,7 @@ def setUp(self): self.description = 'This is a cool feed!' self.subtitle = 'Coolest of all' + self.summary = 'This is a cool podcast description that is unique for itunes' self.language = 'en' self.cloudDomain = 'example.com' @@ -74,6 +75,7 @@ def setUp(self): fg.name = self.name fg.website = self.website fg.description = self.description + fg.summary = self.summary fg.subtitle = self.subtitle fg.language = self.language fg.cloud = (self.cloudDomain, self.cloudPort, self.cloudPath, @@ -105,6 +107,7 @@ def test_constructor(self): name=self.name, website=self.website, description=self.description, + summary=self.summary, subtitle=self.subtitle, language=self.language, cloud=(self.cloudDomain, self.cloudPort, self.cloudPath, @@ -141,6 +144,7 @@ def test_baseFeed(self): assert fg.website == self.website assert fg.description == self.description + assert fg.summary == self.summary assert fg.subtitle == self.subtitle assert fg.language == self.language @@ -214,6 +218,8 @@ def checkRssString(self, rssString): assert channel.find("title").text == self.name assert channel.find("description").text == self.description + assert channel.find("{%s}summary" % self.nsItunes).text == \ + self.summary assert channel.find("{%s}subtitle" % self.nsItunes).text == \ self.subtitle assert channel.find("link").text == self.website