Python library for generating web feeds in both ATOM and RSS formats with extensible support for specialized feed formats
npx @tessl/cli install tessl/pypi-feedgen@1.0.0A comprehensive Python library for generating web feeds in both ATOM and RSS formats. feedgen provides a clean, object-oriented API for creating standards-compliant feeds with full extensibility support through a plugin system, making it suitable for web applications, content management systems, blog platforms, and any application requiring standardized feed output.
pip install feedgenlxml, python-dateutilfrom feedgen.feed import FeedGenerator
from feedgen.entry import FeedEntryfrom feedgen.feed import FeedGenerator
# Create a feed generator
fg = FeedGenerator()
# Set required feed metadata
fg.id('http://example.com/feed')
fg.title('My Example Feed')
fg.author({'name': 'John Doe', 'email': 'john@example.com'})
fg.link(href='http://example.com', rel='alternate')
fg.description('This is an example feed')
fg.language('en')
# Add an entry
fe = fg.add_entry()
fe.id('http://example.com/entry/1')
fe.title('First Entry')
fe.description('This is the first entry in the feed')
fe.link(href='http://example.com/entry/1')
# Generate feeds
atom_feed = fg.atom_str(pretty=True) # Get ATOM feed as string
rss_feed = fg.rss_str(pretty=True) # Get RSS feed as string
# Write to files
fg.atom_file('feed.atom')
fg.rss_file('feed.rss')feedgen uses an object-oriented design with two main classes:
The extension system allows loading specialized functionality for different feed types while maintaining compatibility with standard ATOM and RSS formats.
Core functionality for creating and configuring web feeds, setting metadata, and generating ATOM/RSS output formats.
class FeedGenerator:
def __init__(self): ...
def atom_str(self, pretty=False, extensions=True, encoding='UTF-8', xml_declaration=True): ...
def atom_file(self, filename, extensions=True, pretty=False, encoding='UTF-8', xml_declaration=True): ...
def rss_str(self, pretty=False, extensions=True, encoding='UTF-8', xml_declaration=True): ...
def rss_file(self, filename, extensions=True, pretty=False, encoding='UTF-8', xml_declaration=True): ...Methods for setting and retrieving feed-level metadata including titles, descriptions, authors, links, categories, and other feed properties.
def title(self, title=None): ...
def id(self, id=None): ...
def author(self, author=None, replace=False, **kwargs): ...
def link(self, link=None, replace=False, **kwargs): ...
def description(self, description=None): ...
def subtitle(self, subtitle=None): ...
def language(self, language=None): ...
def cloud(self, domain=None, port=None, path=None, registerProcedure=None, protocol=None): ...
def generator(self, generator=None, version=None, uri=None): ...Functionality for creating, managing, and configuring individual feed entries with their metadata, content, and links.
class FeedEntry:
def title(self, title=None): ...
def id(self, id=None): ...
def content(self, content=None, src=None, type=None): ...
def link(self, link=None, replace=False, **kwargs): ...
def summary(self, summary=None, type=None): ...
def published(self, published=None): ...Extensible plugin architecture supporting specialized feed formats including podcasts (iTunes), Dublin Core metadata, GeoRSS, media RSS, syndication, and BitTorrent feeds.
def load_extension(self, name, atom=True, rss=True): ...
def register_extension(self, namespace, extension_class_feed=None,
extension_class_entry=None, atom=True, rss=True): ...Available built-in extensions: podcast, dc, syndication, torrent, geo, media
# Author/Contributor structure
AuthorDict = {
'name': str, # Required: Author name
'email': str, # Optional: Email address
'uri': str # Optional: Author URI/website
}
# Link structure
LinkDict = {
'href': str, # Required: Link URL
'rel': str, # Optional: Link relationship ('alternate', 'self', etc.)
'type': str, # Optional: MIME type
'title': str, # Optional: Link title
'length': str # Optional: Content length
}
# Category structure
CategoryDict = {
'term': str, # Required: Category term
'scheme': str, # Optional: Category scheme/taxonomy URL
'label': str # Optional: Human-readable label
}
# Cloud structure (RSS only)
CloudDict = {
'domain': str, # Required: Domain where webservice is found
'port': int, # Optional: Port webservice listens to
'path': str, # Optional: Path of webservice
'registerProcedure': str, # Optional: Procedure to call
'protocol': str # Optional: 'HTTP-POST', 'XML-RPC', or 'SOAP 1.1'
}
# Generator structure
GeneratorDict = {
'generator': str, # Required: Software name
'version': str, # Optional: Software version (ATOM only)
'uri': str # Optional: Software URI (ATOM only)
}