Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Feedgen PPG plugin example
from feedgen.ext.base import BaseExtension
from feedgen.feed import FeedGenerator
fg = FeedGenerator()
class PpgExtension(BaseExtension):
__frequency = None
__daysLive = None
def extend_rss(self, rss_feed):
NS = 'http://bbc.co.uk/2009/01/ppgRss'
channel = rss_feed[0]
if self.__frequency or self.__daysLive:
seriesDetails = etree.SubElement(channel, f'{{{NS}}}seriesDetails')
if self.__frequency :
seriesDetails.set('frequency', self.__frequency)
if self.__daysLive:
seriesDetails.set('daysLive', self.__daysLive)
return rss_feed
def extend_ns(self):
return {'ppg': 'http://bbc.co.uk/2009/01/ppgRss'}
def seriesDetails(self, frequency='oneoff', daysLive='-1'):
self.__frequency = frequency
self.__daysLive = daysLive
fg.register_extension("ppg", PpgExtension)
fg.ppg.seriesDetails(frequency='oneoff', daysLive='-1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.