Example #1
0
    def POST(self):
        url = web.input(url="").url
        url = get_real_url(url)
        db = NovelDB()

        # baidu 有两种格式的url
        if url.startswith("http://tieba.baidu.com"):
            _id = re.search(r"\d+$", url).group()
            urls = [
                "http://tieba.baidu.com/p/%s" % _id,
                "http://tieba.baidu.com/f?kz=%s" % _id,
            ]
            _novel = max( db.get_novel_byurl(url) for url in urls )
        else:
            _novel = db.get_novel_byurl(url)

        if _novel:
            return simplejson.dumps({"status": "existed", "msg": "/novel/%s" % _novel.id})
        # 增加返回默认标签
        username, title, url, tag = get_thread_info(url)
        _novel = db.get_novel_byurl(url)
        if _novel:
            return simplejson.dumps({"status": "existed", "msg": "/novel/%s" % _novel.id})        
        if username and title:
            return simplejson.dumps({"status": "ok", "username": username, "title": title, "url": url, "tag": tag})
        return simplejson.dumps({"status": "error", "msg": "发生了错误,请检查地址的正确性"})
Example #2
0
 def POST(self):
     args = web.input()
     args.url = get_real_url(args.url)
     if not all((args.url, args.title, args.author)):
         return simplejson.dumps({"status": "error", "msg": "请填写必填项"})
     args.ip = self.ip
     db = NovelDB()
     if not db.add_recommend(args):
         return simplejson.dumps({"status": "error", "msg": "发生了错误,请检查您的输入"})
     return simplejson.dumps({"status": "ok"})
Example #3
0
 def POST(self):
     args = web.input()
     args.url = get_real_url(args.url)
     if not all((args.url, args.title, args.author)):
         return simplejson.dumps({"status": "error", "msg": "请填写必填项"})
     args.ip = self.ip
     db = NovelDB()
     if not db.add_recommend(args):
         return simplejson.dumps({
             "status": "error",
             "msg": "发生了错误,请检查您的输入"
         })
     return simplejson.dumps({"status": "ok"})
Example #4
0
 def GET(self):
     # 处理source
     source = web.input(source="").source
     if source:
         source = get_real_url(source)
         novel = self.db.get_novel_byurl(source)
         if novel:
             raise web.seeother("/novel/%s" % novel.id)
     tags = self.db.get_index_tags()
     return render_to_response("index", {
         "tags": tags,
         "source": source,
     })
Example #5
0
 def GET(self):
     # 处理source
     source = web.input(source="").source
     if source:
         source = get_real_url(source)
         novel = self.db.get_novel_byurl(source)
         if novel:
             raise web.seeother("/novel/%s" % novel.id)
     tags = self.db.get_index_tags()
     return render_to_response("index", {
         "tags": tags,
         "source": source,
     })
Example #6
0
 def POST(self):
     args = web.input()
     args.url = get_real_url(args.url)
     args.type = get_type_by_url(args.url)
     #        args.email = args.email or "*****@*****.**"
     args.email = ""
     args.ip = self.ip
     db = NovelDB()
     ret = db.add_novel(args)
     if ret[0] is True:
         id = ret[1]
         start_work(id)
         return simplejson.dumps({"status": "ok", "id": id})
     else:
         return simplejson.dumps({"status": "error", "msg": "发生了错误,请稍候再试"})
Example #7
0
    def POST(self):
        args = web.input()
        args.url = get_real_url(args.url)      
        args.type = get_type_by_url(args.url)
#        args.email = args.email or "*****@*****.**"
        args.email = ""
        args.ip = self.ip
        db = NovelDB()
        ret = db.add_novel(args)
        if ret[0] is True:
            id = ret[1]
            start_work(id)
            return simplejson.dumps({"status": "ok", "id": id})
        else:
            return simplejson.dumps({"status": "error", "msg": "发生了错误,请稍候再试"})
Example #8
0
    def POST(self):
        url = web.input(url="").url
        url = get_real_url(url)
        db = NovelDB()

        # baidu 有两种格式的url
        if url.startswith("http://tieba.baidu.com"):
            _id = re.search(r"\d+$", url).group()
            urls = [
                "http://tieba.baidu.com/p/%s" % _id,
                "http://tieba.baidu.com/f?kz=%s" % _id,
            ]
            _novel = max(db.get_novel_byurl(url) for url in urls)
        else:
            _novel = db.get_novel_byurl(url)

        if _novel:
            return simplejson.dumps({
                "status": "existed",
                "msg": "/novel/%s" % _novel.id
            })
        # 增加返回默认标签
        username, title, url, tag = get_thread_info(url)
        _novel = db.get_novel_byurl(url)
        if _novel:
            return simplejson.dumps({
                "status": "existed",
                "msg": "/novel/%s" % _novel.id
            })
        if username and title:
            return simplejson.dumps({
                "status": "ok",
                "username": username,
                "title": title,
                "url": url,
                "tag": tag
            })
        return simplejson.dumps({"status": "error", "msg": "发生了错误,请检查地址的正确性"})