{"id":7221,"library":"feedgen","title":"Feed Generator (ATOM, RSS, Podcasts)","description":"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.","status":"active","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/lkiesow/python-feedgen","tags":["feed","rss","atom","podcast","xml","generator"],"install":[{"cmd":"pip install feedgen","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for parsing and handling date/time information in feeds, especially for timezone awareness.","package":"python-dateutil","optional":false},{"reason":"Used for efficient XML generation and manipulation, forming the core of the feed output.","package":"lxml","optional":false}],"imports":[{"symbol":"FeedGenerator","correct":"from feedgen.feed import FeedGenerator"},{"symbol":"FeedEntry","correct":"from feedgen.entry import FeedEntry"}],"quickstart":{"code":"from feedgen.feed import FeedGenerator\nimport datetime\n\nfg = FeedGenerator()\nfg.id('http://example.com/pages/1')\nfg.title('My Example Feed')\nfg.author({'name': 'John Doe', 'email': 'john.doe@example.com'})\nfg.link(href='http://example.com', rel='alternate')\nfg.link(href='http://example.com/feed.xml', rel='self')\nfg.language('en')\nfg.description('A fantastic example feed generated by feedgen.')\nfg.lastBuildDate(datetime.datetime.now(datetime.timezone.utc))\n\n# Add an entry\nfe = fg.add_entry()\nfe.id('http://example.com/pages/1/article1')\nfe.title('First Article Title')\nfe.link(href='http://example.com/articles/1')\nfe.published(datetime.datetime(2023, 1, 10, 10, 0, 0, tzinfo=datetime.timezone.utc))\nfe.updated(datetime.datetime(2023, 1, 15, 12, 30, 0, tzinfo=datetime.timezone.utc))\nfe.summary('This is a summary of the first article.')\nfe.content('This is the full content of the first article, potentially with <b>HTML</b>.')\nfe.author({'name': 'Jane Doe', 'email': 'jane.doe@example.com'})\n\n# Add another entry\nfe2 = fg.add_entry()\nfe2.id('http://example.com/pages/1/article2')\nfe2.title('Second Article Title')\nfe2.link(href='http://example.com/articles/2')\nfe2.published(datetime.datetime(2023, 2, 1, 9, 0, 0, tzinfo=datetime.timezone.utc))\nfe2.updated(datetime.datetime(2023, 2, 5, 11, 45, 0, tzinfo=datetime.timezone.utc))\nfe2.summary('Summary of the second article.')\n\n# Generate and print the RSS feed\nprint(fg.rss_str(pretty=True).decode('utf-8'))\n\n# Generate and print the ATOM feed\n# print(fg.atom_str(pretty=True).decode('utf-8'))","lang":"python","description":"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."},"warnings":[{"fix":"Ensure your project runs on Python 3.x. Upgrade your Python environment if necessary.","message":"Version 1.0.0 removed official support for Python 2. While older versions might work, Python 2 is no longer tested or maintained.","severity":"breaking","affected_versions":"1.0.0+"},{"fix":"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')`.","message":"Date and time fields (`pubDate`, `lastBuildDate`, `published`, `updated`) *must* include timezone information for proper parsing by feed readers. Without it, readers may incorrectly interpret dates (e.g., as future dates) or repeatedly fetch content.","severity":"gotcha","affected_versions":"all"},{"fix":"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.","message":"RSS feeds require a `guid` (Global Unique Identifier) for each entry to uniquely identify it. While `feedgen` provides a `guid()` method, ensure the value is truly unique and consistent for the item across feed updates. For items that are not permalinks, set `isPermaLink=False`.","severity":"gotcha","affected_versions":"all"},{"fix":"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).","message":"Improperly formatted XML can lead to feed validation errors or prevent feed readers from parsing your content. This often happens with special characters in content or missing required fields.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"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.","cause":"Attempting to set a date string that `dateutil.parser` (used internally by feedgen) cannot fully parse, often due to non-standard format or trailing text.","error":"ValueError: unconverted data remains: ' GMT'"},{"fix":"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.","cause":"Special characters like `&`, `<`, `>` are not properly escaped in the feed content, violating XML rules.","error":"XML Syntax Error: Entity '...' not defined"},{"fix":"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)`.","cause":"This usually indicates missing or incorrect `pubDate`/`lastBuildDate` with timezone information, leading the reader to believe content is new or its update status is ambiguous.","error":"Feed reader shows old items or fetches repeatedly."}]}