# Auto Remove Torrents (H&R Version)
这是一个支持 H&R 检查的自动删种程序,基于 [autoremove-torrents](https://github.com/jerrymakesjelly/autoremove-torrents) 修改,在此感谢原作者jerrymakesjelly。
## 新增功能
v2.0.0
- 整体重构,可以根据 H&R 状态码灵活配置删除条件
- 支持多个策略组合使用
- 支持检查种子的做种时间、上传速度等条件
- 增加种子状态本地缓存,减少 API 请求次数
v1.6.1
- 支持通过 API 检查种子的 H&R 状态来删除种子
## 安装
```bash
pip install autoremove-torrents-hnr
```
## 更新
```bash
pip install autoremove-torrents-hnr --upgrade
或者
pip install autoremove-torrents-hnr==具体版本号
```
## 卸载
```bash
pip uninstall autoremove-torrents-hnr
```
## 配置示例
```yaml
my_task:
client: qbittorrent
host: http://127.0.0.1:7474
username: admin
password: password
strategies:
# 删除未触发考核的种子
remove_untriggered_hnr:
categories: # 种子分类(可选)
- TJUPT
hnr:
host: https://tjupt.org/api/v1/hnr.php
api_token: your_api_token
target_codes: 0 # 未触发考核的种子
min_seed_time: 86400 # 做种时间大于1天将被删除
min_upload_speed: 51200 # 上传速度小于50KB/s将被删除
# 删除已通过考核的种子
remove_completed_hnr:
categories:
- TJUPT
hnr:
host: https://tjupt.org/api/v1/hnr.php
api_token: your_api_token
target_codes: [20, 21] # 已通过考核的种子
last_activity: 172800 # 2天没有活动的种子将被删除
min_upload_speed: 10240 # 上传速度小于10KB/s将被删除
min_ratio: 1.0 # 分享率大于1.0将被删除
# 删除考核被取消的种子
remove_cancelled_hnr:
categories:
- TJUPT
hnr:
host: https://tjupt.org/api/v1/hnr.php
api_token: your_api_token
target_codes: [40, 41, 42] # 考核被取消的种子
delete_data: true # 是否在删除种子的同时也删除数据
```
其他条件配置请参考原项目 [autoremove-torrents](https://autoremove-torrents.readthedocs.io/zh-cn/latest/) 的文档。
## hnr 配置说明
H&R API 接口文档:[hnr_api.md](https://github.com/tjupt/autoremove-torrents/blob/master/hnr_api.md)
在策略配置中添加 `hnr` 部分:
### 必需参数
- `host`: H&R API 地址
- `api_token`: API 访问令牌
- `target_codes`: 目标状态码,可以是单个状态码或状态码列表,具体见H&R API 接口文档:[hnr_api.md](https://github.com/tjupt/autoremove-torrents/blob/master/hnr_api.md)
### 可选参数
- `last_activity`: 种子不活跃时间限制,单位为秒
- `min_seed_time`: 最小做种时间,单位为秒
- `min_upload_speed`: 最小上传速度,单位为字节/秒
- `min_ratio`: 最小分享率
### 条件组合说明
1. 首先检查种子的 HNR 状态码是否匹配 `target_codes`
2. 如果状态码匹配,则继续检查其他配置的条件(如 `last_activity`、`min_seed_time` 等)
3. 只有当所有配置的条件都满足时,种子才会被删除
4. 未配置的条件会被跳过,不参与判断
## 使用方法
参考原项目 [autoremove-torrents](https://autoremove-torrents.readthedocs.io/zh-cn/latest/inst.html#run) 的运行说明
```bash
# 预览模式(不会真正删除)
autoremove-torrents --view --conf=config.yml
# 正常运行
autoremove-torrents --conf=config.yml
```
## 日志
```bash
autoremove-torrents --conf=config.yml --log=logs/autoremove.log --debug
```
## 项目结构
### 1 客户端模块 (client/)
- hnr_api.py: H&R API 客户端,用于查询种子的 H&R 状态
- 其他客户端适配器(如 qBittorrent, Transmission 等)
### 2 条件模块 (condition/)
- base.py: 条件基类,定义了条件的基本接口
- hnr.py: H&R 条件检查实现
- 其他条件实现(如分享率、做种时间等)
### 3 核心功能文件
- strategy.py: 策略执行器,负责:
- 应用各种条件
- 管理种子的保留和删除列表
- 执行删除操作
- conditionparser.py: 条件解析器,负责:
- 解析配置文件中的条件
- 创建对应的条件实例
- 处理条件组合
## 工作流程
### 1 配置加载
- 读取 config.yml
- 解析任务和策略配置
### 2 客户端连接
- 根据配置创建对应的客户端实例
- 建立连接并验证
### 3 策略执行
- 获取种子列表
- 应用分类过滤
- 执行条件检查
- 确定删除列表
### 4 删除操作
- 执行种子删除
- 记录操作日志
## 许可证
MIT License
Raw data
{
"_id": null,
"home_page": "https://github.com/tjupt/autoremove-torrents",
"name": "autoremove-torrents-hnr",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python autoremove torrent",
"author": "TJUPT",
"author_email": "ptmaster@tjupt.org",
"download_url": "https://files.pythonhosted.org/packages/74/13/1076d6b2dbeb1c1a03a3415674a138f040f0d2e559be66ca66c7427ae97f/autoremove_torrents_hnr-2.0.0.tar.gz",
"platform": null,
"description": "# Auto Remove Torrents (H&R Version)\n\n\u8fd9\u662f\u4e00\u4e2a\u652f\u6301 H&R \u68c0\u67e5\u7684\u81ea\u52a8\u5220\u79cd\u7a0b\u5e8f\uff0c\u57fa\u4e8e [autoremove-torrents](https://github.com/jerrymakesjelly/autoremove-torrents) \u4fee\u6539\uff0c\u5728\u6b64\u611f\u8c22\u539f\u4f5c\u8005jerrymakesjelly\u3002\n\n## \u65b0\u589e\u529f\u80fd\n\nv2.0.0\n- \u6574\u4f53\u91cd\u6784\uff0c\u53ef\u4ee5\u6839\u636e H&R \u72b6\u6001\u7801\u7075\u6d3b\u914d\u7f6e\u5220\u9664\u6761\u4ef6\n- \u652f\u6301\u591a\u4e2a\u7b56\u7565\u7ec4\u5408\u4f7f\u7528\n- \u652f\u6301\u68c0\u67e5\u79cd\u5b50\u7684\u505a\u79cd\u65f6\u95f4\u3001\u4e0a\u4f20\u901f\u5ea6\u7b49\u6761\u4ef6\n- \u589e\u52a0\u79cd\u5b50\u72b6\u6001\u672c\u5730\u7f13\u5b58\uff0c\u51cf\u5c11 API \u8bf7\u6c42\u6b21\u6570\n\nv1.6.1\n- \u652f\u6301\u901a\u8fc7 API \u68c0\u67e5\u79cd\u5b50\u7684 H&R \u72b6\u6001\u6765\u5220\u9664\u79cd\u5b50\n\n## \u5b89\u88c5\n\n```bash\npip install autoremove-torrents-hnr\n```\n\n## \u66f4\u65b0\n\n```bash\npip install autoremove-torrents-hnr --upgrade\n\u6216\u8005\npip install autoremove-torrents-hnr==\u5177\u4f53\u7248\u672c\u53f7\n```\n\n## \u5378\u8f7d\n\n```bash\npip uninstall autoremove-torrents-hnr\n```\n\n## \u914d\u7f6e\u793a\u4f8b\n\n```yaml\nmy_task:\n client: qbittorrent\n host: http://127.0.0.1:7474\n username: admin\n password: password\n \n strategies:\n # \u5220\u9664\u672a\u89e6\u53d1\u8003\u6838\u7684\u79cd\u5b50\n remove_untriggered_hnr:\n categories: # \u79cd\u5b50\u5206\u7c7b\uff08\u53ef\u9009\uff09\n - TJUPT\n hnr:\n host: https://tjupt.org/api/v1/hnr.php\n api_token: your_api_token\n target_codes: 0 # \u672a\u89e6\u53d1\u8003\u6838\u7684\u79cd\u5b50\n min_seed_time: 86400 # \u505a\u79cd\u65f6\u95f4\u5927\u4e8e1\u5929\u5c06\u88ab\u5220\u9664\n min_upload_speed: 51200 # \u4e0a\u4f20\u901f\u5ea6\u5c0f\u4e8e50KB/s\u5c06\u88ab\u5220\u9664\n\n # \u5220\u9664\u5df2\u901a\u8fc7\u8003\u6838\u7684\u79cd\u5b50\n remove_completed_hnr:\n categories:\n - TJUPT\n hnr:\n host: https://tjupt.org/api/v1/hnr.php\n api_token: your_api_token\n target_codes: [20, 21] # \u5df2\u901a\u8fc7\u8003\u6838\u7684\u79cd\u5b50\n last_activity: 172800 # 2\u5929\u6ca1\u6709\u6d3b\u52a8\u7684\u79cd\u5b50\u5c06\u88ab\u5220\u9664\n min_upload_speed: 10240 # \u4e0a\u4f20\u901f\u5ea6\u5c0f\u4e8e10KB/s\u5c06\u88ab\u5220\u9664\n min_ratio: 1.0 # \u5206\u4eab\u7387\u5927\u4e8e1.0\u5c06\u88ab\u5220\u9664\n\n # \u5220\u9664\u8003\u6838\u88ab\u53d6\u6d88\u7684\u79cd\u5b50\n remove_cancelled_hnr:\n categories:\n - TJUPT\n hnr:\n host: https://tjupt.org/api/v1/hnr.php\n api_token: your_api_token\n target_codes: [40, 41, 42] # \u8003\u6838\u88ab\u53d6\u6d88\u7684\u79cd\u5b50\n\n delete_data: true # \u662f\u5426\u5728\u5220\u9664\u79cd\u5b50\u7684\u540c\u65f6\u4e5f\u5220\u9664\u6570\u636e\n```\n\n\u5176\u4ed6\u6761\u4ef6\u914d\u7f6e\u8bf7\u53c2\u8003\u539f\u9879\u76ee [autoremove-torrents](https://autoremove-torrents.readthedocs.io/zh-cn/latest/) \u7684\u6587\u6863\u3002\n\n## hnr \u914d\u7f6e\u8bf4\u660e\n\nH&R API \u63a5\u53e3\u6587\u6863\uff1a[hnr_api.md](https://github.com/tjupt/autoremove-torrents/blob/master/hnr_api.md)\n\n\u5728\u7b56\u7565\u914d\u7f6e\u4e2d\u6dfb\u52a0 `hnr` \u90e8\u5206\uff1a\n\n### \u5fc5\u9700\u53c2\u6570\n- `host`: H&R API \u5730\u5740\n- `api_token`: API \u8bbf\u95ee\u4ee4\u724c\n- `target_codes`: \u76ee\u6807\u72b6\u6001\u7801\uff0c\u53ef\u4ee5\u662f\u5355\u4e2a\u72b6\u6001\u7801\u6216\u72b6\u6001\u7801\u5217\u8868\uff0c\u5177\u4f53\u89c1H&R API \u63a5\u53e3\u6587\u6863\uff1a[hnr_api.md](https://github.com/tjupt/autoremove-torrents/blob/master/hnr_api.md)\n\n### \u53ef\u9009\u53c2\u6570\n- `last_activity`: \u79cd\u5b50\u4e0d\u6d3b\u8dc3\u65f6\u95f4\u9650\u5236\uff0c\u5355\u4f4d\u4e3a\u79d2\n- `min_seed_time`: \u6700\u5c0f\u505a\u79cd\u65f6\u95f4\uff0c\u5355\u4f4d\u4e3a\u79d2\n- `min_upload_speed`: \u6700\u5c0f\u4e0a\u4f20\u901f\u5ea6\uff0c\u5355\u4f4d\u4e3a\u5b57\u8282/\u79d2\n- `min_ratio`: \u6700\u5c0f\u5206\u4eab\u7387\n\n### \u6761\u4ef6\u7ec4\u5408\u8bf4\u660e\n1. \u9996\u5148\u68c0\u67e5\u79cd\u5b50\u7684 HNR \u72b6\u6001\u7801\u662f\u5426\u5339\u914d `target_codes`\n2. \u5982\u679c\u72b6\u6001\u7801\u5339\u914d\uff0c\u5219\u7ee7\u7eed\u68c0\u67e5\u5176\u4ed6\u914d\u7f6e\u7684\u6761\u4ef6\uff08\u5982 `last_activity`\u3001`min_seed_time` \u7b49\uff09\n3. \u53ea\u6709\u5f53\u6240\u6709\u914d\u7f6e\u7684\u6761\u4ef6\u90fd\u6ee1\u8db3\u65f6\uff0c\u79cd\u5b50\u624d\u4f1a\u88ab\u5220\u9664\n4. \u672a\u914d\u7f6e\u7684\u6761\u4ef6\u4f1a\u88ab\u8df3\u8fc7\uff0c\u4e0d\u53c2\u4e0e\u5224\u65ad\n\n## \u4f7f\u7528\u65b9\u6cd5\n\u53c2\u8003\u539f\u9879\u76ee [autoremove-torrents](https://autoremove-torrents.readthedocs.io/zh-cn/latest/inst.html#run) \u7684\u8fd0\u884c\u8bf4\u660e\n```bash\n# \u9884\u89c8\u6a21\u5f0f\uff08\u4e0d\u4f1a\u771f\u6b63\u5220\u9664\uff09\nautoremove-torrents --view --conf=config.yml\n\n# \u6b63\u5e38\u8fd0\u884c\nautoremove-torrents --conf=config.yml\n```\n\n## \u65e5\u5fd7\n\n```bash\nautoremove-torrents --conf=config.yml --log=logs/autoremove.log --debug\n```\n\n## \u9879\u76ee\u7ed3\u6784\n### 1 \u5ba2\u6237\u7aef\u6a21\u5757 (client/)\n- hnr_api.py: H&R API \u5ba2\u6237\u7aef\uff0c\u7528\u4e8e\u67e5\u8be2\u79cd\u5b50\u7684\u00a0H&R \u72b6\u6001\n- \u5176\u4ed6\u5ba2\u6237\u7aef\u9002\u914d\u5668\uff08\u5982\u00a0qBittorrent, Transmission \u7b49\uff09\n### 2 \u6761\u4ef6\u6a21\u5757 (condition/)\n- base.py: \u6761\u4ef6\u57fa\u7c7b\uff0c\u5b9a\u4e49\u4e86\u6761\u4ef6\u7684\u57fa\u672c\u63a5\u53e3\n- hnr.py: H&R \u6761\u4ef6\u68c0\u67e5\u5b9e\u73b0\n- \u5176\u4ed6\u6761\u4ef6\u5b9e\u73b0\uff08\u5982\u5206\u4eab\u7387\u3001\u505a\u79cd\u65f6\u95f4\u7b49\uff09\n### 3 \u6838\u5fc3\u529f\u80fd\u6587\u4ef6\n- strategy.py: \u7b56\u7565\u6267\u884c\u5668\uff0c\u8d1f\u8d23\uff1a\n- \u5e94\u7528\u5404\u79cd\u6761\u4ef6\n- \u7ba1\u7406\u79cd\u5b50\u7684\u4fdd\u7559\u548c\u5220\u9664\u5217\u8868\n- \u6267\u884c\u5220\u9664\u64cd\u4f5c\n\n- conditionparser.py: \u6761\u4ef6\u89e3\u6790\u5668\uff0c\u8d1f\u8d23\uff1a\n- \u89e3\u6790\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u6761\u4ef6\n- \u521b\u5efa\u5bf9\u5e94\u7684\u6761\u4ef6\u5b9e\u4f8b\n- \u5904\u7406\u6761\u4ef6\u7ec4\u5408\n\n## \u5de5\u4f5c\u6d41\u7a0b\n### 1 \u914d\u7f6e\u52a0\u8f7d\n- \u8bfb\u53d6\u00a0config.yml\n- \u89e3\u6790\u4efb\u52a1\u548c\u7b56\u7565\u914d\u7f6e\n### 2 \u5ba2\u6237\u7aef\u8fde\u63a5\n- \u6839\u636e\u914d\u7f6e\u521b\u5efa\u5bf9\u5e94\u7684\u5ba2\u6237\u7aef\u5b9e\u4f8b\n- \u5efa\u7acb\u8fde\u63a5\u5e76\u9a8c\u8bc1\n### 3 \u7b56\u7565\u6267\u884c\n- \u83b7\u53d6\u79cd\u5b50\u5217\u8868\n- \u5e94\u7528\u5206\u7c7b\u8fc7\u6ee4\n- \u6267\u884c\u6761\u4ef6\u68c0\u67e5\n- \u786e\u5b9a\u5220\u9664\u5217\u8868\n### 4 \u5220\u9664\u64cd\u4f5c\n- \u6267\u884c\u79cd\u5b50\u5220\u9664\n- \u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7\n\n## \u8bb8\u53ef\u8bc1\n\nMIT License\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Automatically remove torrents according to your strategies with H&R check support.",
"version": "2.0.0",
"project_urls": {
"Homepage": "https://github.com/tjupt/autoremove-torrents"
},
"split_keywords": [
"python",
"autoremove",
"torrent"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5d77a26d1550dd3e2c4d961f9dc94fd39d34a6ae6bc6256c5010a924e00a7e60",
"md5": "a45f4b08e0febe92d9b0cf8e7a660887",
"sha256": "1d8cdd3e3c925b74b99a53394635face167aa181bceb9726bdc34b99aefa7c28"
},
"downloads": -1,
"filename": "autoremove_torrents_hnr-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a45f4b08e0febe92d9b0cf8e7a660887",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 152959,
"upload_time": "2024-12-08T00:44:40",
"upload_time_iso_8601": "2024-12-08T00:44:40.819111Z",
"url": "https://files.pythonhosted.org/packages/5d/77/a26d1550dd3e2c4d961f9dc94fd39d34a6ae6bc6256c5010a924e00a7e60/autoremove_torrents_hnr-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "74131076d6b2dbeb1c1a03a3415674a138f040f0d2e559be66ca66c7427ae97f",
"md5": "4130cd5cd2d8a4538be953e9cc017b57",
"sha256": "9ead2b7b0bb50188fcf8f9514091965082d7f26c31e2ef18643be7ef9d4a2b2b"
},
"downloads": -1,
"filename": "autoremove_torrents_hnr-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "4130cd5cd2d8a4538be953e9cc017b57",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 93619,
"upload_time": "2024-12-08T00:44:43",
"upload_time_iso_8601": "2024-12-08T00:44:43.334085Z",
"url": "https://files.pythonhosted.org/packages/74/13/1076d6b2dbeb1c1a03a3415674a138f040f0d2e559be66ca66c7427ae97f/autoremove_torrents_hnr-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-08 00:44:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tjupt",
"github_project": "autoremove-torrents",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "autoremove-torrents-hnr"
}