feedgen is a Python library (version 1.0.0) for generating web feeds in ATOM and RSS formats, including support for podcast extensions. It is a standalone evolution of Django's `feedgenerator` module, licensed under both FreeBSD and LGPLv3+. The library maintains an active development status, with its latest stable release on December 25, 2023, and continues to be a robust tool for programmatic feed creation.
pip install feedgenVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic RSS feed (and optionally ATOM) with a few entries using `FeedGenerator`. It includes setting global feed properties like ID, title, author, and links, and then adding individual entries with their own metadata. Date fields are set with timezone information, which is crucial for proper feed parsing. Finally, it shows how to generate the feed as a pretty-printed string.
Ensure your project runs on Python 3.x. Upgrade your Python environment if necessary.
Always provide timezone-aware datetime objects, e.g., `datetime.datetime.now(datetime.timezone.utc)` or use `dateutil.parser.parse('2023-01-01T12:00:00+00:00')`.Use `fe.guid('your-unique-id-string', isPermaLink=False)` if the ID is not a permanent URL to the item. The ID should be unique to the content, not necessarily the URL.Always use `feedgen`'s methods for setting content (`fe.content()`, `fe.summary()`) which handle escaping. Validate your generated feed using online validators (e.g., W3C Feed Validator).
Ensure date strings are in a standard format (e.g., ISO 8601) and include timezone information, or pass a `datetime.datetime` object with `tzinfo` set.
Let `feedgen` handle content by passing plain strings to `fe.content()` or `fe.fe.summary()`. It will automatically escape these characters. Avoid manually constructing XML snippets within content fields.
Verify that `fg.lastBuildDate()` and `fe.published()`/`fe.updated()` are always set with timezone-aware `datetime` objects, preferably UTC, e.g., `datetime.datetime.now(datetime.timezone.utc)`.