Skip to content

Commit

Permalink
支持同一链接转存到不同目录,而不是被去重剔除
Browse files Browse the repository at this point in the history
  • Loading branch information
hxz393 committed Dec 12, 2024
1 parent c5c5a0f commit a5853e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ https://pan.baidu.com/e/1X5j-baPwZHmcXioKQPxb_w rsss
# 更新日志
为避免更新日志过长,只保留最近更新日志。

## 版本 2.8.2(2024.12.12)

修复内容:

1. 指定链接转存到不同目录时,重复链接不会被忽略。

## 版本 2.8.1(2024.10.25)

更新内容:
Expand Down
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
# 程序基本信息
MAIN_TITLE = 'BaiduPanFilesTransfers'
MAIN_VERSION = '2.8.1'
MAIN_VERSION = '2.8.2'
HOME_PAGE = 'https://github.com/hxz393/BaiduPanFilesTransfers'
# noinspection LongLine
# 图标使用 zlib 压缩后,再用 base64 编码的值
Expand Down
15 changes: 10 additions & 5 deletions src/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def setup_save(self) -> None:
"""准备链接,更新状态"""
# 从文本链接控件获取全部链接,清洗并标准化链接。注意链接后拼接一个空格,是为了后面能统一处理带与不带提取码的链接
raw_links = self.root.text_links.get(1.0, ttk.END).splitlines()
normalized_links = [normalize_link(f'{link} ') for link in raw_links if link]
self.link_list = list(dict.fromkeys(normalized_links))
self.link_list = [normalize_link(f'{link} ') for link in raw_links if link]
self.link_list_org = list(dict.fromkeys(link for link in raw_links if link))
# 更新任务总数和状态
self.total_task_count = len(self.link_list)
Expand Down Expand Up @@ -294,7 +293,7 @@ def check_only(self, result: Union[List[str], int], url_code: str) -> None:
self.insert_logs(f'链接无效:{url_code} 原因:{ERROR_CODES.get(result, f"错误代码({result})")}')

def creat_user_dir(self, folder_name: str) -> str:
"""建立用户指定目录,返回完整路径"""
"""建立用户指定目录,返回完整路径。目录名从原始输入取,函数为 custom_mode 专用"""
self.check_condition(not folder_name, message='必须输入转存目录')
# 对原始输入进行分割
link_org_sep = self.link_list_org[self.completed_task_count].split()
Expand All @@ -316,8 +315,14 @@ def save_file(self, result: Union[List[str], int], url_code: str, folder_name: s
# 如果开启安全转存模式,对每个转存链接建立目录
if self.custom_mode:
folder_name = self.creat_user_dir(folder_name)
# 终于轮到发送转存请求
result = self.network.transfer_file(result, folder_name)
result = self.network.transfer_file(result, folder_name)
file_info = f'{file_info} 转存到:{folder_name}'
# 改在这里检查链接重复,在日志中查找。链接有出现过不转存,直接赋值结果为错误代码 4
elif url_code in self.root.text_logs.get('1.0', 'end'):
result = 4
# 正常转存
else:
result = self.network.transfer_file(result, folder_name)

# 最后插入转存结果到日志框
self.insert_logs(f'{ERROR_CODES.get(result, f"转存失败,错误代码({result})")}{url_code} {file_info}')

0 comments on commit a5853e7

Please sign in to comment.