Skip to content

Commit

Permalink
更新到 1.10 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
hxz393 committed Dec 31, 2024
1 parent abd4018 commit 3941c6a
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 8 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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」文件夹,来收集已添加到任务的种子文件。

Expand All @@ -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)

发布第一个版本。
8 changes: 7 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
2 changes: 2 additions & 0 deletions config/lang_dict_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -29,6 +30,7 @@
'main_2': '保存目录:',
'main_3': '设置',
'main_4': '添加',
'main_5': '使用种子文件名作为文件夹名称',
'ui.action_setting_1': '程序设置',
'label_status_error': '发生错误!',
'ui.dialog_settings_main_1': '设置页面',
Expand Down
2 changes: 1 addition & 1 deletion config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
# 程序信息
PROGRAM_NAME = 'UTAdder'
VERSION_INFO = 'v1.0.0'
VERSION_INFO = 'v1.1.0'
AUTHOR_NAME = 'assassing'
CONTACT_MAIL = '[email protected]'
WEBSITE_URL = 'https://blog.x2b.net'
Expand Down
Binary file modified doc/main.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/main_en.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion lib/add_to_ut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion ui/action_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -33,14 +34,16 @@ 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()
self.config_manager = config_manager
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:
"""
Expand Down
10 changes: 7 additions & 3 deletions ui/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,20 +53,23 @@ def update_lang(self) -> None:
self.label.setText(f"<b>{self.lang['main_2']}</b>")
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:
"""
初始化用户界面。
: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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3941c6a

Please sign in to comment.