Ejemplo n.º 1
0
def rss_po():
    rss_feed_new = set()
    rss_feed = set()

    for pre in RssPo.where(state=RSS_PRE_PO).order_by('id desc'):
        #print pre.id, pre.title, pre.link
        po = htm2po_by_po(pre)
        if po:
            rss_id = pre.rss_id
            #print po.id
            if rss_id not in rss_feed:
                rss_feed.add(rss_id)
                if RssPo.where(state=RSS_POED, rss_id=rss_id).count():
                    rss_feed_new.add(rss_id)

            if rss_id in rss_feed_new:
                po.feed_new()
            elif po.user_id: #批量导入的文章, 标注状态位, 就不发回复提醒邮件了
                po_pos_set(po.user_id, po)

        pre.state = RSS_POED
        pre.save()

    for pre in RssPo.where(state=RSS_RT_PO):
        po = htm2po_by_po(pre)
        if po:
            po.feed_new()
            feed_rt(0, po.id)
        pre.state = RSS_POED
        pre.save()
Ejemplo n.º 2
0
def rss_po():
    rss_feed_new = set()
    rss_feed = set()

    for pre in RssPo.where(state=RSS_PRE_PO).order_by("id desc"):
        # print pre.id, pre.title, pre.link
        po = htm2po_by_po(pre)
        if po:
            rss_id = pre.rss_id
            # print po.id
            if rss_id not in rss_feed:
                rss_feed.add(rss_id)
                if RssPo.where(state=RSS_POED, rss_id=rss_id).count():
                    rss_feed_new.add(rss_id)

            if rss_id in rss_feed_new:
                po.feed_new()
            elif po.user_id:  # 批量导入的文章, 标注状态位, 就不发回复提醒邮件了
                po_pos_set(po.user_id, po)

        pre.state = RSS_POED
        pre.save()

    for pre in RssPo.where(state=RSS_RT_PO):
        po = htm2po_by_po(pre)
        if po:
            po.feed_new()
            feed_rt(0, po.id)
        pre.state = RSS_POED
        pre.save()
Ejemplo n.º 3
0
def rss_feed_update(res, id, user_id, limit=None):
    rss = Rss.mc_get(id)
    zsite = Zsite.mc_get(user_id)
    for count, i in enumerate(res):
        if limit:
            if count > limit:
                break
        r = link_title_uid_txt(i)
        if not r:
            continue
        link, title, rss_uid, txt = r

        if '相片: ' in title:
            continue

        title_txt = '%s\n%s' % (title, txt)
        if duplicator_rss.txt_is_duplicate(title_txt):
            continue

        #print title, link, duplicator_rss.txt_is_duplicate(title_txt)

        if rss.auto:
            state = RSS_PRE_PO
        else:
            state = RSS_UNCHECK

        c = RssPo.raw_sql(
            'insert into rss_po (user_id,rss_id,rss_uid,title,txt,link,state) values (%s,%s,%s,%s,%s,%s,%s) on duplicate key update title=%s , txt=%s ',
            user_id, id, rss_uid, title, txt, link, state, title, txt)
        duplicator_rss.set_record(title_txt, c.lastrowid)
Ejemplo n.º 4
0
    def post(self, id):
        id = int(id)
        txt = self.get_argument('txt', None)
        rt = self.get_argument('rt', None)
        title = self.get_argument('name', None)
        sync = self.get_argument('sync', None)
        po = RssPo.mc_get(id)
        po.txt = txt
        next = self.get_argument('next', None) or '/rss/index'
        if rt:
            po.state = RSS_RT_PO
        else:
            po.state = RSS_PRE_PO
        site = self.get_argument('site', None)
        if site:
            po.site_id = site
        if title:
            po.title = title
        po.save()

        if sync:
            site_sync_new(id)
        else:
            site_sync_rm(id)

        self.redirect(next)
Ejemplo n.º 5
0
def rss_feed_update(res, id, user_id, limit=None):
    rss = Rss.mc_get(id)
    zsite = Zsite.mc_get(user_id)
    for count , i in enumerate(res):
        if limit:
            if count > limit:
                break
        r = link_title_uid_txt(i)
        if not r:
            continue
        link, title, rss_uid, txt = r

        if '相片: ' in title:
            continue


        title_txt = '%s\n%s'%(title, txt)
        if duplicator_rss.txt_is_duplicate(title_txt):
            continue

        #print title, link, duplicator_rss.txt_is_duplicate(title_txt)

        if rss.auto:
            state = RSS_PRE_PO
        else:
            state = RSS_UNCHECK

        c = RssPo.raw_sql(
'insert into rss_po (user_id,rss_id,rss_uid,title,txt,link,state) values (%s,%s,%s,%s,%s,%s,%s) on duplicate key update title=%s , txt=%s ',
user_id, id, rss_uid, title, txt, link, state,
title, txt
        )
        duplicator_rss.set_record(title_txt, c.lastrowid)
Ejemplo n.º 6
0
 def post(self, state=RSS_UNCHECK, n=1):
     ids = self.get_argument('id').split()
     if ids:
         for id in ids:
             rss = RssPo.mc_get(id)
             if rss and rss.state == RSS_UNCHECK:
                 rss.state = RSS_RM
                 rss.save()
     self.get()
Ejemplo n.º 7
0
from model.po import Po

#o = Zsite.get(name='kvm')
#if o:
#    o.name = ''
#    o.save()
#
#for i in Zsite.where(cid=CID_TAG):
#    if "/" not in i.name:
#        from model.po_tag import _tag_alias_new
#        _tag_alias_new(i.id, i.name) 
#        print i.id, i.name


for i in ormiter(RssPoId, "user_cid=%s"%CID_USER):
    po = Po.mc_get(i.po_id)
    rss_po = RssPo.get(i.rss_po_id)
    print i.id,
    if po and rss_po:
        po.rid = rss_po.rss_id
        po.save()
        print po.id, rss_po.rss_id



if __name__ == "__main__":
    pass



Ejemplo n.º 8
0
 def get(self, id):
     pre = RssPo.mc_get(id)
     if pre:
         pre.state = RSS_RM
         pre.save()
     self.redirect('/rss/index')
Ejemplo n.º 9
0
 def get(self, id):
     next = self.request.headers.get('Referer', '')
     po = RssPo.get(id)
     self.render(next=next, po=po)