def Retrieve(): noveldata = {} #print(request.form) if not 'id' in request.form: return '-1' if not 'novelname' in request.form: return '-2' url = usrlib.Search_By_ID(request.form['novelname'], request.form['id']) if url == -1: return 'Cannot_Connect' noveldata = usrlib.Get_Novel_Info(url, request.form['id']) if noveldata == -1: return 'Fail_Downoad_Info' if 'restrict' in request.form: if request.form['restrict'] == '1': local_noveldata = pickle.load( open('./novel/' + request.form['novelname'] + '/info.dat', "rb")) if 'lastread' in local_noveldata: noveldata['lastread'] = local_noveldata['lastread'] if not usrlib.Save_Content(noveldata): return 'Fail_Save_Info' return 'SUCCESS' else: if not usrlib.Save_Content(noveldata): return 'Fail_Save_Info' return 'SUCCESS' if path.isfile('./novel/' + request.form['novelname'] + '/info.dat'): return 'EXIST' if not usrlib.Save_Content(noveldata): return 'Fail_Save_Info' return 'SUCCESS'
def Search(): if request.method == 'POST': if not 'id' in request.form: rt = {"id": usrlib.Get_ID()} return jsonify(rt) #print(request.form['novelname'],request.form['id']) url = usrlib.Search_By_ID(request.form['novelname'], request.form['id']) if url == -1: rt = {"error": request.form['id'] + ' 无法连接,请检查设置或网站。'} return jsonify(rt) elif url == -2: rt = {"error": request.form['id'] + ' 没有搜索到小说。'} return jsonify(rt) noveldata = usrlib.Get_Novel_Info(url, request.form['id']) if noveldata == -1: rt = {"error": request.form['id'] + ' 获取小说错误,请重试。'} return jsonify(rt) return jsonify(noveldata) else: html = open('./webui/search.html', encoding='utf8').read() return html