xcy1020 大佬有话说 : 2019-11-25 17:37:45
【更新分享率控制】qBittorrent + Rclone 自动上传脚本
本帖最后由 xcy1020 于 2019-12-1 15:49 编辑
通过添加标签或者分类,再添加定时任务,可以指定种子分享率达到期望值再删除数据,避免吸血
请自行安装jq
确保两个脚本的auto_del_flag变量一致,否则没办法删除分享率达标的种子
只吸血的同学只需要将qu_auto.sh的leeching_mode设为true即可
需要控制分享率的需要两个脚本
并添加监控任务
*/1 * * * * bash /root/ratio_mon.sh
——————————————————————————————————————
闲着无聊写了个qb+Rclone自动上传到Google Drive的脚本
大佬们那么多无限容量Google Drive,不塞点东西浪费了
水平有限,写得有点烂,各位大佬见笑了
支持qBittorrent v3.2.0+
不支持v3.1.x
实测v4.2.0Beta1功能可用
其他版本未测,等大佬测试反馈!
配合RSS+磁盘配额控制的话,应该可以全自动,坐等大佬写
yc003t
使用方法:
qB WEB UI 勾选“Torrent 完成时运行外部程序”
填上:
bash /root/qb_auto.sh"%N" "%F" "%R" "%D" "%C" "%Z" "%I"
https://s2.ax1x.com/2019/11/25/Mvmv5j.jpg
chmod +x qb_auto.sh
自行配置好rclone即可
qb_auto.sh
——————————————————————————————————————
#!/bin/sh
torrent_name=$1
content_dir=$2
root_dir=$3
save_dir=$4
files_num=$5
torrent_size=$6
file_hash=$7
qb_version="4.2.0" #如4.0.4、4.1.9.1、4.2.0等,不支持3.1.X
qb_username="hostloc" #qb用户名
qb_password="hostloc.com" #qb密码
qb_web_url="https://hostloc.com" #QB web路径,可以填写本地http://localhost:8080
leeching_mode="true" #吸血模式 设为true 上传完后自动删除种子及数据 否则不删除,继续做种
log_dir="/root/qbauto" #日志目录
rclone_dest="gdrive" #rclone destination关键字 运行rclone config查看name字段即可
rclone_parallel="32" #rclone上传线程 默认4
auto_del_flag="rclone"#添加标签或者分类来标识已上传的种子 v4.0.4+版本添加标签“rclone”,低版本通过添加分类“rclone”标识
if [ ! -d ${log_dir} ]
then
mkdir -p ${log_dir}
fi
version=$(echo $qb_version | grep -P -o "(.){2}" | sed s/\.//g)
function qb_login(){
if [ ${version} -gt 404 ]
then
qb_v="1"
cookie=$(curl -i –header "Referer: ${qb_web_url}" –data "username=${qb_username}&password=${qb_password}" "${qb_web_url}/api/v2/auth/login" | grep -P -o ‘SID=S{32}’)
if [ -n ${cookie} ]
then
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 登录成功!cookie:${cookie}" >> ${log_dir}/autodel.log
else
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 登录失败!" >> ${log_dir}/autodel.log
fi
elif [[ ${version} -le 404 && ${version} -ge 320 ]]
then
qb_v="2"
cookie=$(curl -i –header "Referer: ${qb_web_url}" –data "username=${qb_username}&password=${qb_password}" "${qb_web_url}/login" | grep -P -o ‘SID=S{32}’)
if [ -n ${cookie} ]
then
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 登录成功!cookie:${cookie}" >> ${log_dir}/autodel.log
else
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 登录失败" >> ${log_dir}/autodel.log
fi
elif [[ ${version} -ge 310 && ${version} -lt 320 ]]
then
qb_v="3"
echo "陈年老版本,请及时升级"
exit
else
qb_v="0"
exit
fi
}
function qb_del(){
if [ ${leeching_mode} == "true" ]
then
if [ ${qb_v} == "1" ]
then
curl "${qb_web_url}/api/v2/torrents/delete?hashes=${file_hash}&deleteFiles=true" –cookie ${cookie}
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 删除成功!种子名称:${torrent_name}" >> ${log_dir}/qb.log
elif [ ${qb_v} == "2" ]
then
curl -X POST -d "hashes=${file_hash}" "${qb_web_url}/command/deletePerm" –cookie ${cookie}
else
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 删除成功!种子文件:${torrent_name}" >> ${log_dir}/qb.log
echo "qb_v=${qb_v}" >> ${log_dir}/qb.log
fi
else
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 不自动删除已上传种子" >> ${log_dir}/qb.log
fi
}
function rclone_copy(){
if [ ${type} == "file" ]
then
rclone_copy_cmd=$(rclone -v copy –transfers ${rclone_parallel} –log-file${log_dir}/qbauto_copy.log "${content_dir}" ${rclone_dest}:qbauto/)
elif [ ${type} == "dir" ]
then
rclone_copy_cmd=$(rclone -v copy –transfers ${rclone_parallel} –log-file ${log_dir}/qbauto_copy.log "${content_dir}"/ ${rclone_dest}:qbauto/"${torrent_name}")
fi
}
function qb_add_auto_del_tags(){
if [ ${qb_v} == "1" ]
then
curl -X POST -d "hashes=${file_hash}&tags=${auto_del_flag}" "${qb_web_url}/api/v2/torrents/addTags" –cookie "${cookie}"
elif [ ${qb_v} == "2" ]
then
curl -X POST -d "hashes=${file_hash}&category=${auto_del_flag}" "${qb_web_url}/command/setCategory" –cookie ${cookie}
else
echo "qb_v=${qb_v}" >> ${log_dir}/qb.log
fi
}
if [ -f "${content_dir}" ]
then
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 类型:文件" >> ${log_dir}/qb.log
type="file"
rclone_copy
qb_login
qb_add_auto_del_tags
qb_del
elif [ -d "${content_dir}" ]
then
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 类型:目录" >> ${log_dir}/qb.log
type="dir"
rclone_copy
qb_login
qb_add_auto_del_tags
qb_del
else
echo "[$(date ‘+%Y-%m-%d %H:%M:%S’)] 未知类型,取消上传" >> ${log_dir}/qb.log
fi
echo "种子名称:${torrent_name}" >> ${log_dir}/qb.log
echo "内容路径:${content_dir}" >> ${log_dir}/qb.log
echo "根目录:${root_dir}" >> ${log_dir}/qb.log
echo "保存路径:${save_dir}" >> ${log_dir}/qb.log
echo "文件数:${files_num}" >> ${log_dir}/qb.log
echo "文件大小:${torrent_size}Bytes" >> ${log_dir}/qb.log
echo "HASH:${file_hash}" >> ${log_dir}/qb.log
echo "Cookie:${cookie}" >> ${log_dir}/qb.log
echo -e "————————————————————-n" >> ${log_dir}/qb.log
——————————————————————————————————————
ratio_mon.sh
帖子长度限制 贴不出,自行下载压缩文件
——————————————————————————————————————
Luna 大佬有话说 : 2019-11-26 00:26:29
简单版本,只管上传:
/home/qbtuser/up.sh "%F" "%N"
#!/bin/bash
file=$1
if [ -d "$file" ];then
rclone copy "$1" gd:/Downloads/"$2"
elif [ -f "$file" ]; then
rclone copy "$1" gd:/Downloads/
fi
懒无止境丶 大佬有话说 : 2019-11-25 17:38:37
第一次离大佬这么近:lol
creeper1 大佬有话说 : 2019-11-25 17:39:06
不错不错,等我搞个馒头账号租个3o去
C51 大佬有话说 : 2019-11-25 17:39:36
上传到gd算保种不?
xcy1020 大佬有话说 : 2019-11-25 17:40:53
C51 大佬有话说 : 2019-11-25 17:39
上传到gd算保种不?
yc022t本地不删继续保种就行,下完传完就删,那肯定是吸血
飘云 大佬有话说 : 2019-11-25 17:41:45
亲,要的就是这个,非常感谢!!!
xxhjkl 大佬有话说 : 2019-11-25 17:43:49
这个配合pt的话 搬运大jj爽啊
jpfree 大佬有话说 : 2019-11-25 17:53:38
一般小硬盘才用,大营坡用不上吧。。。
还要留种
etc 大佬有话说 : 2019-11-25 18:01:41
未知类型,取消上传yc002t
不知道什么原因
topman2018 大佬有话说 : 2019-11-25 18:04:59
牛啊。。3O的专用了吧