How extensions work in FeedGenerator
mainExtensions allow you to include additional data in the XML structure (e.g., Podcast metadata).
Loading Extensions
Use fg.load_extension(name, atom=True, rss=True) to load an extension. This looks for a file named {name}.py and expects a class named {Name}Extension (e.g., someext looks for SomextExtension). It also attempts to load a {Name}EntryExtension for individual entries.
atomandrssflags (defaultTrue) control whether the extension applies to those formats.- You can load an extension for a specific
FeedEntryby callingload_extension(...)on the entry object. - To temporarily disable all extensions during generation, call the generation method with
extensions=False(e.g.,fg.rss_str(extensions=False)).
Custom Extensions
If your extension classes are already defined in your code, use register_extension(feed_ext_class, entry_ext_class) instead of loading from a file.
# Loading from a file
fg.load_extension('someext', atom=True, rss=True)
# Using a custom class directly
fg.register_extension(MyFeedExtension, MyEntryExtension)