Пример #1
0
    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()
Пример #2
0
    def export_opml(self, filename):
        RssDb.init(Globals.rss_dbfile)

        import OPML
        opml = OPML.OPML()
        outlines = OPML.OutlineList()
        for c in RssDb.Category.select():
            o = OPML.Outline()
            o['title'] = c.title
            outlines.add_outline(o)
            for f in c.feeds:
                d = OPML.Outline()
                d['description'] = f.description
                d['xmlUrl'] = f.link
                d['homeUrl'] = f.homelink
                d['title'] = f.title
                d['text'] = f.title
                d['version'] = 'RSS'
                d['type'] = 'rss'
                outlines.add_outline(d)
                outlines.close_outline()
            outlines.close_outline()
        opml.outlines = outlines.roots()
        opml.output(file(filename, "wb"))
Пример #3
0
    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()
Пример #4
0
__author__ = 'houjunwei'
import OPML
opml = OPML.parse('/Users/houjunwei/Downloads/rss-itnews.opml')
#1:ITNEWS 2:DATABASES
tag_id = 1
import MySQLdb

CONF={
        'user':'******',
        'passwd':'gogoreader',
        'port':5002,
        'host':'192.168.2.108',
        'db':'gogoreader',
        'charset':'utf8'
}

conn = MySQLdb.connect(**CONF)
cursor = conn.cursor()
cursor.execute('set autocommit=1')

for item in opml.outlines:
    print item['title']
    for i in item.children:
        title=i['title'].replace("\\","\\\\").replace("'","''")
        xmlurl=i['xmlUrl'].replace("\\","\\\\").replace("'","''")
        insertsql="insert ignore into links_rsssource(title,published_time,description,tag_id,url) " \
                  "values('%s',now(),'%s',%d,'%s')"%(title,title,tag_id,xmlurl)
        print insertsql
        cursor.execute(insertsql)
cursor.close()
conn.close()