def createFeed(self, attrs): # Normalize attribute names to lower case attrs = dict([(k.lower(), v) for k, v in attrs.items()]) # get common attributes name = attrs.get('text') or attrs.get('title') if not name: return nick = attrs['nick'] = attrs.get('nick', name.lower()) # select by nickname if self.nicks and nick not in self.nicks: return # observe hours (in UTC!) unless only some feeds are requested hours = attrs.get('hours') if hours and not self.nicks and not _matchHours(hours, time.gmtime()[3]): return # create a feed instance based on the OPML type attribute kind = attrs.get('type', 'rss').lower() if kind == 'rss': uri = attrs.get('xmlurl') if not uri: return feed = RSSFeed(attrs, name, uri) elif kind == 'x-plagg-html': uri = attrs.get('htmlurl') if not uri: return feed = HTMLFeed(attrs, name, uri) elif kind == 'x-plagg-computed': uri, suite = attrs.get('htmlurl'), attrs.get('commands') if not suite: return feed = ComputedFeed(attrs, name, uri, suite) else: return feed.path = os.path.join(self.newspath, nick) # disable the cache if only some feeds are requested if self.nicks: feed.use_cache = False return feed
def method(version, method): """Display the specified API method as an RSS feed.""" params = dict(request.args) params.update({ 'filter': '-cMqQU)2Ngv7r(VTGLvhKZnEIDGH09-IxaIfPU3vLaIXPO*dlV0SQg3._npJh3Qj1ah(aRM8jjRvI_xG9OPgURzV(xF.qBi6I1C-r4h088reO*6s-cXlFwv0lvo2(n4o-CVp4K5XZtXS_jePvw2r4H', 'key': config['key'], }) data = requests.get('http://api.stackexchange.com/%s/%s' % ( version, method, ), params=params).json() type_ = types[data['type']] feed = RSSFeed( 'Stack2RSS Custom Feed', 'A custom RSS feed for the "/%s" Stack Exchange API method.' % method ) for i in data['items']: feed.append_item(**process_item(i, type_)) return feed.get_xml()
def method(version, method): """Display the specified API method as an RSS feed.""" params = dict(request.args) params.update({ 'filter': '-cMqQU)2Ngv7r(VTGLvhKZnEIDGH09-IxaIfPU3vLaIXPO*dlV0SQg3._npJh3Qj1ah(aRM8jjRvI_xG9OPgURzV(xF.qBi6I1C-r4h088reO*6s-cXlFwv0lvo2(n4o-CVp4K5XZtXS_jePvw2r4H', 'key': config['key'], }) data = requests.get('http://api.stackexchange.com/%s/%s' % ( version, method, ), params=params).json() type_ = types[data['type']] feed = RSSFeed( 'Stack2RSS Custom Feed', 'A custom RSS feed for the "/%s" Stack Exchange API method.' % method) for i in data['items']: feed.append_item(**process_item(i, type_)) return feed.get_xml()