def update_error(bid): data = json.loads(request.data) assert data, 'no data...' latest_chapter = data.get('latest_chapter') crawler = data.get('crawler') log = UpdateLog.add(bid, 0, crawler, type=FAILED, latest_chapter=latest_chapter) return jsonify(status='success', log=log.id)
def update_book(bid): data = json.loads(request.data) assert data, 'no data...' chapter = data.get('chapter') crawler = data.get('crawler', '') title = chapter.get('title', '') type = chapter.get('type', 'text') if type == 'text': content = chapter.get('content', '') elif type == 'image': content = '' chapter = Chapter.add(bid, title, content) log = UpdateLog.add(bid, chapter.id, crawler) return jsonify(status='success', log=log.id)