Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (24 sloc) 1.08 KB
# Feed merger for
# This script will check the feed sources for new posts and store them in a database
# Feeds will be stores in folder sources. One file per source with relevant information.
# Database will be a sqlite
from itertools import islice
import feedparser
from config import FEEDS_TO_PROCESS
from database import database, Blog, Post
import utils
def pull_feeds():
"""Get the feeds of all blogs and write them to database."""
with database.session_scope() as session:
for blog in Blog.get_blogs(session):
feeds = feedparser.parse(blog.feed_url)
for entry in islice(feeds.entries, FEEDS_TO_PROCESS):
post = session.query(Post).filter_by(blog=blog,,
if post is None:
post = Post(blog, entry)
if __name__ == '__main__':