Skip to content

Commit 4843612

Browse files
authored
Merge-build: v2.4.1
2 parents 50d9092 + 05988db commit 4843612

File tree

12 files changed

+27
-109
lines changed

12 files changed

+27
-109
lines changed

GUI/mainwindow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from GUI.uic.ui_mainwindow import Ui_MainWindow
66
from GUI.uic.qfluent.components import TextBrowserWithBg
77
from assets import res as ori_res
8-
8+
from variables import VER
99

1010
res = ori_res.GUI.Uic
1111

@@ -14,7 +14,7 @@ class MitmMainWindow(Ui_MainWindow):
1414
def setupUi(self, _mainWindow):
1515
_translate = QtCore.QCoreApplication.translate
1616
super(MitmMainWindow, self).setupUi(_mainWindow)
17-
_mainWindow.setWindowTitle(_translate("MainWindow", "ComicGUISpider v2.4.1-beta"))
17+
_mainWindow.setWindowTitle(_translate("MainWindow", f"ComicGUISpider {VER}"))
1818
self.retrybtn.setDisabled(True)
1919
self.clipBtn.setDisabled(1)
2020
self.searchinput.setClearButtonEnabled(1)

GUI/manager/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,6 @@ def checked(recv):
151151
self.conf_dia.puThread.start()
152152

153153
def after_update(self):
154-
cmd = [uv_exc, "tool","run","--from","comicguispider","cgs"]
154+
cmd = ["cgs"]
155155
subprocess.Popen(cmd, cwd=exc_p, env=env)
156156
QTimer.singleShot(1000, self.gui.close)

GUI/manager/preprocess.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from qfluentwidgets import InfoBar, InfoBarPosition, setTheme
99

1010
from assets import res
11-
from variables import PYPI_SOURCE
11+
from variables import PYPI_SOURCE, VER
1212
from utils import conf, ori_path, exc_p, uv_exc, env
1313
from utils.website import EHentaiKits, Cache
1414
from GUI.browser_window import BrowserWindow
@@ -243,7 +243,7 @@ def emit_progress(msg):
243243

244244
if missing_packages:
245245
# 使用pyproject.toml安装脚本依赖
246-
cmd = [uv_exc, "tool", "install", "--force", "ComicGUISpider[script]"]
246+
cmd = [uv_exc, "tool", "install", "--force", f"ComicGUISpider[script]=={VER}"]
247247
cmd.extend(["--index-url", PYPI_SOURCE[conf.pypi_source]])
248248
process = subprocess.Popen(
249249
cmd, cwd=exc_p, env=env,
@@ -294,14 +294,14 @@ def emit_progress(msg):
294294
if progress_callback:
295295
progress_callback(msg)
296296

297-
from GUI.script.kemono import KemonoAuthor
297+
from utils.script.image.kemono import KemonoAuthor, headers, Api
298298
cache = Cache("kemono_data.pkl")
299299
@cache.with_expiry(240, write_in=True)
300300
def download_kemono_data():
301301
emit_progress("正在更新缓存数据...")
302-
url = "https://kemono.cr/api/v1/creators"
302+
url = Api.creators_txt
303303
try:
304-
with data_cli.stream("GET", url, follow_redirects=True, timeout=60) as resp:
304+
with data_cli.stream("GET", url, headers=headers, follow_redirects=True, timeout=60) as resp:
305305
resp.raise_for_status()
306306
content = b""
307307
for chunk in resp.iter_bytes():

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
✅ kemono 域名更换
6767
✅ 修复 domainTool 的 jm 域名检测
68-
✅ ✨更新修复 kemomo 预处理中的数据下载
68+
✅ ✨修复 kemomo 的 api 变更相关
6969

7070
> 配置窗口左下设有`检查更新`按钮,请根据提示进行更新操作
7171

deploy/update.py

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
"""code update"""
4-
import os
5-
import json
6-
import shutil
74
import pathlib
85
import platform
96
import subprocess
@@ -14,7 +11,7 @@
1411
from packaging.version import parse
1512

1613
from assets import res as ori_res
17-
from variables import PYPI_SOURCE
14+
from variables import PYPI_SOURCE, VER
1815
from utils import conf, exc_p, uv_exc, env
1916

2017

@@ -98,72 +95,6 @@ def download_src_code(self, _url=None, zip_name="src.zip"):
9895
return zip_file
9996

10097

101-
class BackupManager:
102-
def __init__(self):
103-
self.backup_dir = temp_p.joinpath("backup")
104-
if self.backup_dir.exists():
105-
shutil.rmtree(self.backup_dir, ignore_errors=True)
106-
self.ignore_patterns = [self.backup_dir.name, '*.pyc', '__pycache__', 'log', '*.db']
107-
108-
def _safe_operation(self, operation: callable, error_msg: str, *args, **kwargs) -> bool:
109-
try:
110-
operation(*args, **kwargs)
111-
return True
112-
except Exception as e:
113-
updater_logger.warning(f"BackupWarning: {error_msg}: {e}")
114-
return False
115-
116-
def _safe_remove(self, _path, is_dir=False):
117-
return self._safe_operation(shutil.rmtree if is_dir else os.remove, f"BackupDeleteError: {_path}", _path)
118-
119-
def _safe_move(self, _src, _dst):
120-
return self._safe_operation(shutil.move, f"BackupMoveError: {_src} -> {_dst}", _src, _dst)
121-
122-
def _check_file_access(self, _path):
123-
try:
124-
if _path.is_file():
125-
with open(_path, 'a', encoding='utf-8'): pass
126-
return True
127-
except (IOError, OSError):
128-
return False
129-
130-
def create_backup(self):
131-
if self.backup_dir.exists() and not self._safe_remove(self.backup_dir, is_dir=True):
132-
raise RuntimeError("BackupCleanError: fail clean old backup")
133-
try:
134-
shutil.copytree(existed_proj_p.absolute(), self.backup_dir, ignore=shutil.ignore_patterns(*self.ignore_patterns))
135-
except Exception as e:
136-
self.cleanup()
137-
raise e
138-
139-
def restore_backup(self):
140-
if not self.backup_dir.exists():
141-
raise FileNotFoundError("BackupNotFoundError: backup directory not found")
142-
self._check_destination_access()
143-
_failed_items = set()
144-
for _item in self.backup_dir.iterdir():
145-
_src = self.backup_dir / _item.name
146-
_dst = existed_proj_p / _item.name
147-
if _dst.exists() and not self._safe_remove(_dst, is_dir=_dst.is_dir()):
148-
_failed_items.add(_item.name)
149-
if not self._safe_move(_src, existed_proj_p):
150-
_failed_items.add(_item.name)
151-
if _failed_items:
152-
raise RuntimeError(f"BackupRestoreError: [{', '.join(_failed_items)}]")
153-
self.cleanup()
154-
155-
def _check_destination_access(self):
156-
_inaccessible_files = [_dst for _item in self.backup_dir.iterdir()
157-
if (_dst := existed_proj_p / _item.name).exists()
158-
and not self._check_file_access(_dst)]
159-
if _inaccessible_files:
160-
raise RuntimeError(f"BackupAccessError: [{', '.join(_inaccessible_files)}]")
161-
162-
def cleanup(self):
163-
if self.backup_dir.exists():
164-
self._safe_remove(self.backup_dir, is_dir=True)
165-
166-
16798
class Proj:
16899
proj = "CGS"
169100
github_author = "jasoneri"
@@ -174,7 +105,6 @@ class Proj:
174105
ver = ""
175106
first_flag = False
176107
local_ver = None
177-
local_ver_file = existed_proj_p.joinpath('version.json')
178108
changed_files = []
179109
update_flag = "local"
180110
update_info = {}
@@ -190,13 +120,7 @@ def print(self, *args, **kwargs):
190120
print(*args, **kwargs)
191121

192122
def check_existed_version(self):
193-
if not self.local_ver_file.exists():
194-
self.first_flag = True
195-
else:
196-
with open(self.local_ver_file, 'r', encoding='utf-8') as f:
197-
version_info = json.load(f)
198-
return version_info.get('current', 'v0.0.0')
199-
return 'v0.0.0'
123+
return VER
200124

201125
def check(self):
202126
self.local_ver = local_ver = self.check_existed_version()
@@ -214,10 +138,8 @@ def check(self):
214138

215139
def local_update(self, ver=None):
216140
self.ver = ver or self.update_info.get('tag_name') or self.local_ver
217-
backuper = BackupManager()
218-
backuper.create_backup()
219141
try:
220-
cmd = [uv_exc,"tool","upgrade","ComicGUISpider"]
142+
cmd = [uv_exc,"tool","upgrade",f"ComicGUISpider=={self.ver}"]
221143
cmd.extend(["--index-url", PYPI_SOURCE[conf.pypi_source]])
222144
self.print("[uv cmd]" + " ".join(cmd))
223145
process = subprocess.Popen(
@@ -246,9 +168,3 @@ def local_update(self, ver=None):
246168
self.print("[!uv upgrade done!]")
247169
except Exception as e:
248170
raise e
249-
else:
250-
self.update_end()
251-
252-
def update_end(self):
253-
with open(self.local_ver_file, 'w', encoding='utf-8') as f:
254-
json.dump({"current": self.ver}, f, ensure_ascii=False, indent=4)

docs/_github/release_notes.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
> [!Warning]
3-
> 由于绿色包内部执行已更改为 `uv tool`,旧版本绿色包需删掉后使用新版本,无论win还是mac
3+
> 由于绿色包内部执行已更改为 `uv tool``v2.4.0`之前旧版绿色包需删掉后使用新版本,无论win还是mac;
4+
> 使用内置更新升级失败的话查看 [更新失败指引](https://jasoneri.github.io/ComicGUISpider/faq/#%E6%9B%B4%E6%96%B0%E5%A4%B1%E8%B4%A5%E5%90%8E%E7%A8%8B%E5%BA%8F%E6%97%A0%E6%B3%95%E6%89%93%E5%BC%80)
45
56
## 🎁 Feat
67

@@ -12,4 +13,4 @@
1213

1314
✅ kemono 域名更换
1415
✅ 修复 domainTool 的 jm 域名检测
15-
✅ ✨更新修复 kemomo 预处理中的数据下载
16+
✅ ✨修复 kemomo 的 api 变更相关

docs/faq/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
::: tip 两种方式可选
6363

64-
- 下载📦绿色包 重新安装/更新
64+
- 删干净原目录/换一个解压目录 并重新解压📦绿色包,然后重新初始化部署/更新
6565
- 干脆直接使用 [uv tool方式部署安装](/deploy/quick-start#1-下载--部署)
6666
:::
6767

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ComicGUISpider"
3-
version = "2.4.1-beta"
3+
version = "2.4.1"
44
description = "GUI Comic Downloader"
55
readme = "README.md"
66
requires-python = ">=3.12"

utils/redViewer_tools.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import shutil
66
from dataclasses import dataclass
77

8-
from tqdm import tqdm
9-
108
from assets import res
119
from utils import conf
1210

@@ -19,7 +17,7 @@ def combine_then_mv(root_dir, target_dir, order_book=None) -> list:
1917
target_p = pathlib.Path(target_dir)
2018
done = []
2119
for order_dir in filter(lambda x: x.is_dir() and x.name not in expect_dir, p.iterdir()):
22-
for ordered_section in tqdm(order_dir.iterdir()):
20+
for ordered_section in order_dir.iterdir():
2321
___ = target_p.joinpath(f"{order_dir.name}_{ordered_section.name}")
2422
if ___.exists():
2523
shutil.rmtree(___)
@@ -32,7 +30,7 @@ def combine_then_mv(root_dir, target_dir, order_book=None) -> list:
3230
def restore(ori):
3331
p = pathlib.Path(ori)
3432
book_p = None
35-
for i in tqdm(p.iterdir()):
33+
for i in p.iterdir():
3634
book, section = i.name.split('_')
3735
if not p.parent.joinpath(book).exists():
3836
book_p = p.parent.joinpath(book)

utils/script/image/expander.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def __init__(self, title_filters: Optional[Dict[str, str]] = None):
3434

3535
def base_process(self, posts):
3636
if self.has_normal:
37-
posts = list(filter(lambda p: not bool(self._normal_pattern.search(p['title'])), posts))
37+
posts = list(filter(lambda p: not bool(self._normal_pattern.search(
38+
p.get('title', p.get('content', '')))), posts))
3839
for post in posts:
3940
if post.get("title"):
4041
post['title'] = self._sanitize_re.sub('-', post['title'])

0 commit comments

Comments
 (0)