Exemple #1
0
 def handle_result(self, rpc, url):
     try:
         result = rpc.get_result()
         if result.status_code == 200:
             rsslist = []
             realrss = set()
             for rssText in result.content.split("\r\n"):
                 if rssText:
                     rss = RSS()
                     r = rssText.split("$$")
                     if len(r) >= 2:
                         rss.code = r[0]
                         realrss.add(rss.code)
                         rss.rssUrl = r[1]
                         if RSS().all().filter("code =", rss.code).filter("rssUrl =", rss.rssUrl).count() == 0:
                             logging.error(rss.code + "||" + rss.rssUrl)
                             r = RSS().all().filter("code =", rss.code).fetch(1)
                             if r:
                                 logging.error(rss.code + "||" + rss.rssUrl)
                                 clist = Contents().all().filter("rss =", r[0])
                                 for c in clist:
                                     c.status = "1"
                                     c.put()
                                 db.delete(r)
                             rsslist.append(rss)
             db.put(rsslist)
             deleteRss = []
             for dbrss in RSS().all():
                 if dbrss.code not in realrss:
                     deleteRss.append(dbrss)
             db.delete(deleteRss)
     except Exception, e:
         logging.error("0000" + str(e) + url)
Exemple #2
0
 def post(self):
     rssUrl = self.request.get("rssUrl").strip()
     if RSS.all().filter("rssUrl =", rssUrl).count() == 0 and rssUrl:
         rss = RSS()
         rss.rssUrl = rssUrl
         rss.put()
     self.render("templates/index.html", {"RSSs": RSS.all()})