Skip to content

Commit

Permalink
Append media to RSS using enclosure callback to return tuples
Browse files Browse the repository at this point in the history
For use with podcast plugin, appcasts, and the like. Maybe
galleries can use this too?
  • Loading branch information
da2x committed Apr 15, 2014
1 parent 9f0bd46 commit 1d31d31
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def url_replacer(self, src, dst, lang=None):
return result

def generic_rss_renderer(self, lang, title, link, description, timeline, output_path,
rss_teasers, rss_plain, feed_length=10, feed_url=None):
rss_teasers, rss_plain, feed_length=10, feed_url=None, enclosure=None):

"""Takes all necessary data, and renders a RSS feed in output_path."""
rss_obj = rss.RSS2(
Expand Down Expand Up @@ -904,6 +904,16 @@ def generic_rss_renderer(self, lang, title, link, description, timeline, output_
if post.author(lang):
rss_obj.rss_attrs["xmlns:dc"] = "http://purl.org/dc/elements/1.1/"

""" Enclosure callback must returns tuple """
if enclosure:
download_link, download_size, download_type = enclosure(post=post)

args['enclosure'] = rss.Enclosure(
download_link,
download_size,
download_type,
)

items.append(utils.ExtendedItem(**args))

rss_obj.items = items
Expand Down

0 comments on commit 1d31d31

Please sign in to comment.