mirror of
https://github.com/tonquer/picacg-qt.git
synced 2025-01-09 04:17:41 +08:00
update v1.4.8
This commit is contained in:
parent
fab576a131
commit
8313ee7c47
13
CHANGELOG
13
CHANGELOG
@ -2,6 +2,19 @@
|
||||
# tonquer<tonquer@qq.com>
|
||||
# https://github.com/tonquer/picacg-qt
|
||||
######################################################################################
|
||||
# Version: v1.4.8
|
||||
# 2024/1/10
|
||||
# 1) 优化下载新增超时自动重试
|
||||
# 2) 下载右键菜单新增添加到本地漫画中
|
||||
# 3) 本地漫画优化
|
||||
|
||||
# Version: v1.4.7
|
||||
# 2023/11/19
|
||||
# 1) 本地漫画新增分页,避免漫画太多卡顿
|
||||
# 2) 本地漫画新增批量删除
|
||||
# 3) 删除收藏不再重新刷新页面
|
||||
# 4) 修复字体设置不生效
|
||||
|
||||
# Version: v1.4.6
|
||||
# 2023/8/13
|
||||
# 1) 本地漫画支持多章节
|
||||
|
@ -25,9 +25,9 @@ if [ ! -f ~/.picacg/db/version ];then
|
||||
echo "mkdir version"
|
||||
fi
|
||||
|
||||
if [ ! -f ~/.picacg/db/book.db ] || [ "`cat ~/.picacg/db/version`" != "v1.4.7" ] ; then
|
||||
if [ ! -f ~/.picacg/db/book.db ] || [ "`cat ~/.picacg/db/version`" != "v1.4.8" ] ; then
|
||||
cp ${HERE}/db/book.db ~/.picacg/db/
|
||||
echo "v1.4.7" > ~/.picacg/db/version
|
||||
echo "v1.4.8" > ~/.picacg/db/version
|
||||
echo "copy db"
|
||||
fi
|
||||
|
||||
|
@ -69,7 +69,7 @@ class ComicListWidget(BaseListWidget):
|
||||
if not self.isGame:
|
||||
action = popMenu.addAction(Str.GetStr(Str.DownloadAll))
|
||||
action.triggered.connect(self.OpenBookDownloadAll)
|
||||
|
||||
|
||||
if self.isDelMenu:
|
||||
action = popMenu.addAction(Str.GetStr(Str.Delete))
|
||||
action.triggered.connect(partial(self.DelHandler, index))
|
||||
|
@ -10,7 +10,7 @@ MainType = 1
|
||||
|
||||
Main = None
|
||||
|
||||
if sys.platform == "win32" and not Setting.IsUseTitleBar.value:
|
||||
if sys.platform == "win32" and Setting.IsUseTitleBar.value:
|
||||
try:
|
||||
from interface.ui_main_windows import Ui_MainWindows
|
||||
from .windows.frame_less_widget import FrameLessWidget
|
||||
|
@ -15,6 +15,7 @@ Uuid = "defaultUuid"
|
||||
ProjectName = "PicACG"
|
||||
ThreadNum = 10 # 线程
|
||||
DownloadThreadNum = 5 # 下载线程
|
||||
ResetDownloadCnt = 5 # 下载图片重试次数
|
||||
ConvertThreadNum = 3 # 同时转换数量
|
||||
ChatSavePath = "chat"
|
||||
SavePathDir = "commies" # 下载目录
|
||||
@ -53,9 +54,9 @@ Issues1 = "https://github.com/tonquer/picacg-qt/issues"
|
||||
Issues2 = "https://hub.ggo.icu/tonquer/picacg-qt/issues"
|
||||
Issues3 = "https://hub.fastgit.xyz/tonquer/picacg-qt/issues"
|
||||
|
||||
UpdateVersion = "v1.4.7"
|
||||
RealVersion = "v1.4.7"
|
||||
TimeVersion = "2023-11-19"
|
||||
UpdateVersion = "v1.4.8"
|
||||
RealVersion = "v1.4.8"
|
||||
TimeVersion = "2024-1-10"
|
||||
|
||||
Waifu2xVersion = "1.1.6"
|
||||
|
||||
|
@ -82,7 +82,7 @@ class Setting:
|
||||
CoverSize = SettingValue("GeneraSetting", 100, False) #
|
||||
CategorySize = SettingValue("GeneraSetting", 80, False) #
|
||||
ScaleLevel = SettingValue("GeneraSetting", 0, True, ["Auto", 100, 125, 150, 175, 200])
|
||||
IsUseTitleBar = SettingValue("GeneraSetting", 0, True)
|
||||
IsUseTitleBar = SettingValue("GeneraSetting", 1, True)
|
||||
|
||||
FontName = SettingValue("GeneraSetting", "", True)
|
||||
FontSize = SettingValue("GeneraSetting", "", True)
|
||||
@ -146,7 +146,7 @@ class Setting:
|
||||
AutoSign = SettingValue("Other", 1, False)
|
||||
SavePassword = SettingValue("Other", 1, False)
|
||||
IsShowCmd = SettingValue("Other", 0, False)
|
||||
IsGrabGesture: SettingValue = SettingValue("Other", 0, True)
|
||||
IsGrabGesture = SettingValue("Other", 0, True)
|
||||
IsShowProxy5 = SettingValue("Other", 0, False)
|
||||
IsPreUpdate = SettingValue("Other", 0, False)
|
||||
SaveCacheAddress = SettingValue("Other", "104.21.91.145", False)
|
||||
|
BIN
src/db/book.db
BIN
src/db/book.db
Binary file not shown.
@ -312,13 +312,15 @@ class GetComicsRecommendation(ServerReq):
|
||||
|
||||
# 下载图片
|
||||
class DownloadBookReq(ServerReq):
|
||||
def __init__(self, url, loadPath="", cachePath="", savePath="", isReload=False):
|
||||
def __init__(self, url, loadPath="", cachePath="", savePath="", isReload=False, resetCnt=1):
|
||||
method = "Download"
|
||||
self.url = url
|
||||
self.loadPath = loadPath
|
||||
self.cachePath = cachePath
|
||||
self.savePath = savePath
|
||||
self.isReload = isReload
|
||||
self.resetCnt = resetCnt
|
||||
self.isReset = False
|
||||
super(self.__class__, self).__init__(url, ToolUtil.GetHeader(url, method),
|
||||
{}, method)
|
||||
|
||||
|
@ -291,8 +291,12 @@ class Server(Singleton):
|
||||
else:
|
||||
self._Download(task)
|
||||
|
||||
def ReDownload(self, task):
|
||||
self._downloadQueue.put(task)
|
||||
|
||||
def _Download(self, task):
|
||||
try:
|
||||
task.req.resetCnt -= 1
|
||||
if not task.req.isReload:
|
||||
if not isinstance(task.req, req.SpeedTestReq) and not task.req.savePath:
|
||||
for cachePath in [task.req.loadPath, task.req.cachePath]:
|
||||
@ -314,7 +318,10 @@ class Server(Singleton):
|
||||
|
||||
if request.headers is None:
|
||||
request.headers = {}
|
||||
Log.Info("request-> backId:{}, {}".format(task.bakParam, task.req))
|
||||
if not request.isReset:
|
||||
Log.Info("request-> backId:{}, {}".format(task.bakParam, task.req))
|
||||
else:
|
||||
Log.Info("request reset:{} -> backId:{}, {}".format(task.req.resetCnt, task.bakParam, task.req))
|
||||
r = self.session.get(request.url, proxies=request.proxy, headers=request.headers, stream=True, timeout=task.timeout, verify=False)
|
||||
# task.res = res.BaseRes(r)
|
||||
# print(r.elapsed.total_seconds())
|
||||
@ -336,6 +343,10 @@ class Server(Singleton):
|
||||
else:
|
||||
task.status = Status.NetError
|
||||
Log.Warn(task.req.url + " " + es.__repr__())
|
||||
if (task.req.resetCnt > 0):
|
||||
task.req.isReset = True
|
||||
self.ReDownload(task)
|
||||
return
|
||||
self.handler.get(task.req.__class__.__name__)(task)
|
||||
if task.res:
|
||||
task.res.close()
|
||||
|
@ -227,16 +227,24 @@ class DownloadBookHandler(object):
|
||||
now = time.time()
|
||||
|
||||
# 网速快,太卡了,优化成最多100ms一次
|
||||
for chunk in r.iter_content(chunk_size=4096):
|
||||
cur = time.time()
|
||||
tick = cur - now
|
||||
if tick >= 0.1:
|
||||
if backData.bakParam and fileSize-getSize > 0:
|
||||
TaskBase.taskObj.downloadBack.emit(backData.bakParam, fileSize-getSize, b"")
|
||||
now = cur
|
||||
try:
|
||||
for chunk in r.iter_content(chunk_size=4096):
|
||||
cur = time.time()
|
||||
tick = cur - now
|
||||
if tick >= 0.1:
|
||||
if backData.bakParam and fileSize-getSize > 0:
|
||||
TaskBase.taskObj.downloadBack.emit(backData.bakParam, fileSize-getSize, b"")
|
||||
now = cur
|
||||
|
||||
getSize += len(chunk)
|
||||
data += chunk
|
||||
getSize += len(chunk)
|
||||
data += chunk
|
||||
except Exception as es:
|
||||
Log.Error(es)
|
||||
from src.server.server import Server
|
||||
if backData.req.resetCnt > 0:
|
||||
backData.req.isReset = True
|
||||
Server().ReDownload(backData)
|
||||
return
|
||||
|
||||
# Log.Info("size:{}, url:{}".format(ToolUtil.GetDownloadSize(fileSize), backData.req.url))
|
||||
if config.IsUseCache and len(data) > 0:
|
||||
|
@ -56,7 +56,7 @@ class QtTaskBase:
|
||||
# downloadCallBack(data, laveFileSize)
|
||||
# downloadCompleteBack(data, st)
|
||||
# downloadCompleteBack(data, st, backParam)
|
||||
def AddDownloadTask(self, url, path, downloadCallBack=None, completeCallBack=None, downloadStCallBack=None, backParam=None, loadPath="", cachePath="", savePath="", cleanFlag="", isReload=False):
|
||||
def AddDownloadTask(self, url, path, downloadCallBack=None, completeCallBack=None, downloadStCallBack=None, backParam=None, loadPath="", cachePath="", savePath="", cleanFlag="", isReload=False, resetCnt=1):
|
||||
from task.task_download import TaskDownload
|
||||
if not cleanFlag:
|
||||
cleanFlag = self.__taskFlagId
|
||||
@ -68,7 +68,7 @@ class QtTaskBase:
|
||||
if Setting.SavePath.value and path:
|
||||
filePath2 = os.path.join(os.path.join(Setting.SavePath.value, config.CachePathDir), path)
|
||||
cachePath = filePath2
|
||||
return TaskDownload().DownloadTask(url, path, downloadCallBack, completeCallBack, downloadStCallBack, backParam, loadPath, cachePath, savePath, cleanFlag, isReload)
|
||||
return TaskDownload().DownloadTask(url, path, downloadCallBack, completeCallBack, downloadStCallBack, backParam, loadPath, cachePath, savePath, cleanFlag, isReload, resetCnt)
|
||||
|
||||
# downloadCallBack(data, laveFileSize, backParam)
|
||||
# downloadCallBack(data, laveFileSize)
|
||||
|
@ -67,7 +67,7 @@ class TaskDownload(TaskBase, QtTaskBase):
|
||||
break
|
||||
self.HandlerDownload({"st": Status.Ok}, (v, QtDownloadTask.Waiting))
|
||||
|
||||
def DownloadTask(self, url, path, downloadCallBack=None, completeCallBack=None, downloadStCallBack=None, backParam=None, loadPath="", cachePath="", savePath="", cleanFlag="", isReload=False):
|
||||
def DownloadTask(self, url, path, downloadCallBack=None, completeCallBack=None, downloadStCallBack=None, backParam=None, loadPath="", cachePath="", savePath="", cleanFlag="", isReload=False, resetCnt=1):
|
||||
self.taskId += 1
|
||||
data = QtDownloadTask(self.taskId)
|
||||
data.downloadCallBack = downloadCallBack
|
||||
@ -89,7 +89,7 @@ class TaskDownload(TaskBase, QtTaskBase):
|
||||
Log.Debug("add download info, cachePath:{}, loadPath:{}, savePath:{}".format(data.cachePath, data.loadPath, data.savePath))
|
||||
from server.server import Server
|
||||
from server import req
|
||||
Server().Download(req.DownloadBookReq(url, data.loadPath, data.cachePath, data.savePath, data.isReload), backParams=self.taskId)
|
||||
Server().Download(req.DownloadBookReq(url, data.loadPath, data.cachePath, data.savePath, data.isReload, resetCnt=resetCnt), backParams=self.taskId)
|
||||
return self.taskId
|
||||
|
||||
def HandlerTask(self, downloadId, laveFileSize, data, isCallBack=True):
|
||||
@ -314,10 +314,10 @@ class TaskDownload(TaskBase, QtTaskBase):
|
||||
assert isinstance(picInfo, Picture)
|
||||
from server.server import Server
|
||||
url = ToolUtil.GetRealUrl(picInfo.fileServer, picInfo.path)
|
||||
|
||||
resetCnt = config.ResetDownloadCnt
|
||||
self.AddDownloadTask(
|
||||
url, "", task.downloadCallBack, task.downloadCompleteBack, task.statusBack,
|
||||
task.backParam, task.loadPath, task.cachePath, task.savePath, task.cleanFlag)
|
||||
task.backParam, task.loadPath, task.cachePath, task.savePath, task.cleanFlag, resetCnt=resetCnt)
|
||||
except Exception as es:
|
||||
Log.Error(es)
|
||||
return
|
||||
|
@ -39,6 +39,7 @@ class LocalData(object):
|
||||
Type3 = 3 # 加载目录所有
|
||||
Type4 = 4 #
|
||||
Type5 = 5 # 批量加载
|
||||
Type6 = 6 # 批量加载目录列表
|
||||
|
||||
AllPictureFormat = ["jpg", "jpeg", "webp", "gif", "apng", "png"]
|
||||
|
||||
@ -224,7 +225,13 @@ class TaskLocal(TaskBase, QtTaskBase):
|
||||
st, datas = self.ParseBookInfoByFile(dir)
|
||||
elif type == LocalData.Type5:
|
||||
st, datas = self.ParseBookInfoByFileAll(dir)
|
||||
|
||||
elif type == LocalData.Type6:
|
||||
datas = []
|
||||
for d in dir:
|
||||
st, data = self.ParseBookInfoByDirRecursion(d)
|
||||
if st == Str.Ok:
|
||||
datas.append(data)
|
||||
st = Str.Ok
|
||||
self.taskObj.localBack.emit(taskId, st, datas)
|
||||
|
||||
def _LoadRead2(self, taskId):
|
||||
|
@ -235,6 +235,7 @@ class Str:
|
||||
SameWight = 150 # 等宽模式
|
||||
CopyFileLast = 151 # 保存上次路径
|
||||
ImportDouble = 152 # 导入多章节目录
|
||||
ImportLocal = 153 # 导入本地漫画中
|
||||
|
||||
|
||||
@classmethod
|
||||
@ -459,6 +460,7 @@ class Str:
|
||||
cls.strDict[cls.SameWight] = QCoreApplication.translate("cls.obj", "等宽模式", None)
|
||||
cls.strDict[cls.CopyFileLast] = QCoreApplication.translate("cls.obj", "保存上次路径", None)
|
||||
cls.strDict[cls.ImportDouble] = QCoreApplication.translate("cls.obj", "导入多章节目录", None)
|
||||
cls.strDict[cls.ImportLocal] = QCoreApplication.translate("cls.obj", "导入到本地漫画中", None)
|
||||
|
||||
@classmethod
|
||||
def GetStr(cls, enumType, defualt=""):
|
||||
|
@ -161,7 +161,7 @@ class DownloadStatus(QtTaskBase):
|
||||
assert isinstance(task, DownloadItem)
|
||||
task.speedStr = ToolUtil.GetDownloadSize(task.speed) + "/s"
|
||||
task.speed = 0
|
||||
self.UpdateTableItem(task)
|
||||
self.UpdateSpeed(task)
|
||||
return
|
||||
|
||||
def StartItemDownload(self, task):
|
||||
|
@ -251,7 +251,12 @@ class DownloadView(QtWidgets.QWidget, Ui_Download, DownloadStatus):
|
||||
self.tableWidget.setItem(info.tableRow, 9, QTableWidgetItem("{}".format(str(info.convertTick))))
|
||||
self.tableWidget.setItem(info.tableRow, 10, QTableWidgetItem(info.GetConvertStatusMsg()))
|
||||
return
|
||||
|
||||
|
||||
def UpdateSpeed(self, info):
|
||||
assert isinstance(info, DownloadItem)
|
||||
self.tableWidget.setItem(info.tableRow, 5, QTableWidgetItem(info.speedStr))
|
||||
return
|
||||
|
||||
def RemoveRecord(self, bookId):
|
||||
task = self.downloadDict.get(bookId)
|
||||
if not task:
|
||||
@ -307,6 +312,9 @@ class DownloadView(QtWidgets.QWidget, Ui_Download, DownloadStatus):
|
||||
pauseConvertAction = QAction(Str.GetStr(Str.PauseConvert), self)
|
||||
pauseConvertAction.triggered.connect(self.ClickConvertPause)
|
||||
|
||||
addLocalAction = QAction(Str.GetStr(Str.ImportLocal), self)
|
||||
addLocalAction.triggered.connect(self.ClickAddLocalBook)
|
||||
|
||||
if index.isValid():
|
||||
selected = self.tableWidget.selectedIndexes()
|
||||
selectRows = set()
|
||||
@ -344,6 +352,7 @@ class DownloadView(QtWidgets.QWidget, Ui_Download, DownloadStatus):
|
||||
menu.addAction(startConvertAction)
|
||||
menu.addAction(pauseConvertAction)
|
||||
|
||||
menu.addAction(addLocalAction)
|
||||
menu.addAction(removeAction)
|
||||
menu.addAction(removeFileAction)
|
||||
menu.exec_(QCursor.pos())
|
||||
@ -401,6 +410,26 @@ class DownloadView(QtWidgets.QWidget, Ui_Download, DownloadStatus):
|
||||
self.SetNewCovertStatus(task, task.Pause)
|
||||
return
|
||||
|
||||
def ClickAddLocalBook(self):
|
||||
selected = self.tableWidget.selectedIndexes()
|
||||
selectRows = set()
|
||||
for index in selected:
|
||||
selectRows.add(index.row())
|
||||
if not selectRows:
|
||||
return
|
||||
allFilePath = []
|
||||
for row in selectRows:
|
||||
col = 0
|
||||
bookId = self.tableWidget.item(row, col).text()
|
||||
task = self.downloadDict.get(bookId)
|
||||
if not task:
|
||||
continue
|
||||
assert isinstance(task, DownloadItem)
|
||||
if task.savePath:
|
||||
allFilePath.append(os.path.dirname(task.savePath))
|
||||
QtOwner().localReadView.ImportDownloadDirs(allFilePath)
|
||||
return
|
||||
|
||||
def ClickDownloadEps(self):
|
||||
selected = self.tableWidget.selectedIndexes()
|
||||
selectRows = set()
|
||||
|
@ -267,6 +267,7 @@ class LocalReadView(QWidget, Ui_Local, QtTaskBase):
|
||||
assert isinstance(v, LocalData)
|
||||
newV = books[0]
|
||||
v.CopyData(newV)
|
||||
self.db.AddLoadLocalBook(v)
|
||||
if v.eps != []:
|
||||
QtOwner().OpenLocalEpsView(v.id)
|
||||
return
|
||||
@ -326,10 +327,14 @@ class LocalReadView(QWidget, Ui_Local, QtTaskBase):
|
||||
self.lastPath = url
|
||||
for v in books:
|
||||
if v.id in self.allBookInfos:
|
||||
# 已存在则更新
|
||||
alreadyNum += 1
|
||||
self.allBookInfos[v.id].CopyData(v)
|
||||
self.db.AddLoadLocalBook(self.allBookInfos[v.id])
|
||||
else:
|
||||
self.allBookInfos[v.id] = v
|
||||
addNum += 1
|
||||
# 忽略
|
||||
if self.curSelectCategory:
|
||||
category = self.curSelectCategory
|
||||
self.db.AddCategory(self.curSelectCategory, v.id)
|
||||
@ -372,6 +377,11 @@ class LocalReadView(QWidget, Ui_Local, QtTaskBase):
|
||||
def CheckAction4(self):
|
||||
return
|
||||
|
||||
# 批量导入下载目录
|
||||
def ImportDownloadDirs(self, dirs):
|
||||
self.AddLocalTaskLoad(LocalData.Type6, dirs, "", self.CheckAction1LoadBack)
|
||||
return
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
if(event.mimeData().hasUrls()):
|
||||
event.acceptProposedAction()
|
||||
|
Loading…
Reference in New Issue
Block a user