Skip to content

Commit

Permalink
relrase v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rachpt committed Dec 20, 2018
1 parent be06e78 commit 1749fbd
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 97 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

An Autoseed used to reseed Movies in PT sites powered by shell scripts. Get a python version [HERE](https://github.com/Rhilip/Pt-Autoseed).

目前适用于 从 HDSky / TTG / HDChina / CMCT / M-Team 等站点自动转载 电影 [针对 iPad 资源特别优化] 至 HUDBT / WHUPT / NPUBITS / NanYangPT / BYRBT / 北洋园 PT 站。
目前适用于 从 HDSky / TTG / HDChina / CMCT / M-Team 等站点自动转载 电影、剧集、纪录片 [针对 iPad 资源特别优化] 至 HUDBT / WHUPT / NPUBITS / NanYangPT / BYRBT / 北洋园 PT 站。

[![release](https://img.shields.io/badge/Version-3.0-brightgreen.svg)](https://github.com/rachpt/AutoSeed/releases/tag/v3.0) [![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg)](https://raw.githubusercontent.com/rachpt/AutoSeed/master/LICENSE)

Expand All @@ -15,9 +15,9 @@ An Autoseed used to reseed Movies in PT sites powered by shell scripts. Get a py
| https://tp.m-team.cc | https://bt.byr.cn | 2018-06-17 |
| | https://hdcmct.org | 2018-07-28 |
| | https://tjupt.org | 2018-08-28 |
| | | 2018-10-23 |
| 不限\* | | 2018-10-23 |

\* 源站点表示支持抓取其部分简介用于发布.
\* 源站点表示支持抓取其部分简介用于发布,没有则本地生成简介.

## 特点

Expand All @@ -26,7 +26,7 @@ An Autoseed used to reseed Movies in PT sites powered by shell scripts. Get a py
- 支持自动 Dupe 以及禁转判断。
- 开箱即用,不需要使用数据库等复杂操作。
- 速度快,使用临时文件提前生成简介。
- 自动判断并处理简介缺失海报情况
- 几乎全自动


## 环境要求
Expand All @@ -35,7 +35,7 @@ An Autoseed used to reseed Movies in PT sites powered by shell scripts. Get a py
- 软件:
- transmission-daemon,transmission-remote,transmission-show,edit 安装`sudo apt-get install transmission-cli`
- qBittorrent v4.1+, 如果选择使用该客户端做种(transmission-show,edit 为必须项!);
- httpie 1.0+,安装命令`sudo apt-get install httpie`
- httpie 0.9.8+,安装命令`sudo apt-get install httpie`
- 其他常用软件工具,sed,grep,awk等(详见 setting.sh,一般系统自带);
- 默认使用`python3`本地解析豆瓣简介(作为最后的办法),感谢 [@Rhilip](https://github.com/Rhilip/PT-help/blob/master/modules/infogen/gen.py) 的脚本,Python相关依赖自行查看安装。

Expand Down Expand Up @@ -103,6 +103,11 @@ t_id: [55997]

## 更新日志

- 2018-12-19 --> 3.0 (release)
- 完善clean模块,部分功能使用多线程。
- 新的qbittorrent分享率设置实现。
- 代码稳定性增强。

- 2018-12-08 --> 3.0 (开发版,几乎完成)
- 重构几乎全部代码,以支持更多的站点。
- 使用豆瓣豆瓣,尽量保留原始 iNFO 以及 screens,没有则生成。
Expand All @@ -116,4 +121,4 @@ t_id: [55997]

## 实现流程

![流程图](https://ws1.sinaimg.cn/large/675bda05ly1fy1k3xtkv4j20q90ph432.jpg)
![流程图](https://ws1.sinaimg.cn/large/675bda05ly1fyd32i63xvj20oy0sdted.jpg)
12 changes: 6 additions & 6 deletions clean/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#
# Author: rachpt@126.com
# Version: 3.0v
# Date: 2018-12-18
# Date: 2018-12-19
#-----------------------------#
#
# Auto clean old files/folders in
# watch-dir which are not seeding
# on transmission#.
# on transmission and qbittorrent.
#
#---import settings---#
if [ -z "$ROOT_PATH"]; then
Expand Down Expand Up @@ -45,7 +45,7 @@ comparer_file_and_delete() {
[ "$tr" = 'yes' ] && tr_is_seeding "$i"
[[ $qb != yes && $tr != yes ]] && delete_commit='no'
if [ "$i" ] && [ "$delete_commit" = 'yes' ]; then
debug_func 'tr:del:'"$i" #----debug---
debug_func "tr:del:[$i]" #----debug---
rm -rf "$FILE_PATH/$i"
echo "[$(date '+%m-%d %H:%M:%S')]deleted Torrent[$i]" >> "$log_Path"
fi
Expand Down Expand Up @@ -86,14 +86,13 @@ clean_dir() {
add_to_dir=0 # give up add
break; }
done
[[ $add_to_dir -eq 1 ]] && [ "$one_TR_Dir" ] && echo -e "$one_TR_Dir" >> "$ROOT_PATH/clean/dir"
[[ $add_to_dir -eq 1 && $one_TR_Dir ]] && echo -e "$one_TR_Dir" >> "$ROOT_PATH/clean/dir"
fi
unset line add_to_dir
}

clean_frequence() {
local time_threshold=$(expr 60 \* 60 \* 12) # 12 hours
local time_threshold=12 # 12 hours
local time_pass=$(expr $(date '+%s') - $(stat -c '%Y' "$ROOT_PATH/clean/dir"))
[ $time_pass -gt $time_threshold ] && {
clean_main
Expand All @@ -119,5 +118,6 @@ clean_main() {

#---------call func-----------#
clean_dir
# need more test !!!
# maybe need more test !!!
clean_frequence

4 changes: 2 additions & 2 deletions clean/qb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Author: rachpt@126.com
# Version: 3.0v
# Date: 2018-12-18
# Date: 2018-12-19
#
#---------------------------------------#
qb_delete_old() {
Expand All @@ -20,7 +20,7 @@ qb_delete_old() {
grep -B1 "state.*pausedUP"|grep hash|sed 's/hash:[ ]*//;s/,//')"
[[ $dat ]] && echo "$data"|while read one
do
debug_func 'qb:del:'"$one" #----debug---
debug_func "qb:del:[$one]" #----debug---
local torrent_hash="$one"
qb_delete_torrent
done
Expand Down
3 changes: 3 additions & 0 deletions edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Date: 2018-12-08
#
#------------------------------------#
this_mode_is_not_use_now(){
#---main.sh is running?---#
pidof -x main.sh
if [ $? -eq 0 ]; then
Expand Down Expand Up @@ -97,3 +98,5 @@ done
#------------------------------------#
#---clean---#
rm -f "$source_desc" "$source_html"
}
echo '此模块暂时不使用!'
63 changes: 37 additions & 26 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@
#
# Author: rachpt@126.com
# Version: 3.0v
# Date: 2018-12-14
# Date: 2018-12-18
#
#-----------import settings-------------#
ROOT_PATH="$(dirname "$(readlink -f "$0")")"
# use source run
[[ $ROOT_PATH == /*bin* ]] && \
ROOT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$ROOT_PATH/settings.sh"
#---------------------------------------#
# import functions
source "$ROOT_PATH/get_desc/detail_page.sh"
#----------------lock func--------------#
remove_lock() {
rm -f "$lock_File"
debug_func 'main_unlock' #----debug---
rm -f "$lock_File" "$qb_rt_queue"
debug_func 'main:unlock' #----debug---
}
is_locked() {
if [ -f "$lock_File" ]; then
exit
else
set -o noclobber # 禁止重定向覆盖
set -o noclobber # 禁止重定向覆盖
echo "$$" > "$lock_File"
set +o noclobber # 允许重定向覆盖
debug_func 'main_lock' #----debug---
set +o noclobber # 允许重定向覆盖
debug_func 'main:locked' #----debug---
trap remove_lock INT TERM EXIT
fi
}
Expand All @@ -32,12 +35,12 @@ is_locked() {
write_log_begin() {
echo "-------------[start]-------------" >> "$log_Path"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')]\c" >> "$log_Path"
echo "准备发布[$org_tr_name]" >> "$log_Path"
echo "准备发布:[$org_tr_name]" >> "$log_Path"
}
write_log_end() {
echo "+++++++++++++++++++++++++++++++++" >> "$log_Path"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')]\c" >> "$log_Path"
echo "已经发布[$org_tr_name]" >> "$log_Path"
echo "已经发布:[$org_tr_name]" >> "$log_Path"
}

#---------------------------------------#
Expand All @@ -48,7 +51,7 @@ torrent_completed_precent() {
elif [ "$fg_client" = 'transmission' ]; then
tr_get_torrent_completion
else
debug_func 'main_Client_Error' #----debug---
debug_func 'main:Client_Error' #----debug---
fi
}

Expand All @@ -62,15 +65,15 @@ generate_desc() {
torrent_Path="${flexget_path}/$tr_i"
# org_tr_name 用于和 transmission/qb 中的种子名进行比较,
org_tr_name="$($tr_show "$torrent_Path"|grep Name|head -1|sed -r 's/Name:[ ]+//')"
debug_func 'main_1:gl' #----debug---
debug_func 'main:gen_loop' #----debug---
one_TR_Name="$org_tr_name"
#---generate desc before done---#
if [ ! -s "${ROOT_PATH}/tmp/${org_tr_name}_desc.txt" ]; then
[ ! "$test_func_probe" ] && torrent_completed_precent
[ "$test_func_probe" ] && completion=100 # convenient for test
debug_func 'main_comp-'"$completion" #----debug---
[ "$test_func_probe" ] && completion=100 # convenient for test
debug_func "mainr:completed-[$completion]" #----debug---
[ "$completion" ] && [ "$completion" -ge '70' ] && {
debug_func 'main_2:gdesc' #----debug---
debug_func 'main:gen_desc' #----debug---
unset completion source_site_URL
source "$ROOT_PATH/get_desc/desc.sh"
unset source_site_URL; }
Expand All @@ -90,29 +93,30 @@ main_loop() {
org_tr_name="$("$tr_show" "${flexget_path}/$tr_i"|grep 'Name'| \
head -1|sed -r 's/Name:[ ]+//')"

debug_func 'main_3:ml' #----debug---
debug_func 'main:m_loop' #----debug---
#-----------------------------------------------
if [ "$org_tr_name" = "$one_TR_Name" ]; then
#---.torrient file path---#
torrent_Path="${flexget_path}/$tr_i"
#---desc---#
if [ ! -s "${ROOT_PATH}/tmp/${org_tr_name}_desc.txt" ]; then
debug_func 'main_:Failed to find desc' #----debug---
debug_func 'main:failed to find desc' #----debug---
break
else
debug_func 'main_4:post' #----debug---
debug_func 'main:post' #----debug---
write_log_begin # write log
source "$ROOT_PATH/post/post.sh"
write_log_end # write log
# delete uploaded torrent
[ ! "$test_func_probe" ] && \
rm -f "$torrent_Path" && \
clean_commit_main='have_not_test'
clean_commit_main='yes'
fi
fi
done
#---clean & remove old torrent---#
if [ "$clean_commit_main" = 'yes' ]; then
debug_func 'main:clean' #----debug---
source "$ROOT_PATH/clean/clean.sh"
fi
}
Expand All @@ -128,7 +132,7 @@ time_out() {
if [[ $main_pid && $run_time -gt $waitfor ]]; then
# 处理超时
kill -9 $main_pid
rm -f "$lock_File" "$ROOT_PATH/tmp/autoseed-pic.*"
rm -f "$lock_File" "$qb_rt_queue" "$ROOT_PATH/tmp/autoseed-pic.*"
else
# 重复运行
debug_func '主程序正在运行,稍后重试!'
Expand All @@ -152,13 +156,13 @@ if [ "$#" -eq 2 ]; then
# qbittorrent, 2 parameter
Torrent_Name="$1"
Tr_Path="$2"
debug_func 'main_0:qb_in' #----debug---
debug_func 'main:run_from_qb' #----debug---
else
# transmission, no parameter
Torrent_Name="$TR_TORRENT_NAME"
Tr_Path="$TR_TORRENT_DIR"
[[ $TR_TORRENT_NAME ]] && sleep 2 && \
debug_func 'main_0:tr_in' #----debug---
debug_func 'main:run_from_tr' #----debug---
fi
[[ $Torrent_Name && $Tr_Path ]] && \
echo -e "${Torrent_Name}\n${Tr_Path}" >> "$queue"
Expand All @@ -183,16 +187,23 @@ while true; do
one_TR_Dir="$(head -2 "$queue"|tail -1|sed 's!/$!!')"
[[ ! "$one_TR_Name" || ! "$one_TR_Dir" ]] && break
[[ $main_lp_counter -gt 50 ]] && break
debug_func 'main_5:qu' #----debug---
debug_func 'main:queue_loop' #----debug---

if [ "$(find "$flexget_path" -iname '*.torrent*')" ]; then
hold_on # dynamic delay
debug_func 'main_6:q.p' #----debug---
hold_on # dynamic delay
debug_func 'main:queue_in' #----debug---
main_loop
fi
[ ! "$test_func_probe" ] && \
sed -i '1,2d' "$queue" # delete record
((main_lp_counter++)) # C 形式的增1
sed -i '1,2d' "$queue" # delete record
((main_lp_counter++)) # C 形式的增1
qb_reannounce
sleep 2
done

# qbittorrent set ratio
qb_set_ratio_loop
#---------------------------------------#
debug_func 'main_exit' #----debug---
# reannounce
tr_reannounce
qb_reannounce
Loading

0 comments on commit 1749fbd

Please sign in to comment.