Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ RSS
**rss/channel/description**
Podcast description (whitespace is squashed).

**rss/channel/itunes:summary**
Podcast description (whitespace is squashed).

**rss/channel/image/url**
Podcast cover art.

Expand Down
12 changes: 12 additions & 0 deletions podcastparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,25 @@ class PodcastAttr(Target):
WANT_TEXT = True

def end(self, handler, text):
if not self.overwrite and handler.get_podcast_attr(self.key):
return
handler.set_podcast_attr(self.key, self.filter_func(text))

class PodcastAttrList(Target):
WANT_TEXT = True

def end(self, handler, text):
if not self.overwrite and handler.get_podcast_attr(self.key):
return
handler.set_podcast_attr(self.key, self.filter_func(text).split(', '))


class PodcastAttrType(Target):
WANT_TEXT = True

def end(self, handler, text):
if not self.overwrite and handler.get_podcast_attr(self.key):
return
value = self.filter_func(text)
if value in ('episodic', 'serial'):
handler.set_podcast_attr(self.key, value)
Expand All @@ -104,6 +110,8 @@ class PodcastAttrFromHref(Target):
ATTRIBUTE = 'href'

def start(self, handler, attrs):
if not self.overwrite and handler.get_podcast_attr(self.key):
return
value = attrs.get(self.ATTRIBUTE)
if value:
value = urlparse.urljoin(handler.base, value)
Expand Down Expand Up @@ -732,6 +740,7 @@ def parse_pubdate(text):
'rss/channel/title': PodcastAttr('title', squash_whitespace),
'rss/channel/link': PodcastAttrRelativeLink('link'),
'rss/channel/description': PodcastAttr('description', squash_whitespace_not_nl),
'rss/channel/itunes:summary': PodcastAttr('description', squash_whitespace_not_nl, overwrite=False),
'rss/channel/podcast:funding': PodcastAttrFromUrl('funding_url'),
'rss/channel/podcast:locked': PodcastAttrExplicit('import_prohibited'),
'rss/channel/image/url': PodcastAttrRelativeLink('cover_url'),
Expand Down Expand Up @@ -843,6 +852,9 @@ def set_base(self, base):
def set_podcast_attr(self, key, value):
self.data[key] = value

def get_podcast_attr(self, key, default=None):
return self.data.get(key, default)

def set_episode_attr(self, key, value):
self.episodes[-1][key] = value

Expand Down
5 changes: 5 additions & 0 deletions tests/data/channel_description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Example Feed",
"description": "A podcast with a description field",
"episodes": []
}
6 changes: 6 additions & 0 deletions tests/data/channel_description.rss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<rss>
<channel>
<title>Example Feed</title>
<description>A podcast with a description field</description>
</channel>
</rss>
5 changes: 5 additions & 0 deletions tests/data/channel_summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Example Feed",
"description": "A podcast with a summary field",
"episodes": []
}
6 changes: 6 additions & 0 deletions tests/data/channel_summary.rss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>Example Feed</title>
<itunes:summary>A podcast with a summary field</itunes:summary>
</channel>
</rss>
5 changes: 5 additions & 0 deletions tests/data/channel_summary_and_description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Example Feed",
"description": "A podcast with a description field",
"episodes": []
}
7 changes: 7 additions & 0 deletions tests/data/channel_summary_and_description.rss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>Example Feed</title>
<description>A podcast with a description field</description>
<itunes:summary>A podcast with a summary field</itunes:summary>
</channel>
</rss>