-
Notifications
You must be signed in to change notification settings - Fork 117
Home
IvonWei edited this page May 7, 2021
·
76 revisions
首先推荐4个项目:
- IYUUAutoReseed(辅种)
- autoremove-torrents(删种)
- flexget-nexusphp(筛选免费钟)
- qiandao(签到)
如果以上项目已经完全够用了,就不需要往下看了,pt吧内有很详尽的教程。用复杂的方式解决简单的需求并不值得。
这原本是一个 Flexget 的 qBittorrent插件,因为懒得开新项目,已经变成大杂烩了
这个大杂烩是为了实现我自己需求的全自动化,只为能用就好,并没有想着朝简单易用的方向发展。
对插件使用有疑问,或者发现有BUG建议,欢迎来tg或者qq群找我。
PS:提问前
- 了解 yaml 语法
- 了解 flexget rss订阅 基础用法
- 清楚自己需要的功能
- 看完wiki https://github.com/IvonWei/flexget_qbittorrent_mod/wiki
- 关于上述4个推荐项目,我懂的并不比你多,所以请不要问我
口令: 115599
tg: https://t.me/flexget_qbittorrent_mod
qq群: 1128215750
目前实现的功能有:
- 下载、修改、删除种子:https://github.com/IvonWei/flexget_qbittorrent_mod/wiki/qbittorrent_mod
- 获取qbittorrent状态、种子列表: https://github.com/IvonWei/flexget_qbittorrent_mod/wiki/from_qbittorrent
- 辅种:https://github.com/IvonWei/flexget_qbittorrent_mod/wiki/iyuu_auto_reseed
- 自动签到、统计: https://github.com/IvonWei/flexget_qbittorrent_mod/wiki/auto_sign_in
- 企业微信消息推送:https://github.com/IvonWei/flexget_qbittorrent_mod/wiki/wecom
参考:
-
IYUUAutoReseed:https://github.com/ledccn/IYUUAutoReseed
-
qBittorrent-Web-API:https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)
- qBittorrent 4.1.4+
- Flexget > 3.1.72(python-telegram-bot==12.8 brotli baidu-aip pillow pandas==1.0.5 matplotlib fuzzywuzzy python-Levenshtein pyppeteer pyppeteer_stealth)
- Python > 3.8
- 下载插件 master
- 在Flexget的 config 文件夹下新建 plugins 文件夹
- 将所有的 .py 文件 与 ptsites 文件夹 解压至 plugins 下
- 若启用了Web-UI或守护进程,则重启flexget重新加载配置
- 运行image-builder\build.sh 生成镜像,容器参数参考 image-builder\docker-compose.yml
flexget:
image: ivonwei/flexget
container_name: flexget
environment:
FG_WEBUI_PASSWD: 12nfo34ivc043iv9
PUID: 1000
PGID:1000
FG_LOG_LEVEL: INFO
TZ: Asia/Shanghai
volumes:
- <path for config files>:/config
- <path for data files>:/downloads
ports:
- "3539:3539"
更多配置可以学习Flexget官方文档
config_example.yml是我当前正在使用的配置,仅供参考
web_server:
bind: 0.0.0.0
#web监听端口
port: 3539
#变量
variables:
headers:
user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36'
# "&" 设置锚点, "*" 引用锚点
via: &via_setting
- wechat_work:
corp_id: 'xxxxxxxx'
#小程序secret
corp_secret: 'xxxxxxxx'
agent_id: 'xxxxxxxx'
#用户id
to_user: 'xxxxxxxx'
- telegram:
bot_token: xxxxxxxx
recipients:
- username: 'xxxxxxxx'
templates:
#从qBittorrent获取数据
from_qbittorrent_template:
from_qbittorrent_mod: &qbittorrent_setting
host: qbittorrent.example.com
port: 443
#非https请设置为 no
use_ssl: yes
username: xxxxxxxx
password: xxxxxxxx
#基础
qbittorrent_base_template:
qbittorrent_mod: *qbittorrent_setting
#添加
qbittorrent_add_template:
qbittorrent_mod:
action:
add:
reject_on:
#带宽
bandwidth_limit: 13107200
#当下载速度大于 bandwidth_limit * dl_speed 时 拒绝新种子
dl_speed: 0.6
#当限速低于 8MiB 时 拒绝新种子
dl_limit: 8388608
#设为yes可拒绝所有种子,一般清理数据库后使用防止添加未记录的老种
all: no
#分类
category: Rss
#自动管理种子
autoTMM: yes
#修改
qbittorrent_modify_template:
qbittorrent_mod:
action:
modify:
#根据tracker添加种子标签
tag_by_tracker: yes
#批量替换tracker 例如把http替换成https (需要完全匹配)
replace_trackers:
'http://tracker.pt1.com/announce.php?passkey=xxxxxxxxxxxxxx': 'https://tracker.pt1.com/announce.php?passkey=xxxxxxxxxxxxxx'
#恢复
qbittorrent_resume_template:
qbittorrent_mod:
action:
resume:
#如果保存路径上没有种子在正常做种,则重新校验种子,配合跳检,将种子还原成0进度状态
recheck_torrents: true
#连接数管理
qbittorrent_manage_conn_template:
qbittorrent_mod:
action:
#基于 当前连接数 + step 设置最大连接数,最小不低于 min, 最大不高于 max
manage_conn:
min: 100
max: 2000
# 根据tracker状态限制上传
qbittorrent_limit_upload_by_tracker_template:
qbittorrent_mod:
action:
limit_upload_by_tracker:
# 0为不限速,单位 byte
working: 0
not_working: 1
#删除
qbittorrent_delete_keeper_template:
qbittorrent_mod:
action:
remove:
keeper:
#array: 检查pt1,pt2的种子,全部满足删除条件则删除,包括辅种
check_reseed:
- pt1
- pt2
#删种同时数据
delete_files: true
#磁盘剩余空间小于 10 GiB时,才执行删除
keep_disk_space: 10
#删除成功后限制下载速度为 0 (不限速)
dl_limit_on_succeeded: 0
#删除成功后限制备用下载速度为 8 MiB
alt_dl_limit_on_succeeded: 8388608
#如执行任务后空间小于keep_disk_space,则自动限速为 (剩余空间 / dl_limit_interval) KiB/s, 不超过dl_limit_on_succeeded
#单位:秒
dl_limit_interval: 900
#清理
qbittorrent_delete_cleaner_template:
qbittorrent_mod:
action:
remove:
cleaner:
delete_files: yes
schedules:
- tasks: [xxxx, xxxx, rss_download]
interval:
#1分钟
minutes: 1
- tasks: [reseed, resume, delete, modify, clean]
interval:
minutes: 5
- tasks: [xxxxx]
interval:
minutes: 10
- tasks: [sign_in, warner]
schedule:
#8点到23点 每小时执行一次
hour: 8-23/1
#任务列表
tasks:
rss1:
#官方插件:rss 订阅链接
rss:
url: https://pt1.com/rss
#官方说这样会提高速度
all_entries: no
no_entries_ok: yes
#官方插件:regexp 过滤器 接受带有 CCTV 字样的种子
regexp:
accept:
- CCTV
from: title
#基础+添加种子(模板配置会自动合并)
template:
- qbittorrent_base_template
- qbittorrent_add_template
rss2:
# 相同过滤条件的rss可以放到一个inputs下
inputs:
- rss: https://pt1.com/rss
- rss: https://pt2.com/rss
#官方插件:accept_all 过滤器 接受全部
accept_all: yes
template:
- qbittorrent_base_template
- qbittorrent_add_template
pt3:
#网页获取下载数据 需要有css选择器知识 以下是打开碟片的置顶种子设置
html_rss:
url: https://pt3.com/torrents.php
headers:
cookie: 'xxxxxxxxxxxxxxxxxx'
user-agent: '{? headers.user_agent ?}'
#用于下载种子时的附件信息 v0.3.2 修改
#以 "&" 开头时附加在下载链接之后,否则使用 urljoin 方式拼接
params: '&passkey=xxxxxxxxxxxxx'
#组件选择器
root_element_selector: '#form_torrent > table > tbody > tr.topdown_bg'
#以下配置基于上面 组件选择器 匹配到的组件做二次匹配
fields:
#标题(必选)
#为 entry 增加 title 属性 值为 匹配到的组件下的 title 属性
title:
#二次选择器
element_selector: 'a[href*="details.php"]'
#提取属性
attribute: title
#链接(必选)
#为 entry 增加 url 属性 值为 匹配到的组件下的 href 属性
url:
element_selector: 'a[href*="download.php"]'
attribute: href
#除title url属性为必选,其它可自由添加用于过滤
#示例 增加促销信息
#为 entry 增加 promotion 属性 值为 匹配到的组件下的 alt 属性
promotion:
element_selector: 'div[style="padding-bottom: 5px"] > img'
attribute: alt
no_entries_ok: yes
#如果promotion带有 Free则接受
if:
- promotion in ['Free']: accept
template:
- qbittorrent_base_template
- qbittorrent_add_template
#自动辅种 使用 IYUU 提供的接口
reseed:
#优先级 1
priority: 1
#插件优先级
plugin_priority:
#数字越大执行越早,先从from_qbittorrent_mod获取种子,再执行iyuu_auto_reseed
from_qbittorrent_mod: 250
iyuu_auto_reseed: 240
iyuu_auto_reseed:
#IYUU token 获取方法请查阅顶部介绍的 IYUUAutoReseed 项目
iyuu: xxxxxxxxxxxxxxxxxxxx
#站点密钥
passkeys:
#key: 站点域名包含字符串 value:密钥
#例 pt123.xyz
pt123: xxxxxxxxxxxxxxxxxxxx
# abc456.cn
abc456: xxxxxxxxxxxxxxxxxxxx
accept_all: yes
#只拒绝相同 torrent_info_hash 的种子
seen:
fields:
- torrent_info_hash
qbittorrent_mod:
action:
add:
# 给辅种的种子打上 reseed 标签
tags: reseed
#跳过校验
skip_checking: yes
reject_on:
#忽略dl_speed 始终添加
dl_speed: no
#忽略dl_limit 始终添加
dl_limit: no
#忽略all 始终添加
all:no
template:
- qbittorrent_base_template
- qbittorrent_add_template
- from_qbittorrent_template
#自动开始
resume:
priority: 2
disable: [seen, seen_info_hash, retry_failed]
if:
#选择进度100%、暂停状态、标记为 reseed 、1小时内(防止停止任务后又重新开始)添加的的种子
- qbittorrent_state == 'pausedUP' and 'reseed' in qbittorrent_tags and qbittorrent_added_on > now - timedelta(hours=1): accept
template:
- from_qbittorrent_template
- qbittorrent_base_template
- qbittorrent_resume_template
#自动删种
delete:
priority: 3
#官方插件:disable 关闭任务记录 失败重试
disable: [seen, seen_info_hash, retry_failed]
#官方插件: if 过滤器
if:
#参考entry属性列表
#种子在 Rss分类 并且 最后活动时间 < 2天
- qbittorrent_category in ['Rss'] and qbittorrent_last_activity < now - timedelta(days=2): accept
#种子数据丢失 或者 (种子处于未完成的暂停状态 并且 完成大小为0):一般是辅助失败的种子
- qbittorrent_state == 'missingFiles' or (qbittorrent_state in ['pausedDL'] and qbittorrent_completed == 0): accept
#如种子的tag带有 pt1 并且做种时间小于48小时则拒绝 v0.2.9新增:seeding_time share_ratio属性
- "'pt1' in qbittorrent_tags and qbittorrent_seeding_time<48*60*60": reject
#官方sort_by插件:按最后活动时间从早到晚排序 优先删除
sort_by: qbittorrent_last_activity
template:
- from_qbittorrent_template
- qbittorrent_base_template
- qbittorrent_delete_keeper_template
#修改种子信息
modify:
priority: 4
disable: [seen, seen_info_hash, retry_failed]
accept_all: yes
template:
- from_qbittorrent_template
- qbittorrent_base_template
- qbittorrent_modify_template
#清理种子
clean:
priority: 5
disable: [seen, seen_info_hash, retry_failed]
if:
# 清理 标记为 reseed 且 未下载完 且 不在校验状态的种子
- "'reseed' in qbittorrent_tags and not qbittorrent_completed == qbittorrent_total_size and 'checking' not in qbittorrent_state": accept
# 清理 tracker 信息匹配的种子
regexp:
accept:
- '[Tt]orrent not registered with this tracker'
- 'Torrent banned'
- 'Unregistered torrent'
- '006-种子尚未上传或者已经被删除'
- 'Torrent is not authorized for use on this tracker.'
from: qbittorrent_tracker_msg
template:
- from_qbittorrent_template
- qbittorrent_base_template
- qbittorrent_delete_cleaner_template
#连接数管理
manage_conn:
disable: [seen, seen_info_hash, retry_failed]
from_qbittorrent_mod:
server_state: yes
accept_all: yes
if:
#当IO任务队列小于 20 时,设置step为 +50
- 'server_state["queued_io_jobs"] < 20':
set:
step: 50
#当IO任务队列大于 80 时,设置step为 -100
- 'server_state["queued_io_jobs"] > 80':
set:
step: -100
template:
- from_qbittorrent_template
- qbittorrent_base_template
- qbittorrent_manage_conn_template
#- show_entry_template
# 防白嫖
limit_upload_by_tracker:
disable: [seen, seen_info_hash, retry_failed]
if:
# 筛选 不在暂停状态 且 添加时间大于 5分钟 的种子
- "'paused' not in qbittorrent_state and qbittorrent_added_on < now - timedelta(minutes=5)": accept
from_qbittorrent_mod:
# 强制重新获取trakcer状态
force_update: yes
template:
- from_qbittorrent_template
- qbittorrent_base_template
- qbittorrent_limit_upload_by_tracker_template
#自动签到
sign_in:
auto_sign_in:
user-agent: '{? headers.user_agent ?}'
#baidu ocr参数
aipocr:
app_id: 'xxxxxxxxx'
api_key: 'xxxxxxxxx'
secret_key: 'xxxxxxxxx'
#默认所有站点都获取未读消息
sites:
#已适配网站(查看ptsites/sites下站点)
1ptba: 'xxxxxxxxxxxxx'
accept_all: yes
retry_failed:
retry_time_multiplier: no
seen:
fields:
- title
notify:
task:
always_send: false
message: |+
{%- if task.accepted -%}
{%- for group in task.accepted|groupby('task') -%}
FlexGet has just signed in {{ group.list|length }} sites for task {{ group.grouper }}:
{% for entry in group.list %}
{{ loop.index }}: {{ entry.title }} {{ entry.result }}
{%- if entry.messages|d('') %}
Messages: {{ entry.messages }}
{% endif %}
{%- endfor -%}
{%- endfor -%}
{%- endif -%}
{%- if task.failed %}
{% for group in task.failed|groupby('task') %}
The following sites have failed for task {{ group.grouper }}:
{% for entry in group.list %}
{{ loop.index }}: {{ entry.title }} Reason: {{ entry.reason|d('unknown') }}
{%- if entry.messages|d('') %}
Messages: {{ entry.messages }}
{% endif %}
{%- endfor -%}
{%- endfor -%}
{%- endif -%}
via:
- wechat_work:
corp_id: 'xxxxxxxxxxxxx'
corp_secret: 'xxxxxxxxxxxxxxx'
agent_id: 'xxxxxxxxxxxxxxxx'
to_user: 'xxxxxxxxxxxxxxx'
#发送统计图片
image: 'details_report.png'
- telegram:
bot_token: xxxxxxxxxxx
recipients:
- username: 'xxxxxxxxxxx'
#服务器状态预警
warner:
disable: [seen, seen_info_hash, retry_failed]
from_qbittorrent_mod:
# 生成带 server_state 的唯一entry, 并设置 title 为 'qBittorrent Server State'
server_state: 'qBittorrent Server State'
if:
# qBittorrent 不可连接
- 'not server_state["flexget_connected"]': accept
# 下载速度 < 1 MiB
- 'server_state["dl_info_speed"] < 1048576': accept
# 上传速度 < 1 MiB
- 'server_state["up_info_speed"] < 1048576': accept
# 磁盘剩余空间< 5 GiB
- 'server_state["free_space_on_disk"] < 5368709120': accept
template:
- from_qbittorrent_template
notify:
entries:
message: |+
{{ time }}
{{ title }}:
{% if not server_state.flexget_connected -%}
flexget_connected: False
{%- else -%}
dl_info_speed: {{(server_state['dl_info_speed']/1024/1024)|int}} MiB
up_info_speed: {{(server_state['up_info_speed']/1024/1024)|int}} MiB
free_space_on_disk: {{(server_state['free_space_on_disk']/1024/1024/1024)|int}} GiB
{% endif %}
via: *via_setting
#种子转移
transfer:
disable: [ seen, seen_info_hash, retry_failed ]
show_entry:
state: accepted
attribute:
- url
regexp:
accept:
# gazellegames 分类
- gazellegames:
set:
# file:/BT_backup/ 路径为被转移qbittorrent的BT_backup
# doker映射例子:/docker/qbittorrent2/config/data/qBittorrent/BT_backup/:/BT_backup
url: 'file:/BT_backup/{{torrent_info_hash}}.torrent'
#设置分类为被转移分类,需要手动先创建分类并指定路径
category: '{{qbittorrent_category}}'
from: qbittorrent_category
qbittorrent_mod:
host: qbittorrent1.example.com
port: 443
use_ssl: yes
username: xxxxxxxx
password: xxxxxxxx
action:
add:
skip_checking: yes
reject_on:
dl_speed: no
dl_limit: no
all: no
from_qbittorrent_mod:
host: qbittorrent2.example.com
port: 443
use_ssl: yes
username: xxxxxxxx
password: xxxxxxxx