diff --git a/README.md b/README.md index d2a1eb8..4e70b08 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ pyinstaller -F -w -i media/main.ico --add-data 'media/;media' UTAdder.py 批量添加种子到 uTorrent 是程序主要功能,按照程序逻辑来说有三点: -- **保存目录**:如果没有整理下载文件习惯,那这个程序基本用不到,只需要拖动多个种子文件到 uTorrent 窗体,即可实现批量添加任务。但如果经常下载,需要在下载时就设置好指定目录,那么可以使用本程序快速完成添加。例如在设置中下载根目录为 `D:\Download`,保存目录填入 `ABBA`,最终任务的下载目录为 `D:\Download\ABBA`。在完成批量添加任务后,保存目录输入框会自动清空,等待你下次指定,可能是 `AC-DC` 或是别的。 +- **保存目录**:如果没有整理下载文件习惯,那这个程序基本用不到,只需要拖动多个种子文件到 uTorrent 窗体,即可实现批量添加任务。但如果经常下载,需要在下载时就设置好指定目录,那么可以使用本程序快速完成添加。例如在设置中下载根目录为 `D:\Download`,保存目录填入 `ABBA`,最终任务的下载目录为 `D:\Download\ABBA`。在完成批量添加任务后,保存目录输入框会自动清空,等待你下次指定,可能是 `AC-DC` 或是别的。勾选输入框后面的勾,则会保留种子名作为新一级子目录。 - **添加任务**:点击「添加」按钮后,程序会自动将指定目录下的所有种子添加到 uTorrent 中。添加速度没有程序显示的那么快,有延迟但还没碰到过失败,比在界面中一个个任务处理要快多了。完成以后,在程序窗口右下角会显示添加任务总数,或是报错信息? - **处理种子**:添加到下载后,按理说种子文件没用了,可以直接删除。但由于延迟存在,会出现任务还没添加完成(uTorrent 假死),种子文件先被删除,导致添加失败的情况。所以现在使用种子文件目录下的「added」文件夹,来收集已添加到任务的种子文件。 @@ -93,6 +93,12 @@ pyinstaller -F -w -i media/main.ico --add-data 'media/;media' UTAdder.py 更新没有规律,估计小版本号都用不上。 +## 版本 1.1.0(2024.12.31) + +更新内容: + +1. 新增保留种名作为任务目录选项。 + ## 版本 1.0.0(2024.12.19) 发布第一个版本。 \ No newline at end of file diff --git a/README_EN.md b/README_EN.md index 4b9f27d..3a5ce93 100644 --- a/README_EN.md +++ b/README_EN.md @@ -64,7 +64,7 @@ Click "Confirm" to save your changes. The configuration will be stored in `confi The primary feature of UTAdder is to quickly add multiple torrent files into uTorrent in one go. Here's how it works: -- **Save to**: If you don't care about organizing your downloads, you could simply drag and drop multiple torrents into uTorrent. But if you regularly categorize downloads as soon as you add them, UTAdder helps. For example, if your root download directory is `D:\Download` and you set the save directory to `ABBA`, the completed download path becomes `D:\Download\ABBA`. After bulk adding, UTAdder clears the save to field, so you can immediately set a different directory for your next batch (e.g., `AC-DC`). +- **Save to**: If you don't care about organizing your downloads, you could simply drag and drop multiple torrents into uTorrent. But if you regularly categorize downloads as soon as you add them, UTAdder helps. For example, if your root download directory is `D:\Download` and you set the save directory to `ABBA`, the completed download path becomes `D:\Download\ABBA`. After bulk adding, UTAdder clears the save to field, so you can immediately set a different directory for your next batch (e.g., `AC-DC`). When you check the box next to the input field, the torrent name will be retained as a new subdirectory level. - **Adding Tasks**: After you specify the directories, click "Add" to import all torrents from the configured torrent files folder into uTorrent. The speed might not look instantaneous, but it's still much faster than adding them one by one through the GUI. When it's done, the bottom-right corner of window will show the total number of added tasks or display any error messages. - **Handling Torrent Files**: After adding them, the original torrent files could be deleted. However, because there might be a slight delay before uTorrent fully processes them, deleting these files too soon can cause problems. To avoid this, UTAdder automatically moves successfully added torrents into an `added` subfolder within the torrent files directory, ensuring that nothing gets removed prematurely. @@ -90,6 +90,12 @@ After adding tasks, uTorrent's main window will always pop up. There's no workin Updates are irregular; I might not even use small version increments. +## Version 1.1.0 (2024-12-31) + +**Updates**: + +1. Added an option to keep the torrent name as the task directory. + ## Version 1.0.0 (2024-12-19) - First public release. \ No newline at end of file diff --git a/config/lang_dict_all.py b/config/lang_dict_all.py index dac8609..c702dd9 100644 --- a/config/lang_dict_all.py +++ b/config/lang_dict_all.py @@ -7,6 +7,7 @@ 'main_2': 'Save to:', 'main_3': 'Setup', 'main_4': 'Add', + 'main_5': 'Use torrent name as folder name', 'ui.action_setting_1': 'Program Settings', 'label_status_error': 'Error occurred', 'ui.dialog_settings_main_1': 'Settings', @@ -29,6 +30,7 @@ 'main_2': '保存目录:', 'main_3': '设置', 'main_4': '添加', + 'main_5': '使用种子文件名作为文件夹名称', 'ui.action_setting_1': '程序设置', 'label_status_error': '发生错误!', 'ui.dialog_settings_main_1': '设置页面', diff --git a/config/settings.py b/config/settings.py index fbaac18..7e4bac8 100644 --- a/config/settings.py +++ b/config/settings.py @@ -3,7 +3,7 @@ """ # 程序信息 PROGRAM_NAME = 'UTAdder' -VERSION_INFO = 'v1.0.0' +VERSION_INFO = 'v1.1.0' AUTHOR_NAME = 'assassing' CONTACT_MAIL = 'hxz393@gmail.com' WEBSITE_URL = 'https://blog.x2b.net' diff --git a/doc/main.jpg b/doc/main.jpg index 8eb641c..4799b48 100644 Binary files a/doc/main.jpg and b/doc/main.jpg differ diff --git a/doc/main_en.jpg b/doc/main_en.jpg index 368c47f..943869f 100644 Binary files a/doc/main_en.jpg and b/doc/main_en.jpg differ diff --git a/lib/add_to_ut.py b/lib/add_to_ut.py index 0952ee2..27c2fa1 100644 --- a/lib/add_to_ut.py +++ b/lib/add_to_ut.py @@ -25,6 +25,7 @@ def add_to_ut(config: Dict[str, str]) -> Optional[int]: ut_path = config['ut_path'] save_path = config['save_path'] torrent_path = config['torrent_path'] + pick_torrent_name = config['pick_torrent_name'] added_path = os.path.join(torrent_path, "added") added = 0 try: @@ -33,16 +34,21 @@ def add_to_ut(config: Dict[str, str]) -> Optional[int]: # 列出目录下所有文件和目录 for item in os.listdir(torrent_path): + # 分割文件名 + torrent_name, ext = os.path.splitext(item) # 构造完整路径 full_path = os.path.join(torrent_path, item) # 检查是否是文件并以 .torrent 结尾 - if os.path.isfile(full_path) and item.endswith('.torrent'): + if os.path.isfile(full_path) and ext == '.torrent': # 先移动到完成目录再添加 shutil.move(full_path, added_path) add_path = os.path.join(added_path, item) + save_path = f"{save_path}/{torrent_name}" if pick_torrent_name else save_path logger.info(add_path) subprocess.run([ut_path, "/DIRECTORY", save_path, add_path], capture_output=True, text=True) added += 1 + # 也可以一次性添加,torrent_paths 为所有种子路径列表 + # subprocess.run([ut_path, "/DIRECTORY", save_path]+torrent_paths, capture_output=True, text=True) return added except Exception: logger.exception("Exception occurred") diff --git a/ui/action_add.py b/ui/action_add.py index 4562e46..684ff32 100644 --- a/ui/action_add.py +++ b/ui/action_add.py @@ -25,6 +25,7 @@ class ActionAdd(QThread): :param lang_manager: 语言管理器,用于更新动作的显示语言。 :param config_manager: 配置管理器,用于读取和修改设置。 :param sub_dir: 设置此批种子储存文件夹。 + :param pick_torrent_name: 保留种子名作为子文件夹名。 """ initialize_signal = pyqtSignal() finalize_signal = pyqtSignal() @@ -33,7 +34,8 @@ class ActionAdd(QThread): def __init__(self, lang_manager: LangManager, config_manager: ConfigManager, - sub_dir: str): + sub_dir: str, + pick_torrent_name: bool): super().__init__() self.lang_manager = lang_manager self.lang = self.lang_manager.get_lang() @@ -41,6 +43,7 @@ def __init__(self, self.config = self.config_manager.get_config() # 拼接设置中的下载根目录目录和用户输入保存目录名 self.config['save_path'] = os.path.join(self.config['save_path'], sub_dir) + self.config['pick_torrent_name'] = pick_torrent_name def run(self) -> None: """ diff --git a/ui/main_widget.py b/ui/main_widget.py index c539f1d..1f9c92e 100644 --- a/ui/main_widget.py +++ b/ui/main_widget.py @@ -10,7 +10,7 @@ from PyQt5.QtCore import pyqtSignal from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QLineEdit, QLabel +from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QLineEdit, QLabel, QCheckBox from config.settings import GITHUB_URL from ui.action_add import ActionAdd @@ -53,6 +53,7 @@ def update_lang(self) -> None: self.label.setText(f"{self.lang['main_2']}") self.btn_set.setText(self.lang['main_3']) self.btn_add.setText(self.lang['main_4']) + self.check_box.setToolTip(self.lang['main_5']) def init_ui(self) -> None: """ @@ -60,13 +61,15 @@ def init_ui(self) -> None: :return: 无返回值。 """ - # 第一行:标签 + 输入框 + # 第一行:标签 + 输入框 + 勾选框 self.label = QLabel(self) self.line_edit = QLineEdit(self) + self.check_box = QCheckBox() h_layout_top = QHBoxLayout() h_layout_top.addWidget(self.label) h_layout_top.addWidget(self.line_edit) + h_layout_top.addWidget(self.check_box) # 第二行:设置 + 添加按钮 self.btn_set = QPushButton(self) @@ -108,7 +111,8 @@ def on_add_clicked(self) -> None: :return: 无返回值。 """ self.sub_dir = self.line_edit.text() - self.actionAdd = ActionAdd(self.lang_manager, self.config_manager, self.sub_dir) + self.pick_torrent_name = self.check_box.isChecked() + self.actionAdd = ActionAdd(self.lang_manager, self.config_manager, self.sub_dir, self.pick_torrent_name) self.actionAdd.status_updated.connect(self.forward_status) self.actionAdd.initialize_signal.connect(self.initialize) self.actionAdd.finalize_signal.connect(self.finalize)