55# # 2. 检查暂停清单(就是qbittorrent筛选“暂停”的清单),检测该清单中100%下载完成/100%校验通过的种子,将这些种子恢复做种。校验未通过不达100%完成率的种子不会启动,仍然保持暂停状态。
66
77. /usr/local/bin/share
8+ if [[ $( qbittorrent-nox -v | awk ' {print $2}' ) == " v5." * ]]; then
9+ mark_states=stopped
10+ mark_start=start
11+ else
12+ mark_states=paused
13+ mark_start=resume
14+ fi
815
916# # 检测出需要校验的种子并发起校验
1017downloading_info=$( $cmd_curl " ${api_url_base} /torrents/info?filter=downloading" )
@@ -14,7 +21,7 @@ recheck_hashes=""
1421for (( i= 0 ; i< ${# downloading_hashes[*]} ; i++ )) ; do
1522 piece_states=" "
1623 piece_states=$( $cmd_curl " $api_url_base /torrents/pieceStates?hash=${downloading_hashes[i]} " )
17- if [[ ${downloading_states[i]} == pausedDL && ${piece_states} != * 2* ]]; then
24+ if [[ ${downloading_states[i]} == ${mark_states} DL && ${piece_states} != * 2* ]]; then
1825 recheck_hashes=" ${recheck_hashes} |${downloading_hashes[i]} "
1926 fi
2027done
2936
3037# # 检测校验完成的种子,并对100%完成率的种子恢复做种
3138sleep 1
32- paused_info=$( $cmd_curl " ${api_url_base} /torrents/info?filter=paused " )
39+ paused_info=$( $cmd_curl " ${api_url_base} /torrents/info?filter=${mark_states} " )
3340paused_hashes=( $( echo $paused_info | jq -r .[].hash) )
3441paused_states=( $( echo $paused_info | jq -r .[].state) )
3542resume_hashes=" "
3643for (( i= 0 ; i< ${# paused_hashes[*]} ; i++ )) ; do
3744 piece_states=" "
3845 piece_states=$( $cmd_curl " $api_url_base /torrents/pieceStates?hash=${paused_hashes[i]} " )
39- if [[ ${paused_states[i]} == pausedUP && ${piece_states} != * 0* && ${piece_states} != * 1* ]]; then
46+ if [[ ${paused_states[i]} == ${mark_states} UP && ${piece_states} != * 0* && ${piece_states} != * 1* ]]; then
4047 resume_hashes=" ${resume_hashes} |${paused_hashes[i]} "
4148 fi
4249done
43- echo " hashes=${resume_hashes/ |/ } " | $cmd_curl_post " $api_url_base /torrents/resume " -d @-
50+ echo " hashes=${resume_hashes/ |/ } " | $cmd_curl_post " $api_url_base /torrents/$mark_start " -d @-
4451resume_hashes_sum=$( echo ${resume_hashes/ |/ } | awk -F " |" ' {print NF}' )
4552if [[ $resume_hashes_sum -gt 0 ]]; then
4653 echo " (N) $( date +' %Y-%m-%dT%H:%M:%S' ) - [$( basename $0 ) ] qbittorrent客户端对 ${resume_hashes_sum} 个种子恢复做种"
0 commit comments