Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Manipulate :epkg:`RSS` streams.
4"""
5import os
6from ..rss.rss_helper import enumerate_rss_merge, to_rss, to_html
9def compile_rss_blogs(links, url, description,
10 template=None, title="BLOG",
11 author="AUTHOR", keywords="blog,python",
12 out_html="index.html", out_rss="rssfile.xml",
13 validate=None, fLOG=print):
14 """
15 Compiles multiple blogs in one single blog. Uses
16 :epkg:`RSS` files.
18 :param links: list of urls of blogs to merge
19 :param url: publishing url
20 :param description: description of the aggregation
21 :param title: title of the aggregation
22 :param author: author of the aggregation
23 :param keywords: keywords for the blog post
24 :param template: change the template for the blog aggregation
25 :param out_html: output :epkg:`HTML`
26 :param out_rss: output :epkg:`RSS`
27 :param validate: None or a function to validate a blog post,
28 ``validate(blog: BlogPost) -> bool``
29 :param fLOG: logging function
30 """
31 collect = []
32 for i, blog in enumerate(
33 enumerate_rss_merge(
34 links, title=title, min_size=None)):
35 fLOG("[compile_rss_blogs] reading blog {0}: {1} - '{2}'".format(
36 i, blog.pubDate, blog.link))
37 if validate in (None, '') or validate(blog):
38 collect.append(blog)
40 fLOG("[compile_rss_blogs] create '{0}'".format(out_rss))
41 rss = to_rss(collect, url, description)
42 with open(out_rss, "w", encoding="utf-8") as f:
43 f.write(rss)
45 fLOG("[compile_rss_blogs] create '{0}'".format(out_html))
46 html = to_html(collect, template=template, title=title,
47 author=author, keywords=keywords,
48 header=description, rssfile=os.path.split(out_rss)[-1])
49 with open(out_html, "w", encoding="utf-8") as f:
50 f.write(html)