def add_feed(self): dialog = [ ('string', 'caption', tr('Caption'), tr('Feed Caption:'), None), ('string', 'url', tr('New Feed URL'), tr('Feed URL:'), None), ] from modules.EasyGuider import EasyDialog easy = EasyDialog.EasyDialog(self.sharewin, tr('Add Feed'), dialog) values = None if easy.ShowModal() == wx.ID_OK: values = easy.GetValue() easy.Destroy() if values: #add feed to db item, node = self.sharewin.get_cur_node() RssDb.init(Globals.rss_dbfile) f = RssDb.Feed(category_id=node['data']['id'], title=values["caption"], link=values['url']) f.commit() data = { 'type': 'rss', 'level': 'feed', 'caption': values["caption"], 'data': { 'url': values['url'], 'homeurl': '', 'save': False, 'id': f.id } } obj = self.sharewin.addnode(item, data=data) self.add_feed_ids(node['data']['id'], f.id, obj)
def import_opml(self, filename): RssDb.init(Globals.rss_dbfile) import OPML opml = OPML.parse(filename) for o in opml.outlines: c = RssDb.Category.get_by(title=o['title']) if not c: c = RssDb.Category(o['title']) c.commit() for i in o.children: f = RssDb.Feed.get_by(category_id=c.id, link=i['xmlUrl']) if f: f.title = i['title'] f.homelink = i.get('htmlUrl', '') f.description = i.get('description', '') f.commit() else: c.feeds.append( RssDb.Feed(title=i['title'], link=i['xmlUrl'], homelink=i.get('htmlUrl', ''), imagelink='', description=i.get('description', ''))) RssDb.objectstore.commit() item, node = self.sharewin.get_cur_node() self.sharewin.reset_cur_item()