def AddBookEpsPicInfoBack(self, backData): # 此处在线程中加载后续分页 TODO 分页太多时会导致太慢 try: r = backData.res bookId = backData.req.bookId epsId = backData.req.epsId bookInfo = self.books.get(bookId) epsInfo = bookInfo.eps[epsId - 1] page = r.data['pages']["page"] pages = r.data['pages']["pages"] limit = r.data['pages']["limit"] # 重新初始化 # if page == 1: # del epsInfo.pics[:] for i, data in enumerate(r.data['pages']['docs']): index = (page - 1) * limit + i if len(epsInfo.pics) > index: picInfo = epsInfo.pics[index] else: picInfo = Picture() epsInfo.pics.append(picInfo) ToolUtil.ParseFromData(picInfo, data['media']) loadPage = int((len(epsInfo.pics) - 1) / limit + 1) nextPage = page + 1 # 如果已经有了,则从最后那一页加载起就可以了 if loadPage > nextPage: nextPage = loadPage if nextPage <= pages: self.server.Send(req.GetComicsBookOrderReq( bookId, epsId, nextPage), bakParam=backData.bakParam, isASync=False) return Status.WaitLoad return Status.Ok except Exception as es: import sys cur_tb = sys.exc_info()[ 2] # return (exc_type, exc_value, traceback) e = sys.exc_info()[1] Log.Error(cur_tb, e) return Status.Error
def _DownloadBoos(self, bookId): bookInfo = self.books.get(bookId) if not bookInfo: return for index, eps in enumerate(bookInfo.eps): if eps.pics: continue page = 0 pages = 1 while page < pages: r = self.server.Send( req.GetComicsBookOrderReq(bookId, index + 1, page + 1)) page = r.data['pages']["page"] pages = r.data['pages']["pages"] for data in r.data['pages']['docs']: epsInfo = Picture() ToolUtil.ParseFromData(epsInfo, data['media']) eps.pics.append(epsInfo) pass
def AddBookEpsPicInfo(self, bookId, index=1, bakParam=0): page = 1 self.server.Send(req.GetComicsBookOrderReq(bookId, index, page), bakParam=bakParam)