Skip to content

Commit 17321da

Browse files
committed
chore: 更新版本至1.1.33并优化下载源处理逻辑
- 将项目版本从1.1.32更新至1.1.33 - 优化DownloadSource.add_source_to_candidate函数参数格式,提高可读性 - 调整process_files方法中循环顺序,优先处理已合并的源 - 添加空列表检查,避免处理无效数据 - 优化循环逻辑,在满足条件时提前退出循环 - 保持原有功能不变,仅改进代码结构和错误处理
1 parent 6e8de6d commit 17321da

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "funread"
3-
version = "1.1.32"
3+
version = "1.1.33"
44
description = "一个用于管理和处理阅读源(Legado 阅读 APP 的书源和 RSS 源)的 Python 工具库"
55
readme = "README.md"
66
requires-python = ">=3.8"

src/funread/legado/manage/download/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def url_index(self, url: str) -> int:
9898

9999
@staticmethod
100100
def add_source_to_candidate(
101-
md5: str, fpath: str, source: Dict[str, Any], url_info: Optional[Dict[str, Any]] = None
101+
md5: str,
102+
fpath: str,
103+
source: Dict[str, Any],
104+
url_info: Optional[Dict[str, Any]] = None,
102105
) -> None:
103106
"""
104107
将源添加到候选列表
@@ -303,9 +306,11 @@ def export_sources(self, size: int = 1000) -> Iterator[List[Dict[str, Any]]]:
303306
continue
304307

305308
# 从候选和已合并列表中提取源
306-
for key in ("candidate", "merged"):
309+
for key in ("merged", "candidate"):
307310
if key not in data:
308311
continue
312+
if len(data[key]) == 0:
313+
continue
309314
for item in data[key][:3]: # 每个文件最多取前3个
310315
if "source" not in item or "md5_list" not in item:
311316
continue
@@ -321,6 +326,7 @@ def export_sources(self, size: int = 1000) -> Iterator[List[Dict[str, Any]]]:
321326
if len(dd) >= size:
322327
yield dd
323328
dd = []
329+
break
324330
except (IOError, json.JSONDecodeError, KeyError) as e:
325331
logger.warning(f"Failed to process {file_path}: {e}")
326332
continue

0 commit comments

Comments
 (0)