def AddBookInfosBack(self, msg=""): if msg != Status.Ok: self.SetStatu(self.Error) return else: book = BookMgr().books.get(self.bookId) self.title = book.title self.savePath = os.path.join(os.path.join(config.SavePath, config.SavePathDir), ToolUtil.GetCanSaveName(self.title)) self.savePath = os.path.join(self.savePath, "原图") self.convertPath = os.path.join(os.path.join(config.SavePath, config.SavePathDir), ToolUtil.GetCanSaveName(self.title)) self.convertPath = os.path.join(self.convertPath, "waifu2x") self.AddBookEpsInfos() return
def AddConvert(self): savePath = os.path.join(self.parent.savePath, ToolUtil.GetCanSaveName(self.epsTitle)) filePath = os.path.join( savePath, "{:04}.{}".format(self.curPreConvertId + 1, "jpg")) if not os.path.isfile(filePath): self.status = DownloadInfo.NotFound self.parent.SetConvertStatu(self.status) return isConvertNext = True while self.curPreConvertId < self.picCnt: if os.path.isfile(self.curConvertPath): self.curPreConvertId += 1 else: isConvertNext = False f = open(filePath, "rb") data = f.read() f.close() w, h = ToolUtil.GetPictureSize(data) model = ToolUtil.GetDownloadScaleModel(w, h) QtTask().AddConvertTask("", data, model, self.AddConvertBack, cleanFlag="download_{}".format( self.parent.bookId)) break self.parent.UpdateTableItem() if isConvertNext: self.StartConvert() return
def GetDonwloadFilePath(self, bookId, epsId, index): if bookId not in self.downloadDict: return "" task = self.downloadDict[bookId] if epsId not in task.epsInfo: return "" epsTitle = task.epsInfo[epsId].epsTitle savePath = os.path.join(task.savePath, ToolUtil.GetCanSaveName(epsTitle)) return os.path.join(savePath, "{:04}.{}".format(index + 1, "jpg"))
def AddConvert(self): savePath = os.path.join(self.parent.savePath, ToolUtil.GetCanSaveName(self.epsTitle)) filePath = os.path.join(savePath, "{:04}.{}".format(self.curPreConvertId + 1, "jpg")) if not os.path.isfile(filePath): self.status = DownloadInfo.Error self.parent.SetConvertStatu(self.status) return if os.path.isfile(self.curConvertPath): self.curPreConvertId += 1 return self.StartConvert() f = open(filePath, "rb") data = f.read() f.close() w, h = ToolUtil.GetPictureSize(data) model = ToolUtil.GetDownloadScaleModel(w, h) QtTask().AddConvertTask("", data, model, self.AddConvertBack, cleanFlag="download_".format(self.parent.bookId)) return
def curConvertPath(self): savePath = os.path.join(self.parent.convertPath, ToolUtil.GetCanSaveName(self.epsTitle)) return os.path.join(savePath, "{:04}.{}".format(self.curPreConvertId + 1, "jpg"))
def curSavePath(self): savePath = os.path.join(self.parent.savePath, ToolUtil.GetCanSaveName(self.epsTitle)) return os.path.join(savePath, "{:04}.{}".format(self.curPreDownloadIndex + 1, "jpg"))