├── LICENSE ├── README.md ├── _config.yml ├── clean ├── clean.sh ├── dir ├── qb.sh └── tr.sh ├── get_desc ├── customize.sh ├── db_info.sh ├── desc.sh ├── detail_page.sh ├── extract.sh ├── font │ └── cyberbit.ttf ├── gen.py ├── generate.sh ├── hdsky_adoption.sh ├── html2bbcode.sh ├── info.sh ├── match.sh └── screens.sh ├── main.sh ├── post ├── add.sh ├── byrbt.sh ├── cmct.sh ├── hudbt.sh ├── judge.sh ├── mteam.sh ├── nanyangpt.sh ├── neu6.sh ├── npupt.sh ├── parameter.sh ├── post.sh ├── tjupt.sh ├── tlfbits.sh ├── whu.sh └── xseed ├── qbittorrent.sh ├── settings.sh ├── static.sh ├── test.sh ├── tmp ├── db │ └── sample.txt ├── dupe-rules.txt ├── log ├── match-lists.txt ├── queue └── series-imdb.txt └── transmission.sh /README.md: -------------------------------------------------------------------------------- 1 | # AutoSeed 2 | 3 | An Autoseed used to reseed Movies in PT sites powered by shell scripts. Get a python version [HERE](https://github.com/Rhilip/Pt-Autoseed). 4 | 5 | 目前适用于 从 HDS / TTG / HDC / CMCT / MTeam 等站点自动转载 电影、剧集、纪录片 [针对 iPad 资源特别优化] 至 HUDBT / WHU / NPUPT / NYPT / BYRBT / TJUPT。 6 | 7 | [![release](https://img.shields.io/badge/Version-3.1-brightgreen.svg)](https://github.com/rachpt/AutoSeed/releases/tag/v3.1) [![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg)](https://raw.githubusercontent.com/rachpt/AutoSeed/master/LICENSE) 8 | 9 | | 源站点(from) | 支持站点(to) | 时间(time) | 10 | | :--------------: | :------------: | :----------: | 11 | | hds | hudbt | 2018-05-19 | 12 | | ttg | whu | 2018-05-21 | 13 | | hdc | npupt | 2018-06-07 | 14 | | cmct | nypt | 2018-06-07 | 15 | | mteam | byrbt | 2018-06-17 | 16 | | | cmct | 2018-07-28 | 17 | | | tjupt | 2018-08-28 | 18 | | 不限\* | | 2018-10-23 | 19 | 20 | \* 源站点表示支持抓取其部分简介用于发布,没有则本地生成简介. 21 | 22 | ## 特点 23 | 24 | - 自动生成并提交简介,与原种简介尽量一致。 25 | - 自动设置做种时间与分享率、清理旧种子、硬盘容量释放。 26 | - 速度快,使用临时文件提前生成简介,使用多线程提速。 27 | - 开箱即用,不需要使用数据库等复杂操作。 28 | - 支持自动 Dupe 以及禁转判断。 29 | - 支持多项自定义规则优化任务。 30 | - 总的来说,几乎全自动。 31 | 32 | 33 | ## 环境要求 34 | 35 | - GNU/Linux(ubuntu 18.04 lts、archLinux、centos7 测试通过)。 36 | - 软件: 37 | - transmission-daemon,transmission-remote,transmission-show,transmission-edit; 38 | - qBittorrent v4.1+,(使用该客户端须安装transmission-show,edit!); 39 | - httpie 0.9.8+,用于和web服务器通讯; 40 | - mediainfo,[mtn](http://moviethumbnail.sourceforge.net/)(非必须) 用于本地生成info信息; 41 | - ffmpeg,用于本地生成缩略图(配合mediainfo); 42 | - 其他常用软件工具,sed,grep,awk等(详见 setting.sh,一般系统自带); 43 | - 默认先使用`python3`本地解析豆瓣简介,感谢 [@Rhilip](https://github.com/Rhilip/PT-help/blob/master/modules/infogen/gen.py) 的脚本,(Python相关依赖requests,bs4,html2bbcode); 44 | - curl,备用下载工具; 45 | - unrar、[dottorrent](https://github.com/kz26/dottorrent),解压0day分卷资源。 46 | 47 | - ubuntu 系安装 48 | ```sh 49 | sudo apt install transmission-daemon \ 50 | transmission-cli qbittorrent(or nox) \ 51 | httpie mediainfo python3 ffmpeg 52 | sudo pip3 install requests bs4 html2bbcode 53 | ``` 54 | - arch 系安装 55 | ```sh 56 | sudo pacman -Sy transmsiion-cli \ 57 | qbittorrent(or nox) httpie mediainfo \ 58 | python python-pip ffmpeg 59 | sudo pacman -Sy python-requests python-beautifulsoup4 60 | # 不要通过 pip 安装上面两个库到系统 61 | sudo pip3 install html2bbcode 62 | ``` 63 | - centos 安装 64 | ```sh 65 | sudo yum -y install transmission-cli \ 66 | transmission-common transmission-daemon \ 67 | qbittorrent(or nox) httpie mediainfo \ 68 | python python-pip ffmpeg 69 | sudo pip3 install install requests bs4 html2bbcode 70 | ``` 71 | 72 | ## 使用方法 73 | 74 | 1. clone 本 repo (或者下载 zip) 至本地,请使用最新的版本; 75 | 2. 修改设置文件`setting.sh`(包括cookie、passkey,监控 torrent 文件路径等); 76 | 3. 使用 transmission **订阅源种**,添加 `main.sh` 路径至 `script-torrent-done-filename`,具体见 [这里](https://rachpt.github.io/2018/03/25/transmission-settings/) ; 77 | 5. 使用 qbittorrent **订阅源种**,添加如 `/home/AutoSeed/main.sh "%N" "%D"` 所示代码至`完成时运行外部程序`处; 78 | 3、4只能选其一,目前只能使用一个客户端订阅源种; 79 | 6. (推荐)将 `main.sh` 添加到 `crontab` 周期运行(运行锁会解决各种问题),以提前生成简介; 80 | 7. 调试请看 test.sh 中的说明。 81 | 82 | 详细请看[WIKI](https://github.com/rachpt/AutoSeed/wiki)。 83 | 84 | *其他:* 85 | 86 | 请使用 flexget 订阅下载,transmission 使用 [transmissionrpc](https://flexget.com/Plugins/transmission) 将源种传入,qbittorrent 使用 flexget 的 qbittorrent 模块。 87 | `crontab` 运行参考命令 `*/5 * * * * /home/AutoSeed/main.sh >/dev/null 2>&1`。 88 | ubuntu 用户注意使用 bash 运行而非系统默认的 dash! 89 | python 并非必须,只需将 `setting.sh` 中的`Use_Local_Gen='yes'`改为其他值,则使用基于 [web](https://rhilip.github.io/PT-help/ptgen) 的生成方法,当然本地解析失败时,也会尝试使用web方法生成。 90 | 91 | 92 | ## 更新日志 93 | 94 | - 2019-02-18 --> 3.1 95 | - 修复几处 bug。 96 | - 新增使用 ffmpeg 生成缩略图。 97 | - 新增自定义豆瓣链接匹配规则。 98 | - 新增特定资源的单独发布规则。 99 | - 完善多处细节,比如解决 WiKi 美剧 imdb 固定为第一季情况,添加备用图床等。 100 | 101 | - 2018-12-19 --> 3.0 (release) 102 | - 完善clean模块,部分功能使用多线程。 103 | - 新的qbittorrent分享率设置实现。 104 | - 代码稳定性增强。 105 | 106 | - 2018-12-08 --> 3.0 (开发版,几乎完成) 107 | - 重构几乎全部代码,以支持更多的站点。 108 | - 使用豆瓣简介,尽量保留原始 iNFO 以及 screens,没有则生成。 109 | - 添加对 qbittorrent 的支持,目前 clean、edit 模块还未重构。 110 | - 主体稳定性正在测试... 111 | 112 | - 2018-10-23 --> 3.0 (开发版,未完成) 113 | - 重构部分代码,以支持更多的站点。 114 | - 使用豆瓣豆瓣,尽量保留原始 iNFO 以及 screens,没有则生成。 115 | - 目前修改了'get_desc',以及部分 'post',其他正在修改中…… 116 | 117 | ## 实现流程 118 | 119 | [点击查看](https://www.processon.com/view/link/5c088855e4b0ca4b40c93a49) 120 | 121 | ## License 122 | 123 | [GPL-3.0](https://github.com/rachpt/AutoSeed/blob/master/LICENSE) 124 | 125 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /clean/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: clean/clean.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-04-28 7 | #-----------------------------# 8 | # 9 | # Auto clean old files/folders in 10 | # watch-dir which are not seeding 11 | # on transmission and qbittorrent. 12 | # 13 | #-----------test--------------# 14 | # 测试说明: 15 | # `bash -x clean.sh test 1 0` 测试 qbittorrent 16 | # `bash -x clean.sh test 0 1` 测试 transmission 17 | # 测试不会删除数据,但是会删除已经停止了的种子 18 | # 测试会忽略清理频率限制(至少12小时一次) 19 | #-----------------------------# 20 | #---import settings---# 21 | if [ -z "$ROOT_PATH" ]; then 22 | ROOT_PATH="$(dirname "$(readlink -f "$0")")" 23 | ROOT_PATH="${ROOT_PATH%/*}" 24 | source "$ROOT_PATH/settings.sh" 25 | fi 26 | unset test_c 27 | [[ "$1" = test ]] && test_c=1 && { 28 | [[ "$2" = 1 ]] && use_qbt='yes' || use_qbt='no' 29 | [[ "$3" = 1 ]] && use_trs='yes' || use_trs='no'; } 30 | #-----------------------------# 31 | # import functions 32 | source "$ROOT_PATH/clean/tr.sh" 33 | source "$ROOT_PATH/clean/qb.sh" 34 | #-----------------------------# 35 | # judge function, return a value 36 | is_old_file() { 37 | # need a parameter, return a 0/1 code 38 | local file_modf time_interval 39 | file_modf=$(stat -c '%Y' "$FILE_PATH/$1") 40 | time_interval=$(($(date '+%s') - ${file_modf:-0})) 41 | if [[ $time_interval -ge ${TimeINTERVAL:-7200} ]]; then 42 | printf 1 # yes 43 | else 44 | printf 0 # no 45 | fi 46 | } 47 | #-----------------------------# 48 | # it's a called function 49 | comparer_file_and_delete() { 50 | # _qb_names _tr_names 在main中使用local限定,可以减少重复工作 51 | IFS_OLD=$IFS; IFS=$'\n'; local f old_status 52 | for f in $(ls -1 "$FILE_PATH"); do 53 | IFS=$IFS_OLD 54 | old_status=$(is_old_file "$f") 55 | if [[ $old_status -eq 1 && "$f" ]]; then 56 | # 删除不在qb tr中的文件 57 | local delete_commit 58 | # transmission 判断更容易,所以放前面。 59 | [[ $use_trs = yes ]] && tr_is_seeding "$f" || delete_commit='yes' 60 | [[ $use_qbt = yes && $delete_commit = yes ]] && qb_is_seeding "$f" 61 | # 如果两个客户端都未使用,则不删文件。 62 | [[ $use_qbt != yes && $use_trs != yes ]] && delete_commit='no' 63 | if [[ $delete_commit = yes ]]; then 64 | debug_func "clean:del-file:[$f]" #----debug--- 65 | [[ "$f" && -e "$FILE_PATH/$f" && ! $test_c ]] && \rm -rf "$FILE_PATH/$f" 66 | printf '%s\n' "[$(date '+%m-%d %H:%M:%S')]deleted Torrent[$f]" >> "$log_Path" 67 | fi 68 | fi 69 | done 70 | unset f old_status 71 | } 72 | #-----------------------------# 73 | # judge function, return a value 74 | disk_check() { 75 | disk_avail=$(\df -h "$FILE_PATH"|awk '/^\//{split($4,a,"G");print a[1]}') 76 | disk_over=$(bc <<< "${disk_avail:-0} < ${DISK_AVAIL_MIN:-0}") # var default 0 77 | # bc true = 1, false = 0 78 | } 79 | #-----------------------------# 80 | # it's a called function 81 | disk_is_over_use() { 82 | local disk_over disk_avail i 83 | disk_check 84 | if [[ "$disk_over" -eq 1 && $use_trs = yes ]]; then 85 | for i in $($tr_remote -l|grep -Eo '[0-9]+.+100%'|grep -Eo '^[0-9]+'); do 86 | $tr_remote -t "$i" --remove-and-delete >> "$log_Path" 2>&1 87 | debug_func "clean::reach-limit[$i]" #----debug--- 88 | sleep 10 && disk_check 89 | [[ "$disk_over" -eq 0 ]] && break 90 | done 91 | fi 92 | if [[ "$disk_over" -eq 1 && $use_qbt = yes ]]; then 93 | : # 我好像用不到,此处不写 94 | fi 95 | } 96 | 97 | #-----------------------------# 98 | # 清理路径列队,用于更新 dir 里面的值 99 | clean_dir() { 100 | if [ ! -s "$ROOT_PATH/clean/dir" ]; then 101 | # add to the first line 102 | [[ "$one_TR_Dir" ]] && printf '%s\n' "$one_TR_Dir" > "$ROOT_PATH/clean/dir" 103 | else 104 | local line add_to_dir 105 | add_to_dir=1 106 | while read -r line; do 107 | [[ "$one_TR_Dir" == "$line" ]] && { 108 | add_to_dir=0 # give up add 109 | break; } 110 | done < "$ROOT_PATH/clean/dir" 111 | [[ $add_to_dir -eq 1 && $one_TR_Dir ]] && \ 112 | printf '%s\n' "$one_TR_Dir" >> "$ROOT_PATH/clean/dir" 113 | fi 114 | unset line add_to_dir 115 | } 116 | 117 | #----------call-func----------# 118 | clean_frequence() { 119 | # 限制清理频率 120 | local time_threshold time_pass 121 | [[ $test_c ]] && time_threshold=1 || time_threshold=$((60 * 60 * 12)) # 12 hours to seconds 122 | # use $(( )) to calculate number 123 | time_pass=$(($(date '+%s') - $(stat -c '%Y' "$ROOT_PATH/clean/dir"))) 124 | [[ $time_pass -gt $time_threshold ]] && { 125 | debug_func "clean:use_qbt[$use_qbt]-use_trs[$use_trs]" 126 | [[ $test_c ]] || sleep 20 # 延时 127 | clean_main 128 | # 更新dir时间 129 | touch -m "$ROOT_PATH/clean/dir"; } 130 | } 131 | 132 | #----------main-loop----------# 133 | clean_main() { 134 | local one_line _qb_names _tr_names # *_names为客户端做种列表 135 | [[ $use_qbt = yes ]] && qb_delete_old # will not delete file 136 | [[ $use_trs = yes ]] && tr_delete_old # will not delete file 137 | [ -s "$ROOT_PATH/clean/dir" ] && \ 138 | while read -r one_line; do 139 | FILE_PATH="$one_line" # no slash end !!! 140 | comparer_file_and_delete # make sure new file will not be deleted 141 | disk_is_over_use # make sure free space 142 | done < "$ROOT_PATH/clean/dir" 143 | unset one_line _qb_names _tr_names 144 | printf '%s\n' "+++++++++++++[clean]+++++++++++++" >> "$log_Path" 145 | } 146 | 147 | #---------call func-----------# 148 | clean_dir # update clean queue 149 | # maybe need more test !!! 150 | clean_frequence # check and clean 151 | 152 | -------------------------------------------------------------------------------- /clean/dir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /clean/qb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: clean/qb.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-04-27 7 | # 8 | #---------------------------------------# 9 | qb_delete_old() { 10 | qbit_webui_cookie 11 | # from tr name find other info 12 | debug_func 'qb:delete-start' #----debug--- 13 | local _qb_data _paused_data one_1 max_time _sd_timeData 14 | # --pretty=format is important!! 15 | _qb_data="$(http --ignore-stdin --pretty=format GET "$qb_lists" sort=added_on \ 16 | "$qb_Cookie"|grep -E '"name":|"hash":|"ratio":|"state":|"time_active":')" 17 | 18 | #---------------------------------------# 19 | # 删除停止了的种子,不删数据 20 | _paused_data="$(echo "$_qb_data"|grep -B3 '"state":.*pausedUP'|grep -Eio '[a-z0-9]{40}')" 21 | for one_1 in $_paused_data; do qb_delete_torrent "$one_1"; done 22 | #---------------------------------------# 23 | # 达到做种时间的种子 24 | max_time="$(($MAX_SEED_TIME * 24 * 60 * 60))" # 此处时间为秒,不是分钟 25 | _sd_timeData="$(echo "$_qb_data"|grep -B4 '"time_active":.*[0-9]*'|sed \ 26 | '/"name":/d;/"ratio":/d;/"state":/d;s/[",:]//g'|sed 'N;s/\n//')" 27 | for one_2 in $(echo "$_sd_timeData"|awk -v t=$max_time '{if($4 >= t)print $2}') 28 | do 29 | qb_delete_torrent "$one_2" 30 | done 31 | } 32 | 33 | #---------------------------------------# 34 | qb_is_seeding() { 35 | # _qb_names in clean/clean.sh 36 | [[ ! "$_qb_names" ]] && qbit_webui_cookie && \ 37 | _qb_names="$(http --ignore-stdin --pretty=format -f POST "$qb_lists" sort=added_on \ 38 | "$qb_Cookie"|grep '"name":'|uniq|sed -E 's/.*"name":[ ]+"//;s/",$//')" 39 | [[ "$1" && "$_qb_names" ]] && { 40 | [[ "$_qb_names" =~ .*${1}.* ]] && delete_commit='no' || delete_commit='yes' 41 | } || { [[ "$_qb_names" ]] || \ 42 | debug_func "clean.qbt.failed.to.get.seeding.lists" 43 | delete_commit='no' # concel delete file !!! 44 | } 45 | } 46 | #-----------------------------# 47 | 48 | -------------------------------------------------------------------------------- /clean/tr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: clean/tr.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-04-27 7 | # 8 | #-----------------------------# 9 | tr_delete_old() { 10 | # 使用多线程技术加速 11 | local thread="$ROOT_PATH/tmp/thread" 12 | local THREAD_num=8 #定义进程数量 13 | if [[ -a "$thread" ]];then #防止计数文件存在引起冲突 14 | \rm -f "$thread" #若存在先删除 15 | fi 16 | mkfifo "$thread" #创建fifo型文件用于计数 17 | exec 9<> "$thread" 18 | 19 | for (( i=0;i<$THREAD_num;i++ )) #向fd9文件中写回车,有多少个进程就写多少个 20 | do 21 | echo -ne "\n" 1>&9 22 | done 23 | #-----------------------------# 24 | unset ID 25 | for ID in $($tr_remote -l|grep -Eo '^[ ]*[0-9]+'|sed 's/ //g') 26 | do 27 | read -u 9 #read一次,就减去fd9中一个回车 28 | { #当fd9中没有回车符时,脚本就会停住,达到控制进程数量的目的 29 | #---error torrent---# 30 | local tr_info="$($tr_remote -t $ID -i)" 31 | if [ "$(echo "$tr_info"|grep 'torrent not registered with this tracker')" ]; then 32 | $tr_remote -t $ID -r 33 | fi 34 | #---old torrent---# 35 | local seed_time=$(echo "$tr_info"|grep 'Seeding Time.*days'|grep -Eo '[0-9]+'|head -1) 36 | 37 | [ "$seed_time" ] && if [ $seed_time -ge $MAX_SEED_TIME ]; then 38 | $tr_remote -t $ID -r 39 | fi 40 | #---finished torrent---# 41 | if [ "$(echo "$tr_info"|grep 'State:.*Finished')" ]; then 42 | $tr_remote -t $ID -r 43 | fi 44 | unset tr_info 45 | echo -ne "\n" 1>&9 #某个子进程执行结束,向fd9追加一个回车符,补充循环开始减去的那个 46 | }& 47 | done 48 | wait #等待所有后台子进程结束 49 | \rm -f "$thread" 50 | } 51 | 52 | #-----------------------------# 53 | tr_is_seeding() { 54 | # _tr_names in clean/clean.sh 55 | # transmission 第10 列开始为种子名, NR>1去掉第一行,最后一行被for去掉 56 | [[ ! "$_tr_names" ]] && _tr_names="$($tr_remote -l|awk \ 57 | 'NR>1{for(i=10;i<=NF;i++)print $i}')" 58 | [[ "$1" && "$_tr_names" ]] && { 59 | [[ "$_tr_names" =~ .*${1}.* ]] && delete_commit='no' || delete_commit='yes' 60 | } || { [[ "$_tr_names" ]] || \ 61 | debug_func "clean.trs.failed.to.get.seeding.lists" 62 | delete_commit='no' # cancel delete file !!! 63 | } 64 | } 65 | #-----------------------------# 66 | 67 | -------------------------------------------------------------------------------- /get_desc/customize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/customize.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-07-14 7 | # 8 | #-------------------------------------# 9 | # 本文件对特定资源发布站点进行特殊设置, 10 | # 配置文件路径 $ROOT_PATH/tmp/dupe-rules.txt, 11 | # 调用需要一个全局变量,$dot_name. 12 | #-------------------------------------# 13 | # 14 | my_dupe_rules() { 15 | local lists _d i _name _one_name _url _site _line 16 | lists="$ROOT_PATH/tmp/dupe-rules.txt" 17 | # 过滤后的数据 18 | _d="$(sed -E 's/[##].*//g;s/[  ]+//g;/^$/d;s/[A-Z]/\l&/g' "$lists")" 19 | if [[ -f $lists && $(echo "$_d"|wc -l) -ge 1 ]]; then 20 | for ((i=1;i<=$(echo "$_d"|wc -l);i++)); do 21 | _name="$(echo "$dot_name"|sed 'y/。,?;:‘“、()`~!@#%*ABCDEFGHIJKLMNOPQRSTUVWXYZ/.,?;:\"\",()`~!@#%*abcdefghijklmnopqrstuvwxyz/')" 22 | _name="$(echo "${_name,,}"|sed 's/[\.  ]//g')" 23 | _line="$(echo "$_d"|sed -n "${i}{s/[\.  ]//g;p;q}")" 24 | _one_name="$(echo "$_line"|awk -F '+' '{print $NF}'|sed "s/[\.  ]//g")" 25 | _one_name="$(echo "$_one_name"|sed 'y/。,?;:‘“、()`~!@#%*ABCDEFGHIJKLMNOPQRSTUVWXYZ/.,?;:\"\",()`~!@#%*abcdefghijklmnopqrstuvwxyz/')" 26 | [[ $_name =~ .*$_one_name.* ]] && { 27 | _site="$(echo "$_line"|awk -F '+' '{print NF}')" 28 | ((_site>1)) && { 29 | [[ $(echo "$_line"|awk -F '+' '{print $1}') =~ 1|yes ]] && enable_hudbt='yes' 30 | [[ $(echo "$_line"|awk -F '+' '{print $1}') =~ 0|no ]] && enable_hudbt='no' 31 | } 32 | ((_site>2)) && { 33 | [[ $(echo "$_line"|awk -F '+' '{print $2}') =~ 1|yes ]] && enable_whu='yes' 34 | [[ $(echo "$_line"|awk -F '+' '{print $2}') =~ 0|no ]] && enable_whu='no' 35 | } 36 | ((_site>3)) && { 37 | [[ $(echo "$_line"|awk -F '+' '{print $3}') =~ 1|yes ]] && enable_npupt='yes' 38 | [[ $(echo "$_line"|awk -F '+' '{print $3}') =~ 0|no ]] && enable_npupt='no' 39 | } 40 | ((_site>4)) && { 41 | [[ $(echo "$_line"|awk -F '+' '{print $4}') =~ 1|yes ]] && enable_nanyangpt='yes' 42 | [[ $(echo "$_line"|awk -F '+' '{print $4}') =~ 0|no ]] && enable_nanyangpt='no' 43 | } 44 | ((_site>5)) && { 45 | [[ $(echo "$_line"|awk -F '+' '{print $5}') =~ 1|yes ]] && enable_byrbt='yes' 46 | [[ $(echo "$_line"|awk -F '+' '{print $5}') =~ 0|no ]] && enable_byrbt='no' 47 | } 48 | ((_site>6)) && { 49 | [[ $(echo "$_line"|awk -F '+' '{print $6}') =~ 1|yes ]] && enable_cmct='yes' 50 | [[ $(echo "$_line"|awk -F '+' '{print $6}') =~ 0|no ]] && enable_cmct='no' 51 | } 52 | ((_site>7)) && { 53 | [[ $(echo "$_line"|awk -F '+' '{print $7}') =~ 1|yes ]] && enable_tjupt='yes' 54 | [[ $(echo "$_line"|awk -F '+' '{print $7}') =~ 0|no ]] && enable_tjupt='no' 55 | } 56 | #source "$ROOT_PATH/static.sh" # update trackers post_site 57 | debug_func 'dupe:use-customize-dupe-rules' #----debug--- 58 | break # jump out 59 | } 60 | done 61 | else 62 | debug_func ':dupe:no-dupe-rules-file!' #----debug--- 63 | fi 64 | # test tracker's status 65 | [[ ${completion:-100} -ge 92 && $HAVE_TESTED != yes ]] && { 66 | is_tracker_down # static.sh 67 | HAVE_TESTED='yes' # 减少重复测试 68 | } 69 | } 70 | #----------------------------------------# 71 | 72 | -------------------------------------------------------------------------------- /get_desc/db_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/db_info.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-05-24 7 | # 8 | #-------------------------------------# 9 | # https://github.com/Rhilip/PT-help/blob/master/modules/infogen/gen.py 10 | # 的 bash 实现,豆瓣apikey 随机选择。 11 | #-------------------------------------# 12 | # 处理 json 信息 13 | get_json_values_by_awk() { 14 | awk -v json="$1" -v key="$2" -v defaultValue="" 'BEGIN{ 15 | foundKeyCount = 0; sp = 0; 16 | while (length(json) > 0) { 17 | pos = match(json, "\""key"\"[ \\t]*?:[ \\t]*"); 18 | if (pos == 0) {if (foundKeyCount == 0) {print defaultValue;} exit 0;} 19 | 20 | ++foundKeyCount; 21 | start = 0; stop = 0; layer = 0; 22 | for (i = pos + length(key) + 1; i <= length(json); ++i) { 23 | lastChar = substr(json, i - 1, 1) 24 | currChar = substr(json, i, 1) 25 | 26 | if (start <= 0) { 27 | if (lastChar == ":") { 28 | start = currChar == " " ? i + 1: i; 29 | if (currChar == "{" || currChar == "[") { layer = 1; ++sp; } 30 | } 31 | } else { 32 | if (currChar == "{" || currChar == "[") { ++layer; ++sp; } 33 | if (currChar == "}" || currChar == "]") { --layer; } 34 | if ((currChar == "," || currChar == "}" || currChar == "]") && layer <= 0) { 35 | stop = currChar == "," ? i : i + 1 + layer; 36 | break; 37 | } 38 | } 39 | } 40 | 41 | if (start <= 0 || stop <= 0 || start > length(json) || stop > length(json) || start >= stop) { 42 | if (foundKeyCount == 0) {print defaultValue;} exit 0; 43 | } else { 44 | if (sp == 0) { ++sp; } 45 | print substr(json, start + sp, stop - start - 2 * sp); 46 | } 47 | 48 | json = substr(json, stop + 1, length(json) - stop) 49 | } 50 | }' 51 | } 52 | 53 | #-------------------------------------# 54 | # 豆瓣详情页面,获取中英文名、集数、获奖信息、imdb链接 55 | douban_page() { 56 | local db_pg _chinese_title _foreign_title _aka 57 | unset this_title trans_title episodes awards 58 | db_pg="$(http -Ib --pretty=format "${1%/}/" "$user_agent"|sed \ 59 | '/'|tail -1|sed 's/(豆瓣)//')" 62 | _aka="$(echo "$db_pg"|grep '又名'|sed 's/.*span> *//;s/$_chinese_title *//;s/<.*//")" 65 | [[ $_foreign_title ]] && { 66 | [[ $_aka ]] && trans_title="$_chinese_title/$_aka" || trans_title="$_chinese_title" 67 | this_title="$_foreign_title" 68 | } || { 69 | [[ $_aka ]] && trans_title="$_aka" 70 | this_title="$_chinese_title" 71 | } 72 | [[ $imdb_link ]] || imdb_link="https://www.imdb.com/title/$(echo "$db_pg"| \ 73 | grep -Eo 'tt[0-9]+'|head -1)/" 74 | episodes="$(echo "$db_pg"|grep '集数:'|grep -Eo '[0-9]+')" 75 | awards="$(http -Ib --pretty=format "${1%/}/awards/" "$user_agent"|grep -A30 \ 76 | 'class="awards"'|grep -v '
  • [^<;]+<'|sed 's/[<>]//g;s/^/  &/')" 77 | export chs_name_douban="$_chinese_title" 78 | export eng_name_douban="$_foreign_title" 79 | fi 80 | } 81 | #-------------------------------------# 82 | # imdb详情页面json数据,获取评分以及 Amazon 海报 83 | imdb_page() { 84 | local im_json 85 | unset imdb_img imdb_rating num_raters_im 86 | im_json="$(printf "`http -Ib --pretty=format "${1%/}/" "$user_agent"|sed \ 87 | '1,\%%,$ d;s/[ ]*//g'`")" 88 | if [[ -n $im_json ]]; then 89 | imdb_rating="$(get_json_values_by_awk "$im_json" 'aggregateRating'|grep -Eo \ 90 | '"ratingValue": *".*"'|grep -Eo "[0-9\.]+")" 91 | num_raters_im="$(get_json_values_by_awk "$im_json" 'aggregateRating'|grep -Eo \ 92 | '"ratingCount": *[0-9]+'|grep -Eo '[0-9]+')" 93 | imdb_img="$(get_json_values_by_awk "$im_json" 'image')" 94 | fi 95 | } 96 | 97 | #-------------------------------------# 98 | # 通过两个豆瓣api接口,获取大部分信息,并打印 99 | gen_format_desc() { 100 | # 参数 tt1234567 或者 12345678 101 | json="`http -b -I --pretty=format "$base_url/${1}?apikey=$2" "$user_agent"| \ 102 | sed ':a;N;s/\n//;t a;'|sed -E 's/[ ]+//g'`" 103 | [[ `echo "$json"|grep -E 'code":104|code":5000'` ]] && json='' 104 | if [[ -n "$json" ]]; then 105 | local poster year region genre language playdate douban_rating num_raters_db 106 | local duration director writer cast tags introduction 107 | #----------- 108 | poster="$(get_json_values_by_awk "$json" 'image'|sed 's/s_ratio_/l_ratio_/;s/img3/img1/')" 109 | [[ -n $douban_link ]] || douban_link="$(get_json_values_by_awk "$json" 'alt'|sed 's%movie/%subject/%')" 110 | year="$(get_json_values_by_awk "$json" 'year')" 111 | region="$(get_json_values_by_awk "$json" 'country'|sed ':a;N;s/\n//;t a;'|sed 's%","%/%g')" 112 | genre="$(get_json_values_by_awk "$json" 'movie_type'|sed ':a;N;s/\n//;t a;'|sed 's%","%/%g')" 113 | language="$(get_json_values_by_awk "$json" 'language'|sed ':a;N;s/\n//;t a;'|sed 's%","%/%g')" 114 | playdate="$(get_json_values_by_awk "$json" 'pubdate'|sed ':a;N;s/\n//;t a;'|sed 's%","%/%g')" 115 | 116 | douban_rating="$(get_json_values_by_awk "`get_json_values_by_awk "$json" 'rating'`" 'average')" 117 | num_raters_db="$(get_json_values_by_awk "$json" 'rating'|grep -Eo '"numRaters":[0-9]+'|grep -Eo '[0-9]+')" 118 | [[ -n $douban_link ]] || \ 119 | douban_link="$(get_json_values_by_awk "$json" 'alt'|sed 's%/movie/%/subject/%')" 120 | 121 | [[ -n $douban_link ]] && douban_page "$douban_link" 122 | [[ -n $imdb_link ]] && imdb_page "$imdb_link" 123 | 124 | duration="$(get_json_values_by_awk "$json" 'movie_duration'|sed ':a;N;s/\n//;t a;'|sed 's%","%/%g')" 125 | 126 | director="$(get_json_values_by_awk "$json" 'director'|sed ':a;N;s/\n//;t a;'|sed 's%","%/%g')" 127 | writer="$(get_json_values_by_awk "$json" 'writer'|sed ':a;N;s/\n//;t a;'|sed 's%","%/%g')" 128 | cast="$(get_json_values_by_awk "$json" 'cast'|sed 's/","/\n/g'|sed '1 ! {s/^/      &/g}')" 129 | 130 | tags="$(get_json_values_by_awk "`get_json_values_by_awk "$json" 'tags'`" 'name'| \ 131 | sed ':a;N;s/\n/\|/;t a;'|sed 's%","%/%g')" 132 | introduction="$(get_json_values_by_awk "$json" 'summary'|sed ':a;N;s/\n//;t a;')" 133 | #---------- 134 | export douban_poster_url="$poster" 135 | # print 136 | [[ -n $poster ]] && \ 137 | echo "[img]$poster[/img]" 138 | [[ -n $imdb_img ]] && echo -e "Amazon poster:\n$imdb_img\n" || echo '' 139 | [[ -n $trans_title ]] && \ 140 | echo "◎译  名 $trans_title" 141 | [[ -n $this_title ]] && \ 142 | echo "◎片  名 $this_title" 143 | [[ -n $year ]] && \ 144 | echo "◎年  代 ${year//\"/}" 145 | [[ -n $region ]] && \ 146 | echo "◎产  地 ${region//\"/}" 147 | [[ -n $genre ]] && \ 148 | echo "◎类  别 ${genre//\"/}" 149 | [[ -n $language ]] && \ 150 | echo "◎语  言 ${language//\"/}" 151 | [[ -n $playdate ]] && \ 152 | echo "◎上映日期 ${playdate//\"/}" 153 | [[ -n $imdb_rating ]] && { 154 | echo -e "◎IMDb评分 $imdb_rating\c" && \ 155 | [[ -n $num_raters_im ]] && echo " from $num_raters_im users" || echo ''; } 156 | [[ -n $imdb_link ]] && \ 157 | echo "◎IMDb链接 $imdb_link" 158 | [[ -n $douban_rating ]] && { 159 | echo -e "◎豆瓣评分 $douban_rating\c" && \ 160 | [[ -n "$num_raters_db" ]] && echo " from $num_raters_db users" || echo ''; } 161 | [[ -n $douban_link ]] && \ 162 | echo "◎豆瓣链接 $douban_link" 163 | [[ -n $episodes ]] && \ 164 | echo "◎集  数 $episodes" 165 | [[ -n $duration ]] && \ 166 | echo "◎片  长 ${duration//\"/}" 167 | [[ -n $director ]] && \ 168 | echo "◎导  演 ${director//\"/}" 169 | [[ -n $writer ]] && \ 170 | echo "◎编  剧 ${writer//\"/}" 171 | [[ -n $cast ]] && \ 172 | echo "◎主  演 ${cast//\"/}" 173 | echo -e "\n" 174 | [[ -n $tags ]] && \ 175 | echo -e "◎标  签 $tags\n" 176 | [[ -n $introduction ]] && \ 177 | echo -e "◎简  介 \n  $introduction\n" 178 | [[ -n $awards ]] && \ 179 | echo -e "◎获奖情况 \n$awards\n" 180 | fi 181 | } 182 | #---------------main------------------# 183 | [[ $1 =~ https?://(movie.)?douban.com/subject/[0-9]+/? ]] && \ 184 | _kw="$(echo "$1"|grep -Eo '[0-9]+')" || { 185 | [[ $1 =~ https?://www.imdb.com/title/tt[0-9]+/? ]] && \ 186 | _kw="$(echo "$1"|grep -Eo 'tt[0-9]+')"; } 187 | [[ -z $_kw ]] && _kw="$1" # 简略形式 188 | 189 | db_apikey_1='02646d3fb69a52ff072d47bf23cef8fd' 190 | db_apikey_2='0b2bdeda43b5688921839c8ecb20399b' 191 | db_apikey_3='0dad551ec0f84ed02907ff5c42e8ec70' 192 | db_apikey_4='0df993c66c0c636e29ecbb5344252a4a' 193 | db_apikey_5='07c78782db00a121175696889101e363' 194 | 195 | [[ "$user_agent" ]] || \ 196 | user_agent='User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0' 197 | 198 | [[ $_kw =~ tt[0-9]+ ]] && { 199 | base_url='https://api.douban.com/v2/movie/imdb' 200 | imdb_link="https://www.imdb.com/title/$_kw/" 201 | } || { 202 | base_url='https://api.douban.com/v2/movie' 203 | douban_link="https://movie.douban.com/subject/$_kw/"; } 204 | 205 | _rand="$((1 + RANDOM % 5))" 206 | gen_format_desc "$_kw" "$(eval echo '$'db_apikey_$_rand)" 207 | _count=1 208 | while [[ -z $json && $_count -le 5 ]]; do 209 | [[ $_rand -eq 5 ]] && _rand=1 || _rand=$((_rand + 1)) 210 | gen_format_desc "$_kw" "$(eval echo '$'db_apikey_$_rand)" 211 | ((_count++)) 212 | done 213 | unset json _rand _kw _count base_url imdb_img imdb_rating num_raters_im 214 | unset this_title trans_title episodes awards 215 | #-------------------------------------# 216 | 217 | -------------------------------------------------------------------------------- /get_desc/desc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/desc.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-07-14 7 | # 8 | #-------------------------------------# 9 | # 调函数,生成简介 10 | # 提前生成简介,post,重编辑会用到该文件 11 | #-------------------------------------# 12 | # 最后发布前会再次重命名为简单的名字减少莫名其妙的bug。 13 | # dot_name即点分隔名,用作 0day 名,以及构成保存简介文件名。 14 | dot_name="$(echo "$org_tr_name"|sed 's/[^ -z]//g')" # 删除所有汉字 15 | debug_func "desc:dot-name.0[$dot_name]" #----debug--- 16 | # name 包含10个以上英文字符,则使用其作为0day名,否则使用部分主文件名 17 | if [[ $(echo "$dot_name"|sed 's/[\. 0-9]//g'|awk '{print length($0)}') -lt 10 ]]; then 18 | #---special for non-standard 0day-name---# 19 | dot_name="$("$tr_show" "$torrent_Path"|grep -A10 'FILES'| \ 20 | grep -Ei '[\.0-9]+[ ]*(GB|MB)'|grep -Eio "[-\.\'a-z0-9\!@_ ]+"|tail -2| \ 21 | head -1|sed -r 's/^[\. ]+//;s/\.[a-z4 ]{2,5}$//i'| \ 22 | sed -r 's/\.sample//i;s/[ ]+/./g')" && \ 23 | debug_func "desc:dot-name.2[$dot_name]" #----debug--- 24 | else 25 | # remove suffix name 26 | dot_name="$(echo "$dot_name"|sed -E 's/[ ]+/./g;s/\.{2,}/./g;s/\.[a-z4]{2,4}$//i;;s/^\.//')" 27 | debug_func "desc:dot-name.1[$dot_name]" #----debug--- 28 | fi 29 | 30 | # 导入自定义规则 31 | my_dupe_rules # get_desc/customize.sh 32 | source_desc="${ROOT_PATH}/tmp/${org_tr_name}_desc.txt" 33 | # byrbt, html format 34 | [ "$enable_byrbt" = 'yes' ] && \ 35 | source_html="${ROOT_PATH}/tmp/${org_tr_name}_html.txt" 36 | # tjupt, deal with images 37 | [ "$enable_tjupt" = 'yes' ] && \ 38 | source_desc2tjupt="${ROOT_PATH}/tmp/${org_tr_name}_desc2tjupt.txt" 39 | 40 | #---to log and edit.sh---# 41 | if [[ -z "$source_site_URL" ]]; then 42 | get_source_site # get_desc/detail_page.sh 43 | debug_func "desc:get-site[$source_site_URL][$s_site_uid]" #----debug--- 44 | else 45 | set_source_site_cookie # get_desc/detail_page.sh 46 | debug_func 'desc:get-site-cookie' #----debug--- 47 | fi 48 | # 使用预先编辑报的简介,将不会再尝试生成info 49 | [[ ! -s "$source_desc" ]] && \ 50 | match_douban_desc # get_desc/match.sh 51 | #---if not exist desc file---# 52 | if [ ! -s "$source_desc" ]; then 53 | debug_func 'desc:no-source-info' #----debug--- 54 | # 尝试搜索原种简介,以获取 iNFO 以及 screens 55 | form_source_site_get_Desc # get_desc/detail_page.sh 56 | # generate info? 57 | if [ ! -s "$source_desc" ]; then 58 | [[ $completion -ge 92 ]] && { 59 | # import functions 60 | debug_func 'desc:info' #----debug--- 61 | [[ `type -t read_info_file` != "function" ]] && \ 62 | source "$ROOT_PATH/get_desc/info.sh" 63 | read_info_file; } # get_desc/info.sh 64 | fi 65 | if [ -s "$source_desc" ]; then 66 | # set source site torrent's ratio, only once 67 | [[ $fg_client = qbittorrent && $s_site_uid ]] && \ 68 | echo -e "${org_tr_name}\n${trackers[$s_site_uid]}\n`eval echo \ 69 | '$'ratio_$s_site_uid`" >> "$qb_rt_queue" 70 | # import functions to generate desc 71 | #------------match imdb/douban url----------# 72 | debug_func 'desc:match' #----debug--- 73 | match_douban_imdb "$dot_name" # get_desc/match.sh 74 | match_douban_imdb "$org_tr_name" # get_desc/match.sh 75 | #-----------use python/api gen desc---------# 76 | debug_func 'desc:generate' #----debug--- 77 | [[ `type -t generate_main_func` != "function" ]] && \ 78 | source "$ROOT_PATH/get_desc/generate.sh" 79 | generate_main_func # get_desc/generate.sh 80 | #-----------------screens-------------------# 81 | if [[ $enable_byrbt = yes || $enable_tjupt = yes ]]; then 82 | debug_func 'desc:screens' #----debug--- 83 | [[ `type -t deal_with_images` != "function" ]] && \ 84 | source "$ROOT_PATH/get_desc/screens.sh" 85 | deal_with_images # get_desc/screens.sh 86 | debug_func 'desc:out' #----debug--- 87 | fi 88 | fi 89 | else 90 | # 保险起见,检查已经生成的简介 91 | if [[ $enable_byrbt = yes && $(grep -Eo "src=[\"\']http[^\'\"]+" \ 92 | "$source_html"|sed "/bt\.byr\.cn/d") ]]; then 93 | [[ `type -t deal_with_images` != "function" ]] && \ 94 | source "$ROOT_PATH/get_desc/screens.sh" 95 | deal_with_images # get_desc/screens.sh 96 | debug_func 'desc-byr-pic-pass2' #----debug--- 97 | fi 98 | fi 99 | #-------------------------------------# 100 | 101 | -------------------------------------------------------------------------------- /get_desc/detail_page.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/detail_page.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2020-01-09 7 | # 8 | #-------------------------------------# 9 | # 通过搜索原种站点(依据torrent文件中的tracker信息), 10 | # 只有预定义的站点才有效。 11 | # 获得的原种简介仅筛选 iNFO 以及 screens 保留到临时文件 12 | # source_desc[html 用于 byrbt], 13 | # 后续合并通过豆瓣生成的简介。 14 | #-------------------------------------# 15 | no_source_2_source() { 16 | # 来自 byr 17 | if [[ $source_site_URL =~ .*byr.* ]]; then 18 | source_site_URL="${post_site[byrbt]}" 19 | enable_byrbt='no' 20 | s_site_uid='byrbt' 21 | # 来自 nanyangpt 22 | elif [[ $source_site_URL =~ .*nanyangpt.* ]]; then 23 | source_site_URL="${post_site[nanyangpt]}" 24 | enable_nanyangpt='no' 25 | s_site_uid='nanyangpt' 26 | # 来自 npupt 27 | elif [[ $source_site_URL =~ .*npupt.* ]]; then 28 | source_site_URL="${post_site[npupt]}" 29 | enable_npupt='no' 30 | s_site_uid='npupt' 31 | # 来自 tjupt 32 | elif [[ $source_site_URL =~ .*tjupt.* ]]; then 33 | source_site_URL="${post_site[tjupt]}" 34 | enable_tjupt='no' 35 | s_site_uid='tjupt' 36 | fi 37 | } 38 | 39 | #--------------prepare-func-----------# 40 | get_source_site() { 41 | # s_site_uid 用于qbittorrent 设置原种 ratio. qbittorrent.sh 42 | unset source_site_URL cookie_source_site unknown_site source_t_id s_site_uid 43 | local tracker_info 44 | tracker_info="$($tr_show "$torrent_Path"|grep -A6 'TRACKERS'| \ 45 | sed '/FILES/,$d;/^$/d;/[ ]*http/!d')" 46 | # 获取种子原站点 47 | if [[ "$tracker_info" =~ .*hdsky.* ]]; then 48 | source_site_URL="${post_site[hds]}" 49 | s_site_uid='hds' 50 | elif [[ "$tracker_info" =~ .*totheglory.* ]]; then 51 | source_site_URL="${post_site[ttg]}" 52 | s_site_uid='ttg' 53 | elif [[ "$tracker_info" =~ .*hdchina.* ]]; then 54 | source_site_URL="${post_site[hdc]}" 55 | s_site_uid='hdc' 56 | elif [[ "$tracker_info" =~ .*m-team.cc.* ]]; then 57 | source_site_URL="${post_site[mt]}" 58 | s_site_uid='mt' 59 | enable_mt='no' 60 | elif [[ "$tracker_info" =~ .*springsunday.net.* ]]; then 61 | source_site_URL="${post_site[cmct]}" 62 | s_site_uid='cmct' 63 | enable_cmct='no' 64 | #elif [[ "$tracker_info" =~ .*newsite.* ]]; then 65 | # source_site_URL="${post_site[newsite]}" 66 | else 67 | source_site_URL="$(echo "$tracker_info"|grep -Eo 'https?://[^:/]*'| \ 68 | head -1|sed 's/ssl.empirehost.me/iptorrents.com/; 69 | s/tracker\.//;s/routing.bgp.technology/iptorrents.com/; 70 | s/localhost.stackoverflow.tech/iptorrents.com/')" 71 | # IPT trackers 72 | fi 73 | no_source_2_source # 减少不必要的过程 74 | # set cookie 75 | [[ $s_site_uid ]] && \ 76 | cookie_source_site="$(eval echo '$'cookie_$s_site_uid)" 77 | } 78 | 79 | #-------------------------------------# 80 | set_source_site_cookie() { 81 | # 供二次编辑简介使用 82 | if [[ $source_site_URL = ${post_site[hds]} ]]; then 83 | s_site_uid='hds' 84 | cookie_source_site="$cookie_hds" 85 | elif [[ $source_site_URL = ${post_site[ttg]} ]]; then 86 | s_site_uid='ttg' 87 | cookie_source_site="$cookie_ttg" 88 | elif [[ $source_site_URL = ${post_site[hdc]} ]]; then 89 | s_site_uid='hdc' 90 | cookie_source_site="$cookie_hdc" 91 | elif [[ $source_site_URL = ${post_site[mt]} ]]; then 92 | s_site_uid='mt' 93 | cookie_source_site="$cookie_mt" 94 | elif [[ $source_site_URL = ${post_site[cmct]} ]]; then 95 | s_site_uid='cmct' 96 | cookie_source_site="$cookie_cmct" 97 | elif [[ $source_site_URL = ${post_site[byrbt]} ]]; then 98 | s_site_uid='byrbt' 99 | cookie_source_site="$cookie_byrbt" 100 | elif [[ $source_site_URL = ${post_site[npupt]} ]]; then 101 | s_site_uid='npupt' 102 | cookie_source_site="$cookie_npupt" 103 | elif [[ $source_site_URL = ${post_site[nanyangpt]} ]]; then 104 | s_site_uid='nanyangpt' 105 | cookie_source_site="$cookie_nanyangpt" 106 | elif [[ $source_site_URL = ${post_site[tjupt]} ]]; then 107 | s_site_uid='tjupt' 108 | cookie_source_site="$cookie_tjupt" 109 | fi 110 | } 111 | 112 | #-------------------------------------# 113 | get_search_keys() { 114 | local name season season_db year num 115 | # 剧集季数 116 | season="$(echo "$1"|grep -Eio '[ \.]s0?(10|20|[1-9]+).?(ep?[0-9]+)?[ \.]')" 117 | [[ $season ]] && season_db="$(echo "$season"|sed -E \ 118 | 's/s0?(10|20|[1-9]+).?(ep?[0-9]+)?[ \.]/Season.\1/i')" 119 | # 年份 120 | year="$(echo "$1"|sed 's/1080//;s/2160//'|grep -Eo '[12][098][0-9]{2}'|tail -1)" 121 | num="$(echo "$1"|sed 's/1080//;s/2160//'|grep -Eo '[12][098][0-9]{2}'|wc -l)" # 统计year个数 122 | # 删除分辨率 123 | name="$(echo "$1"|sed -E 's/(1080[pi]|720p|4k|2160p).*//i')" 124 | # 删除介质 125 | name="$(echo "$name"|sed -E 's/(hdtv|blu-?ray|web-?(dl)?|bdrip|dvdrip|webrip).*//i')" 126 | # 删除季数 127 | name="$(echo "$name"|sed -E 's/[ \.]s0?(10|20|[1-9]+).?(ep?[0-9]+)?[ \.].*//i')" 128 | name="$(echo "$name"|sed -E 's/[ \.]ep?[0-9]{1,2}(-e?p?[0-9]{1,2})?[ \.].*//i')" 129 | # 删除合集 130 | name="$(echo "$name"|sed -E 's/[ \.]Complete[\. ].*//i')" 131 | # 删除年份 132 | [[ $num -ge 1 ]] && name="$(echo "$name"|sed -E 's/[ \.][12][098][0-9]{2}[ \.]*/./g')" 133 | # 删除连续点和空格 134 | name="$(echo "$name"|sed -E 's/[ \.]+/./g')" 135 | # 返回 136 | [[ "$2" = db ]] && echo "$name" || \ 137 | if [[ $year ]]; then 138 | if [[ $season ]]; then 139 | echo "${name}+${year}+${season}" 140 | else 141 | echo "${name}+${year}" 142 | fi 143 | else 144 | echo "${name}" 145 | fi 146 | } 147 | 148 | #-------------------------------------# 149 | form_source_site_get_tID() { 150 | if [[ "$source_site_URL" && "$cookie_source_site" ]]; then 151 | local _sw_2 _sw_3 _sw_4 152 | _get_s_id() { 153 | ## TODO 搜索原种ID; 一个参数:关键词 154 | if [[ "$source_site_URL" = ${post_site[ttg]} ]]; then 155 | # TTG 156 | local s_search_URL="${source_site_URL}/browse.php" 157 | 158 | source_t_id="$(http --verify=no --ignore-stdin --timeout=25 -b GET \ 159 | "$s_search_URL" c==M search_field=="$1" "$cookie_source_site" "$user_agent"| \ 160 | grep -Eo "id=[0-9]+[^\"]*hit=1"|head -1|grep -Eo '[0-9]{3,}')" 161 | else 162 | # 一般形式 163 | local s_search_URL="${source_site_URL}/torrents.php" 164 | 165 | source_t_id="$(http --verify=no --ignore-stdin --timeout=25 -b GET \ 166 | "$s_search_URL" search=="$1" "$cookie_source_site" "$user_agent"| \ 167 | grep -Eo "id=[0-9]+[^\"]*hit=1"|head -1|grep -Eo '[0-9]{3,}')" 168 | fi 169 | } 170 | # 先判断源cookie是否有效 171 | [[ "$(http --verify=no --ignore-stdin -b "$source_site_URL" \ 172 | "$cookie_source_site" "$user_agent"|grep 'name="username"')" ]] && { \ 173 | echo "[ $source_site_URL ] Invalid cookie!!!" >> "$log_Path" 174 | debug_func "detail_p:[ $source_site_URL ] Invalid cookie!!!" # 无效 cookie 175 | } || { 176 | 177 | # First try 178 | _get_s_id "$dot_name" 179 | 180 | # Second try 181 | if [ ! "$source_t_id" ]; then 182 | debug_func "detail_p:关键词[$dot_name]未搜索到原种id!" 183 | _sw_2="$(get_search_keys "$dot_name")" 184 | [[ $dot_name != $_sw_2 ]] && _get_s_id "$_sw_2" 185 | fi 186 | 187 | #---deal with wrong year---# 188 | if [ ! "$source_t_id" ]; then 189 | _sw_3="$(echo "$_sw_2"|sed "s/+[12][089][0-9][0-9]//g")" 190 | [[ $_sw_3 != $_sw_2 ]] && _get_s_id "$_sw_3" 191 | fi 192 | #---try just with base name---# 193 | if [ ! "$source_t_id" ]; then 194 | _sw_4="$(echo "$_sw_3"|sed "s/\.+\..*//g")" 195 | [[ $_sw_4 != $_sw_3 ]] && _get_s_id "$_sw_3" 196 | fi 197 | [[ $source_t_id ]] && debug_func "detail_p:source-t_id[$source_t_id]" || \ 198 | debug_func "detail_p:[$_sw_4]未搜索到原种id!" 199 | } 200 | unset _search_w 201 | unset -f _get_s_id 202 | fi 203 | } 204 | 205 | #--------------main-func--------------# 206 | form_source_site_get_Desc() { 207 | [[ $s_site_uid ]] && echo "got source_site: [$s_site_uid]" >> "$log_Path" 208 | unset imdb_url douban_url extra_subt # 防止上次结果影响到下一次 209 | form_source_site_get_tID 210 | # source_t_id will be unset in generate.sh 211 | if [ "$source_t_id" ]; then 212 | #---hdsky 认领种子---# 213 | [[ -f "${ROOT_PATH}/get_desc/hdsky_adoption.sh" ]] && { 214 | source "${ROOT_PATH}/get_desc/hdsky_adoption.sh" 215 | call_hdsky_adoption; } 216 | #---define temp file name---# 217 | source_full="${ROOT_PATH}/tmp/${org_tr_name}_full.txt" 218 | http --verify=no --ignore-stdin --timeout=25 -b GET \ 219 | "${source_site_URL}/details.php?id=${source_t_id}" \ 220 | "$cookie_source_site" "$user_agent" > "$source_full" 221 | #---desc-full--start 222 | if [ -s "$source_full" ]; then 223 | # imdb 和豆瓣链接,用于生成简介 224 | imdb_url="$(grep -Eo 'tt[0-9]{7,8}' "$source_full"|head -1)" 225 | douban_url="$(grep -Eo 'douban\.com/subject/[0-9]{7,8}' "$source_full"|head -1)" 226 | [[ $douban_url ]] && douban_url="https://movie.douban.com/subject/${douban_url##*/}" 227 | [[ "$(grep -E '禁止转载|禁转资源|谢绝转发|独占资源|禁转资源|No forward anywhere' "$source_full")" ]] && local forbid='yes' 228 | 229 | # 匹配官方组 简介中的 info 以及 screens 所在行号 230 | local start_line end_line middle_line _ep ## extra_subt 原种副标题,非局域变量 231 | if [[ "$source_site_URL" = "${post_site[hds]}" ]]; then 232 | extra_subt="$(grep '&passkey=' "$source_full"|sed -E 's/.*">//;s%%%g')" 233 | start_line=$(sed -n '/影片参数/=' "$source_full"|head -1) 234 | end_line=$(sed -n '/<\/div><\/td><\/tr>$/=' "$source_full"|head -1) # 第一个 235 | 236 | elif [[ "$source_site_URL" = "${post_site[hdc]}" ]]; then 237 | extra_subt="$(grep -A1 ''|sed -E \ 238 | "s/[[:space:]]+/ /;s%%%g")" 239 | start_line=$(sed -n '/
    /=' "$source_full"|tail -1) 240 | end_line=$(sed -n '/<\/div><\/td><\/tr>$/=' "$source_full"|head -2|tail -1) # 第二个 241 | 242 | elif [[ "$source_site_URL" = "${post_site[ttg]}" ]]; then 243 | extra_subt="$(grep '

    ' "$source_full"|sed -E "s/[^\[]+\[//;s/\]//;s%%%g")" 244 | sed -E -i "s%%
    \n%ig" "$source_full" # 2019-02-19 update 245 | # 使用 sed -n '/匹配内容/=' 获取行号 246 | start_line=$(sed -n '/\.[cC]omparisons/=;/\.[sS]elected\.[sS]creens/=; 247 | /\.[mM]ore\.[sS]creens/=;/\.[pP]lot/=' "$source_full"|head -1) 248 | middle_line=$(sed -n '/.x264.[iI]nfo/=' "$source_full"|head -1) 249 | end_line=$(sed -n "$middle_line,$(($middle_line + 10))p" \ 250 | "$source_full"|sed -n '/<\/table>/='|head -1) # ttg 251 | end_line=$(($middle_line + $end_line - 1)) # ttg 252 | [[ $end_line ]] || end_line=$(sed -n '/x264 [info]/=' "$source_full"|tail -1) 253 | 254 | 255 | elif [[ "$source_site_URL" = "${post_site[mt]}" ]]; then 256 | extra_subt="$(grep -A2 '^//;s%%%g')" 258 | start_line=$(sed -n '/codetop/=' "$source_full"|head -1) 259 | end_line=$(sed -n '/<\/div><\/td><\/tr>$/=' "$source_full"|head -1) # 第一个 260 | 261 | elif [[ "$source_site_URL" = "${post_site[cmct]}" ]]; then 262 | extra_subt="$(grep -E "download.php\?id=[0-9]+\">\[CMCT\]" "$source_full"| \ 263 | sed -E 's/.*">//;s%%%g;s/\[//g;s/\]//g')" 264 | start_line=$(sed -n '/资料参数/=;/参数信息/=;/General Information/=' "$source_full"|head -1) 265 | end_line=$(sed -n '/下载信息/=;/郑重声明/=' "$source_full"|head -1) # 第一个 266 | 267 | else 268 | extra_subt="$(grep -E "副标题" "$source_full"|sed -E 's/.*">//;s%%%g;s/\[//g;s/\]//g')" 269 | _ep="$(grep -Eiom1 '[^a-z]Ep?[0-9]{1,2}(-Ep?[0-9]{1,2})?' "$source_full")" 270 | [[ "$_ep" && "$extra_subt" ]] && { 271 | _ep="${_ep/$'\n'*/}" # 取第一行, 替代 head -1 272 | shopt -s extglob 273 | extra_subt="${extra_subt} | 集数: ${_ep/?([^a-zA-Z0-9])}" 274 | shopt -u extglob; } 275 | # tjupt origin info 276 | [[ "$source_site_URL" = "${post_site[tjupt]}" ]] && { 277 | start_line="$(sed -n '\%
    代码
    %=' "$source_full")" 278 | end_line="$(sed -n '\%$%=' "$source_full")"; } 279 | 280 | fi 281 | # 裁剪简介获取 iNFO 以及 screens 282 | start_line=${start_line/$'\n'*}; end_line=${end_line/$'\n'*} # 替代 head -1 283 | if [[ $start_line && $end_line && $start_line -lt $end_line ]]; then 284 | sed -n "${start_line},${end_line}p" "$source_full" > "$source_desc" 285 | else 286 | debug_func "detail_p:start-l-[$start_line]end-l-[$end_line]" #----debug--- 287 | fi 288 | unset start_line end_line middle_line 289 | #----------------desc----------------start 290 | if [ -s "$source_desc" ]; then 291 | #---filter html code---# 292 | sed -i "s/.*id='kdescr'>//g;s/onclick=\"Previewurl([^)]*)[;]*\"//g; 293 | s/onload=\"Scale([^)]*)[;]*\"//g;s/onmouseover=\"[^\"]*;\"//g" "$source_desc" 294 | sed -i "s#onclick=\"Previewurl.*/>
    #/>
    #g" "$source_desc" 295 | sed -i "/本资源仅限/d;/法律责任/d" "$source_desc" 296 | sed -Ei "s@\"[^\"]*attachments([^\"]+)@\"${source_site_URL}/attachments\1@ig; 297 | s#src=\"attachments#src=\"${source_site_URL}/attachments#ig" "$source_desc" 298 | sed -i "s#onmouseover=\"[^\"]*[;]*\"##ig" "$source_desc" 299 | sed -i "s#onload=\"[^\"]*[;]*\"##ig" "$source_desc" 300 | sed -i "s#onclick=\"[^\"]*[;)]*\"##ig" "$source_desc" 301 | sed -i "1 s/代码//" "$source_desc" 302 | #---hdsky scripts---# 303 | sed -Ei "s###ig" "$source_desc" 304 | #---ttg,table---# 305 | sed -Ei "/^x264.*<\/table>/ s!.*!\n!ig" "$source_desc" 306 | 307 | #---copy as a duplication for byrbt---# 308 | [ "$enable_byrbt" = 'yes' ] && { \cp -f "$source_desc" "$source_html" 309 | sed -Ei 's/fieldset>|legend>/span>/ig;s/ ?引用 ?//g' "$source_html"; } 310 | 311 | #---html2bbcode---# 312 | source "$ROOT_PATH/get_desc/html2bbcode.sh" 313 | [[ $forbid = yes ]] && echo -e "\n&禁止转载&\n" >> "$source_desc" 314 | #----------------desc---------------- 315 | else 316 | debug_func 'get_desc:failed-to-get-source-page!' #----debug--- 317 | fi 318 | #----------------desc----------------end 319 | 320 | \rm -f "$source_full" 321 | unset source_full forbid 322 | fi 323 | #---desc-full--end 324 | fi 325 | } 326 | 327 | #-------------------------------------# 328 | 329 | -------------------------------------------------------------------------------- /get_desc/extract.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/extract.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-08-22 7 | # 8 | #-------------------------------------# 9 | # 提取rar分卷压缩种子,并制作种子文件。 10 | # unrar 需要在环境变量中。 11 | #-------------------------------------# 12 | 13 | extract_rar_files() { 14 | if [[ "$(find "${Tr_Path%/}/${Torrent_Name}" -type f -iname "*.r[a01][r0-9]"|wc -l)" -gt 5 ]]; then 15 | unrar e -o- -inul "${Tr_Path%/}/${Torrent_Name}/*.rar" "${Tr_Path%/}/${Torrent_Name}" 16 | if [[ $? -eq 0 || $? -eq 10 ]]; then 17 | # make dot torrent file, 10 means the files to extract already exist 18 | \rm -f "${flexget_path%/}/${Torrent_Name}.torrent" 19 | $dottorrent -t "https://iptorrents.com" -s 4M -p -x '*.rar' -x '*.r[0-9]*' -x '*.sfv' \ 20 | -x '.*' -c "Powered by rachpt/AutoSeed. https://github.com/rachpt/AutoSeed" \ 21 | "${Tr_Path%/}/${Torrent_Name}" "${flexget_path%/}/${Torrent_Name}.torrent" 22 | [[ $? -ne 0 ]] && debug_func 'extract: failed to make .torrent file!' 23 | else 24 | debug_func 'extract: failed to unrar!' 25 | fi 26 | fi 27 | } 28 | 29 | -------------------------------------------------------------------------------- /get_desc/font/cyberbit.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rachpt/AutoSeed/2fe4f723cbe00e0159af698e8aef8ee65ec91ec6/get_desc/font/cyberbit.ttf -------------------------------------------------------------------------------- /get_desc/gen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | # Copyright (c) 2017-2020 Rhilip 4 | 5 | import re 6 | import json 7 | import requests 8 | from bs4 import BeautifulSoup 9 | from html2bbcode.parser import HTML2BBCode 10 | 11 | __version__ = "0.3.4" 12 | __author__ = "Rhilip" 13 | 14 | douban_format = [ 15 | # (key name in dict. the format of key, string format) with order 16 | ("poster", "[img]{}[/img]\n\n"), 17 | ("trans_title", "◎译  名 {}\n"), 18 | ("this_title", "◎片  名 {}\n"), 19 | ("year", "◎年  代 {}\n"), 20 | ("region", "◎产  地 {}\n"), 21 | ("genre", "◎类  别 {}\n"), 22 | ("language", "◎语  言 {}\n"), 23 | ("playdate", "◎上映日期 {}\n"), 24 | ("imdb_rating", "◎IMDb评分 {}\n"), 25 | ("imdb_link", "◎IMDb链接 {}\n"), 26 | ("douban_rating", "◎豆瓣评分 {}\n"), 27 | ("douban_link", "◎豆瓣链接 {}\n"), 28 | ("episodes", "◎集  数 {}\n"), 29 | ("duration", "◎片  长 {}\n"), 30 | ("director", "◎导  演 {}\n"), 31 | ("writer", "◎编  剧 {}\n"), 32 | ("cast", "◎主  演 {}\n\n"), 33 | ("tags", "\n◎标  签 {}\n"), 34 | ("introduction", "\n◎简  介 \n\n  {}\n"), 35 | ("awards", "\n◎获奖情况 \n\n{}\n"), 36 | ] 37 | 38 | bangumi_format = [ 39 | ("cover", "[img]{}[/img]\n\n"), 40 | ("story", "[b]Story: [/b]\n\n{}\n\n"), 41 | ("staff", "[b]Staff: [/b]\n\n{}\n\n"), 42 | ("cast", "[b]Cast: [/b]\n\n{}\n\n"), 43 | ("alt", "(来源于 {} )\n") 44 | ] 45 | 46 | steam_format = [ 47 | ("cover", "[img]{}[/img]\n\n"), 48 | ('baseinfo', "【基本信息】\n\n{}\n"), 49 | ('descr', "【游戏简介】\n\n{}\n\n"), 50 | ('sysreq', "【配置需求】\n\n{}\n\n"), 51 | ('screenshot', "【游戏截图】\n\n{}\n\n"), 52 | ] 53 | 54 | support_list = [ 55 | ("douban", re.compile("(https?://)?movie\.douban\.com/(subject|movie)/(?P\d+)/?")), 56 | ("imdb", re.compile("(https?://)?www\.imdb\.com/title/(?Ptt\d+)")), 57 | # ("3dm", re.compile("(https?://)?bbs\.3dmgame\.com/thread-(?P\d+)(-1-1\.html)?")), 58 | ("steam", re.compile("(https?://)?(store\.)?steam(powered|community)\.com/app/(?P\d+)/?")), 59 | ("bangumi", re.compile("(https?://)?(bgm\.tv|bangumi\.tv|chii\.in)/subject/(?P\d+)/?")), 60 | ] 61 | 62 | headers = { 63 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 64 | 'Chrome/61.0.3163.100 Safari/537.36 ', 65 | "Accept-Language": "en,zh-CN;q=0.9,zh;q=0.8" 66 | } 67 | 68 | 69 | def get_page(url: str, json_=False, jsonp_=False, bs_=False, text_=False, **kwargs): 70 | kwargs.setdefault("headers", headers) 71 | page = requests.get(url, **kwargs) 72 | page.encoding = "utf-8" 73 | page_text = page.text 74 | if json_: 75 | return page.json() 76 | elif jsonp_: 77 | start_idx = page_text.find('(') 78 | end_idx = page_text.rfind(')') 79 | return json.loads(page_text[start_idx + 1:end_idx]) 80 | elif bs_: 81 | return BeautifulSoup(page.text, "lxml") 82 | elif text_: 83 | return page_text 84 | else: 85 | return page 86 | 87 | 88 | def html2ubb(html: str) -> str: 89 | return str(HTML2BBCode().feed(html)) 90 | 91 | 92 | class Gen(object): 93 | site = sid = url = ret = None 94 | img_list = [] # 临时存储图片信息 95 | 96 | def __init__(self, url: str): 97 | self.clear() 98 | self.pat(url) 99 | 100 | def pat(self, url: str): 101 | for site, pat in support_list: 102 | search = pat.search(url) 103 | if search: 104 | self.sid = search.group("sid") 105 | self.site = site 106 | if not self.site: 107 | self.ret["error"] = "No support link." 108 | 109 | def clear(self): 110 | self.site = self.sid = self.url = None 111 | self.img_list = [] # 临时存储图片信息 112 | self.ret = { 113 | "success": False, 114 | "error": None, 115 | "format": "", 116 | "copyright": "Powered by @{}".format(__author__), 117 | "version": __version__ 118 | } 119 | 120 | def gen(self, _debug=False): 121 | if not self.ret.get("error"): 122 | try: 123 | getattr(self, "_gen_{}".format(self.site))() 124 | self.ret["img"] = self.img_list 125 | self.ret["success"] = True if not self.ret.get("error") else False 126 | except Exception as err: 127 | raw_error = self.ret["error"] 128 | self.ret["error"] = "Internal error : {}, please connect @{}, thank you.".format(raw_error, __author__) 129 | if _debug: 130 | raise Exception("Internal error").with_traceback(err.__traceback__) 131 | return self.ret 132 | 133 | def _gen_douban(self): 134 | douban_link = "https://movie.douban.com/subject/{}/".format(self.sid) 135 | douban_page = get_page(douban_link, bs_=True) 136 | douban_api_json = get_page('https://api.douban.com/v2/movie/{}?apikey=0df993c66c0c636e29ecbb5344252a4a'.format(self.sid), json_=True) 137 | 138 | if "msg" in douban_api_json: 139 | self.ret["error"] = douban_api_json["msg"] 140 | elif str(douban_page).find("检测到有异常请求") > -1: 141 | self.ret["error"] = "GenHelp was banned by Douban." 142 | elif douban_page.title.text == "页面不存在": 143 | self.ret["error"] = "The corresponding resource does not exist." 144 | else: 145 | data = {"douban_link": douban_link} 146 | 147 | def fetch(node): 148 | return node.next_element.next_element.strip() 149 | 150 | # 对主页面进行解析 151 | data["chinese_title"] = (douban_page.title.text.replace("(豆瓣)", "").strip()) 152 | data["foreign_title"] = (douban_page.find("span", property="v:itemreviewed").text 153 | .replace(data["chinese_title"], '').strip()) 154 | 155 | aka_anchor = douban_page.find("span", class_="pl", text=re.compile("又名")) 156 | data["aka"] = sorted(fetch(aka_anchor).split(' / ')) if aka_anchor else [] 157 | 158 | if data["foreign_title"]: 159 | trans_title = data["chinese_title"] + (('/' + "/".join(data["aka"])) if data["aka"] else "") 160 | this_title = data["foreign_title"] 161 | else: 162 | trans_title = "/".join(data["aka"]) if data["aka"] else "" 163 | this_title = data["chinese_title"] 164 | 165 | data["trans_title"] = trans_title.split("/") 166 | data["this_title"] = this_title.split("/") 167 | 168 | region_anchor = douban_page.find("span", class_="pl", text=re.compile("制片国家/地区")) 169 | language_anchor = douban_page.find("span", class_="pl", text=re.compile("语言")) 170 | episodes_anchor = douban_page.find("span", class_="pl", text=re.compile("集数")) 171 | imdb_link_anchor = douban_page.find("a", text=re.compile("tt\d+")) 172 | year_anchor = douban_page.find("span", class_="year") 173 | 174 | data["year"] = douban_page.find("span", class_="year").text[1:-1] if year_anchor else "" # 年代 175 | data["region"] = fetch(region_anchor).split(" / ") if region_anchor else [] # 产地 176 | data["genre"] = list(map(lambda l: l.text.strip(), douban_page.find_all("span", property="v:genre"))) # 类别 177 | data["language"] = fetch(language_anchor).split(" / ") if language_anchor else [] # 语言 178 | data["playdate"] = sorted(map(lambda l: l.text.strip(), # 上映日期 179 | douban_page.find_all("span", property="v:initialReleaseDate"))) 180 | data["imdb_link"] = imdb_link_anchor.attrs["href"] if imdb_link_anchor else "" # IMDb链接 181 | data["imdb_id"] = imdb_link_anchor.text if imdb_link_anchor else "" # IMDb号 182 | data["episodes"] = fetch(episodes_anchor) if episodes_anchor else "" # 集数 183 | 184 | duration_anchor = douban_page.find("span", class_="pl", text=re.compile("单集片长")) 185 | runtime_anchor = douban_page.find("span", property="v:runtime") 186 | 187 | duration = "" # 片长 188 | if duration_anchor: 189 | duration = fetch(duration_anchor) 190 | elif runtime_anchor: 191 | duration = runtime_anchor.text.strip() 192 | data["duration"] = duration 193 | 194 | # 请求其他资源 195 | if data["imdb_link"]: # 该影片在豆瓣上存在IMDb链接 196 | imdb_source = ("https://p.media-imdb.com/static-content/documents/v1/title/{}/ratings%3Fjsonp=" 197 | "imdb.rating.run:imdb.api.title.ratings/data.json".format(data["imdb_id"])) 198 | try: 199 | imdb_json = get_page(imdb_source, jsonp_=True) # 通过IMDb的API获取信息,(经常超时555555) 200 | imdb_average_rating = imdb_json["resource"]["rating"] 201 | imdb_votes = imdb_json["resource"]["ratingCount"] 202 | if imdb_average_rating and imdb_votes: 203 | data["imdb_rating"] = "{}/10 from {} users".format(imdb_average_rating, imdb_votes) 204 | except Exception as err: 205 | pass 206 | 207 | # 获取获奖情况 208 | awards = "" 209 | awards_page = get_page("https://movie.douban.com/subject/{}/awards".format(self.sid), bs_=True) 210 | for awards_tag in awards_page.find_all("div", class_="awards"): 211 | _temp_awards = "" 212 | _temp_awards += "  " + awards_tag.find("h2").get_text(strip=True) + "\n" 213 | for specific in awards_tag.find_all("ul"): 214 | _temp_awards += "  " + specific.get_text(" ", strip=True) + "\n" 215 | 216 | awards += _temp_awards + "\n" 217 | 218 | data["awards"] = awards 219 | 220 | # 豆瓣评分,简介,海报,导演,编剧,演员,标签 221 | data["douban_rating_average"] = douban_average_rating = douban_api_json["rating"]["average"] or 0 222 | data["douban_votes"] = douban_votes = douban_api_json["rating"]["numRaters"] or 0 223 | data["douban_rating"] = "{}/10 from {} users".format(douban_average_rating, douban_votes) 224 | data["introduction"] = re.sub("^None$", "暂无相关剧情介绍", douban_api_json["summary"]) 225 | data["poster"] = poster = re.sub("s(_ratio_poster|pic)", r"l\1", douban_api_json["image"]) 226 | self.img_list.append(poster) 227 | 228 | data["director"] = douban_api_json["attrs"]["director"] if "director" in douban_api_json["attrs"] else [] 229 | data["writer"] = douban_api_json["attrs"]["writer"] if "writer" in douban_api_json["attrs"] else [] 230 | data["cast"] = douban_api_json["attrs"]["cast"] if "cast" in douban_api_json["attrs"] else "" 231 | data["tags"] = list(map(lambda member: member["name"], douban_api_json["tags"])) 232 | 233 | # -*- 组合数据 -*- 234 | descr = "" 235 | for key, ft in douban_format: 236 | _data = data.get(key) 237 | if _data: 238 | if isinstance(_data, list): 239 | join_fix = " / " 240 | if key == "cast": 241 | join_fix = "\n      " 242 | elif key == "tags": 243 | join_fix = " | " 244 | _data = join_fix.join(_data) 245 | descr += ft.format(_data) 246 | self.ret["format"] = descr 247 | 248 | # 将清洗的数据一并发出 249 | self.ret.update(data) 250 | 251 | def _gen_imdb(self): 252 | douban_imdb_api = get_page("https://api.douban.com/v2/movie/imdb/{}?apikey=0df993c66c0c636e29ecbb5344252a4a".format(self.sid), json_=True) 253 | if douban_imdb_api.get("alt"): 254 | # 根据tt号先在豆瓣搜索,如果有则直接使用豆瓣解析结果 255 | self.pat(douban_imdb_api["alt"]) 256 | self._gen_douban() 257 | else: # TODO 如果没有,则转而从imdb上解析数据。 258 | self.ret["error"] = "Can't find this imdb_id({}) in Douban.".format(self.sid) 259 | 260 | def _gen_steam(self): 261 | steam_chs_url = "http://store.steampowered.com/app/{}/?l=schinese".format(self.sid) 262 | steam_page = requests.get(steam_chs_url, 263 | # 使用cookies避免 Steam 年龄认证 264 | cookies={"mature_content": "1", "birthtime": "157737601", 265 | "lastagecheckage": "1-January-1975", "wants_mature_content": "1"}) 266 | if re.search("(欢迎来到|Welcome to) Steam", steam_page.text): # 不存在的资源会被302到首页,故检查标题或r.history 267 | self.ret["error"] = "The corresponding resource does not exist." 268 | else: 269 | data = {} 270 | steam_bs = BeautifulSoup(steam_page.text, "lxml") 271 | # 从网页中定位数据 272 | name_anchor = steam_bs.find("div", class_="apphub_AppName") or steam_bs.find("span", itemprop="name") # 游戏名 273 | cover_anchor = steam_bs.find("img", class_="game_header_image_full") # 游戏封面图 274 | detail_anchor = steam_bs.find("div", class_="details_block") # 游戏基本信息 275 | linkbar_anchor = steam_bs.find("a", class_="linkbar") # 官网 276 | language_anchor = steam_bs.select("table.game_language_options > tr")[1:] # 已支持语言 277 | tag_anchor = steam_bs.find_all("a", class_="app_tag") # 标签 278 | rate_anchor = steam_bs.find_all("div", class_="user_reviews_summary_row") # 游戏评价 279 | descr_anchor = steam_bs.find("div", id="game_area_description") # 游戏简介 280 | sysreq_anchor = steam_bs.select("div.sysreq_contents > div.game_area_sys_req") # 系统需求 281 | screenshot_anchor = steam_bs.select("div.screenshot_holder a") # 游戏截图 282 | 283 | # 请求第三方中文名信息 284 | try: # Thanks @Deparsoul with his Database 285 | steamcn_json = get_page("https://steamdb.steamcn.com/app/{}/data.js?v=38".format(self.sid), jsonp_=True) 286 | except Exception: 287 | pass 288 | else: 289 | if "name_cn" in steamcn_json: 290 | data["name_chs"] = steamcn_json["name_cn"] 291 | 292 | # 数据清洗 293 | def reviews_clean(tag): 294 | return tag.get_text(" ", strip=True).replace(":", ":") 295 | 296 | def sysreq_clean(tag): 297 | os_dict = {"win": "Windows", "mac": "Mac OS X", "linux": "SteamOS + Linux"} 298 | os_type = os_dict[tag["data-os"]] 299 | sysreq_content = re.sub("([^配置]):\n", r"\1: ", tag.get_text("\n", strip=True)) 300 | 301 | return "{}\n{}".format(os_type, sysreq_content) 302 | 303 | def lag_clean(tag): 304 | lag_checkcol_list = ["界面", "完全音频", "字幕"] 305 | tag_td_list = tag.find_all("td") 306 | lag_support_checkcol = [] 307 | lag = tag_td_list[0].get_text(strip=True) 308 | if re.search("不支持", tag.text): 309 | lag_support_checkcol.append("不支持") 310 | else: 311 | for i, j in enumerate(tag_td_list[1:]): 312 | if j.find("img"): 313 | lag_support_checkcol.append(lag_checkcol_list[i]) 314 | 315 | return lag + ("({})".format(", ".join(lag_support_checkcol)) if lag_support_checkcol else "") 316 | 317 | data["cover"] = re.sub("^(.+?)(\?t=\d+)?$", r"\1", (cover_anchor or {"src": ""})["src"]) 318 | data["name"] = name_anchor.get_text(strip=True) 319 | data["detail"] = detail_anchor.get_text("\n", strip=True).replace(":\n", ": ").replace("\n,\n", ", ") 320 | data["tags"] = list(map(lambda t: t.get_text(strip=True), tag_anchor)) or [] 321 | data["review"] = list(map(reviews_clean, rate_anchor)) or [] 322 | if linkbar_anchor and re.search("访问网站", linkbar_anchor.text): 323 | data["linkbar"] = re.sub("^.+?url=(.+)$", r"\1", linkbar_anchor["href"]) 324 | data["language"] = list(filter(lambda s: s.find("不支持") == -1, map(lag_clean, language_anchor)))[:3] or [] 325 | 326 | base_info = "中文名: {}\n".format(data["name_chs"]) if data.get("name_chs") else "" 327 | base_info += (data["detail"] + "\n") if data.get("detail") else "" 328 | base_info += "官方网站: {}\n".format(data["linkbar"]) if data.get("linkbar") else "" 329 | base_info += ("游戏语种: " + " | ".join(data["language"]) + "\n") if data.get("language") else "" 330 | base_info += ("标签: " + " | ".join(data["tags"]) + "\n") if data.get("tags") else "" 331 | base_info += ("\n".join(data["review"]) + "\n") if data.get("review") else "" 332 | 333 | data["baseinfo"] = base_info 334 | data["descr"] = html2ubb(str(descr_anchor)).replace("[h2]关于这款游戏[/h2]", "").strip() 335 | data["screenshot"] = list(map(lambda dic: re.sub("^.+?url=(http.+?)\.[\dx]+(.+?)(\?t=\d+)?$", 336 | r"\1\2", dic["href"]), screenshot_anchor)) 337 | data["sysreq"] = list(map(sysreq_clean, sysreq_anchor)) 338 | 339 | # 主介绍生成 340 | descr = "" 341 | for key, ft in steam_format: 342 | _data = data.get(key) 343 | if _data: 344 | if isinstance(_data, list): 345 | join_fix = "\n" 346 | if key == "screenshot": 347 | _data = map(lambda d: "[img]{}[/img]".format(d), _data) 348 | if key == "sysreq": 349 | join_fix = "\n\n" 350 | _data = join_fix.join(_data) 351 | descr += ft.format(_data) 352 | self.ret["format"] = descr 353 | 354 | # 将清洗的数据一并发出 355 | self.ret.update(data) 356 | 357 | def _gen_bangumi(self): 358 | bangumi_link = "https://bgm.tv/subject/{}".format(self.sid) 359 | bangumi_characters_link = "https://bgm.tv/subject/{}/characters".format(self.sid) 360 | 361 | bangumi_page = get_page(bangumi_link, bs_=True) 362 | if str(bangumi_page).find("出错了") > -1: 363 | self.ret["error"] = "The corresponding resource does not exist." 364 | else: 365 | data = {"id": self.sid, "alt": bangumi_link} 366 | 367 | # 对页面进行划区 368 | cover_staff_another = bangumi_page.find("div", id="bangumiInfo") 369 | cover_another = cover_staff_another.find("img") 370 | staff_another = cover_staff_another.find("ul", id="infobox") 371 | story_another = bangumi_page.find("div", id="subject_summary") 372 | # cast_another = bangumi_page.find("ul", id="browserItemList") 373 | 374 | data["cover"] = re.sub("/cover/[lcmsg]/", "/cover/l/", "https:" + cover_another["src"]) # Cover 375 | data["story"] = story_another.get_text() if story_another else "" # Story 376 | data["staff"] = list(map(lambda tag: tag.get_text(), staff_another.find_all("li")[4:4 + 15])) # Staff 377 | 378 | bangumi_characters_page = get_page(bangumi_characters_link, bs_=True) 379 | 380 | cast_actors = bangumi_characters_page.select("div#columnInSubjectA > div.light_odd > div.clearit") 381 | 382 | def cast_clean(tag): 383 | h2 = tag.find("h2") 384 | char = (h2.find("span", class_="tip") or h2.find("a")).get_text().replace("/", "").strip() 385 | cv = "、".join(map(lambda p: (p.find("small").get_text() or p.find("a").get_text()).strip(), 386 | tag.select("> div.clearit > p"))) 387 | return "{}:{}".format(char, cv) 388 | 389 | data["cast"] = list(map(cast_clean, cast_actors))[:9] # Cast 390 | 391 | descr = "" 392 | for key, ft in bangumi_format: 393 | _data = data.get(key) 394 | if _data: 395 | if isinstance(_data, list): 396 | _data = "\n".join(_data) 397 | descr += ft.format(_data) 398 | data["format"] = descr 399 | 400 | self.ret.update(data) 401 | -------------------------------------------------------------------------------- /get_desc/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/generate.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-10-28 7 | # 8 | #-------------------------------------# 9 | # 本文件通过豆瓣或者IMDB链接(如果都没有则使用资源0day名), 10 | # 通过 @Rhilip 提供的API获得简介,或则本地 python 解析, 11 | # 本地生成豆瓣简介(需要设置允许)。 12 | #-------------------------------------# 13 | 14 | # 通过 豆瓣 suggest 搜索资源豆瓣ID,用于后续简介获取 15 | get_douban_url_by_keywords() { 16 | search_doubanurl() { 17 | local _key _year 18 | _key="$(get_search_keys "$1" 'db')" # get_desc/detail_page.sh 19 | _year="$(echo "$1"|grep -Eo '[12][098][0-9]{2}'|tail -1)" 20 | [[ "$_year" ]] || _year=`date +%Y` # 默认当前年份 21 | search_url="$(http --verify=no --pretty=format --ignore-stdin --timeout=25 \ 22 | -b GET 'https://movie.douban.com/j/subject_suggest' q=="$_key" "$user_agent"| \ 23 | grep -B 1 "$_year"|grep -Eio \ 24 | 'https?://(movie.)?douban.com/subject/[0-9]+'|head -1)" 25 | # 去掉可能不准确的年份再试 26 | [[ "$search_url" ]] || \ 27 | search_url="$(http --verify=no --pretty=format --ignore-stdin --timeout=25 \ 28 | -b GET 'https://movie.douban.com/j/subject_suggest' q=="$_key" "$user_agent"| \ 29 | grep -Eio 'https?://(movie.)?douban.com/subject/[0-9]+'|head -1)" 30 | debug_func "豆瓣关键词:[${_key}+${_year}]" #----debug--- 31 | } 32 | # the first time try 33 | search_doubanurl "$org_tr_name" 34 | [[ $search_url ]] || sleep 3 && search_doubanurl "$dot_name" # try again 35 | # 写入日志 36 | [[ "$search_url" ]] && echo "搜索得到豆瓣链接:$search_url" >> "$log_Path" || \ 37 | echo '未搜索到豆瓣链接!!!' >> "$log_Path" 38 | unset -f search_doubanurl 39 | } 40 | 41 | poster_to_bbcode() { 42 | # 参数$1,海报列表,$2,链接 43 | local _one_url _the_rest _line 44 | local _url_lists="$(echo "$1"|sed 's/http:/https:/')" # https 图片url 45 | _line=$(($RANDOM % $(echo "$_url_lists"|wc -l) + 1)) # 随机海报 46 | [[ $_line ]] || _line=1 # default the first one 47 | _one_url="$(echo "$_url_lists"|sed -n "$_line p")" 48 | gen_desc_bbcode="$(echo "$gen_desc_bbcode"|sed "s%$douban_poster_url%$_one_url%")" 49 | # 删除url中的/,否则需要使用\对每个\转义!!!最多留12条链接 50 | _the_rest="$(echo "$_url_lists"|sed "/${_one_url##*/}/d"|head -12)" # url contents slash!!! 51 | [[ $_the_rest ]] && { 52 | _the_rest="$(echo "$_the_rest"|sed "1i 其他海报: [来自$2]")" 53 | # 转化为\n分割的一行, `` cmd have to use \\\n, while $() cmd use \\n 54 | _the_rest="$(echo "$_the_rest"|sed ':a;N;s/\n/\\n/;ta;')" 55 | # sed append use a line contain '\n' to append multi lines 56 | gen_desc_bbcode="$(echo "$gen_desc_bbcode"|sed "/\[img\]/a $_the_rest")" 57 | debug_func "gen-multi-url:[`echo "$_url_lists"|wc -l`]" #----debug--- 58 | } 59 | debug_func "gen-other-poster-url:[$_one_url]" #----debug--- 60 | } 61 | 62 | mtime_poster() { 63 | # 获取时光网海报 64 | local mtime_id mtime_lists _name 65 | _name="$1" # one param to search, chinese name 66 | mtime_id="$(http --ignore-stdin --timeout=26 GET \ 67 | 'http://service-channel.mtime.com/Search.api' Ajax_CallBack==true \ 68 | Ajax_CallBackType=='Mtime.Channel.Services' Ajax_CallBackMethod==GetSuggestObjs \ 69 | Ajax_CallBackArgument0=="$_name"|sed -E 's/(,|:\[\{)/\n/g'|grep -B3 \ 70 | "\"$_name\""|grep -E 'id.*[0-9]+'|grep -Eo '[0-9]+'|head -1)" 71 | if [[ "$mtime_id" ]]; then 72 | debug_func "gen-mtime-id:[$mtime_id]" #----debug--- 73 | mtime_lists="$(http --ignore-stdin --timeout=26 GET \ 74 | "http://movie.mtime.com/$mtime_id/posters_and_images/posters/hot.html"| \ 75 | grep 'imageList'|sed 's/},{/\n/g'|grep '正式海报'|grep -Eo \ 76 | "https?://img[0-9]+\.mtime\.(cn|com)/pi/(u/)?[/0-9\._]+X1000\.(jpg|jpeg|png|gif)")" 77 | if [[ "$mtime_lists" ]]; then 78 | poster_to_bbcode "$mtime_lists" "http://movie.mtime.com/$mtime_id/" 79 | else 80 | debug_func 'gen-mtime-poster-url:[failed!]' #----debug--- 81 | fi 82 | else 83 | debug_func 'gen-mtime:[failed-to-find-id!]' #----debug--- 84 | fi 85 | } 86 | 87 | m1905_poster() { 88 | # 获取m1905 网海报 89 | local m1905_id m1905_lists _name _urls 90 | _name="$1" # one param to search, chinese name 91 | m1905_id="$(http --ignore-stdin --timeout=26 GET "http://www.1905.com/search/?q=$_name"| \ 92 | grep "title=\"$_name\""|grep -Eo 'film/[0-9]{3,}/'|head -1|grep -Eo '[0-9]+')" 93 | if [[ "$m1905_id" ]]; then 94 | debug_func "gen-m1905-id:[$m1905_id]" #----debug--- 95 | _urls="$(http --ignore-stdin --timeout=26 GET "http://www.1905.com/mdb/film/$m1905_id/still/"| \ 96 | grep -A2 '>海报'|grep -Eo "https?://(image[0-9]+|www)\.m?1905\.(com|cn)[^\"\']+\.(jpg|jpeg|png|gif|shtml)"| \ 97 | sort|uniq|sed -E 's/thumb_[0-9]_[0-9]{2,3}_[0-9]{2,3}_//')" 98 | m1905_lists="$(echo "$_urls"|grep -Eo "https?://image[0-9]+[^\"\']+\.(jpg|jpeg|png|gif)")" 99 | # 获取更多的海报 100 | [[ "$(echo "$m1905_lists"|wc -l)" -le 3 ]] && { 101 | _urls="$(echo "$_urls"|grep '.*\.shtml'|head -1)" # newgallery/hdpic 102 | [[ "$_urls" ]] && m1905_lists="$(http --ignore-stdin --timeout=26 GET "$_urls"| \ 103 | grep -A2 '
    '|grep -Eo "https?://image[0-9]+.m1905.(com|cn)[^\"\']+\.(jpg|jpeg|png|gif)"| \ 104 | grep -v 'thumb'|sort|uniq)"; } 105 | fi 106 | if [[ "$m1905_lists" ]]; then 107 | poster_to_bbcode "$m1905_lists" "http://www.1905.com/mdb/film/$m1905_id/" 108 | else 109 | debug_func 'gen-m1905-poster-url:[failed!] || trying-mtime...' #----debug--- 110 | mtime_poster "$_name" 111 | fi 112 | } 113 | #-------------------------------------# 114 | from_douban_get_desc() { 115 | # 获取搜索链接 116 | [[ $douban_url ]] || douban_url="$(grep -Eio \ 117 | 'https?://(www\.|movie\.)?douban\.com/subject/[0-9]{7,8}/?' "$source_desc"|head -1)" 118 | [[ $imdb_url ]] || imdb_url="$(grep -Eio 'tt[0-9]{7,8}' "$source_desc"|head -1)" 119 | if [[ "$douban_url" ]]; then 120 | search_url="$douban_url" 121 | elif [[ "$imdb_url" ]]; then 122 | if [[ $dot_name =~ .*\.[Ss](0?[2-9]|[1-9]?[0-9])\..*WiKi ]]; then 123 | debug_func 'gen-wiki-series!...' #----debug--- 124 | get_douban_url_by_keywords # WiKi series case 125 | else 126 | search_url="http://www.imdb.com/title/$imdb_url" 127 | fi 128 | else 129 | get_douban_url_by_keywords 130 | fi 131 | debug_func "generate-search-url:[$search_url]" #----debug--- 132 | # 使用 API 或者 python 本地解析豆瓣简介 133 | if [ "$search_url" ]; then 134 | local desc_json _get i _sk 135 | unset gen_desc_bbcode douban_poster_url chs_name_douban eng_name_douban 136 | if [[ $Use_Local_Gen = yes ]]; then 137 | desc_json="$("$python3" -c "import sys;sys.path.append(\"${ROOT_PATH}/get_desc/\"); \ 138 | from gen import Gen;import json;gen=Gen(\"${search_url}\").gen(_debug=True); \ 139 | print(json.dumps(gen,sort_keys=True,indent=2,separators=(',',':'),ensure_ascii=False))")" 140 | fi 141 | _get="$(echo "$desc_json"|grep -Eq '"format".+".+",' && echo yes || echo no)" 142 | debug_func "generate-code-local:[$_get]" #----debug--- 143 | for ((i=1;i<=2;i++)); do 144 | if [[ $_get = no ]]; then 145 | [[ $imdb_url ]] && _sk="site=douban&sid=$imdb_url" || _sk="url=$search_url" 146 | desc_json="$(http --pretty=format --ignore-stdin --timeout=36 --verify=no \ 147 | GET "`eval echo '$'db_api_$i`?${_sk}")" 148 | _get="$(echo "$desc_json"|grep -Eq '"format".+".+",' && echo yes || echo no)" 149 | debug_func "generate-code-api-$i:[$_get]" #----debug--- 150 | else 151 | break 152 | fi 153 | done 154 | 155 | gen_desc_bbcode="$(echo "$desc_json"|grep 'format'| \ 156 | awk -F '"' '{print $4}'|sed 's#\\n#\n#g;s/img3/img1/;s/\[center\]//;s%\[/center\]%%')" 157 | 158 | douban_poster_url="$(echo "$desc_json"|grep '"poster":'| \ 159 | head -1|awk -F '"' '{print $4}'|sed 's/img3/img1/')" 160 | # 中文名 161 | chs_name_douban="$(echo "$desc_json"|grep 'chinese_title'| \ 162 | head -1|awk -F '"' '{print $4}')" 163 | # 英文名 164 | eng_name_douban="$(echo "$desc_json"|grep 'foreign_title'| \ 165 | head -1|awk -F '"' '{print $4}')" 166 | m1905_poster "$chs_name_douban" # try to find another poster image url 167 | 168 | [[ $enable_byrbt = yes ]] && gen_desc_html="$(echo "$gen_desc_bbcode"| \ 169 | sed "1c "|sed 's!$!&
    !g')" # byrbt 170 | fi 171 | unset search_url 172 | } 173 | filt_subt() { 174 | [[ "$chs_name_douban" && "$extra_subt" ]] && { 175 | extra_subt="$(echo "$extra_subt"|sed -E \ 176 | "s/$chs_name_douban//;s%^[ /]+%%;s/ +/ /g;s/"//g;s/\[ *\]//g")" 177 | } 178 | } 179 | #-------------------------------------# 180 | # 拼接简介 181 | generate_main_func() { 182 | from_douban_get_desc 183 | filt_subt 184 | # bbcode 185 | : "$(< "$source_desc")" 186 | source_desc_tmp="&extra_comment&${extra_subt} 187 | &shc_name_douban&${chs_name_douban} 188 | &eng_name_douban&${eng_name_douban} 189 | ${gen_desc_bbcode} 190 | 191 | [quote=iNFO][font=monospace] 192 | $([[ -s $source_desc ]] && echo "$_" || echo 'Failed to get mediainfo!') 193 | [/font][/quote] 194 | $(if [ $source_t_id ]; then 195 | echo -e "\n[quote=转载来源][b]本种来自:[/b] ${source_site_URL}/details.php?id=${source_t_id}[/quote]" 196 | else 197 | echo -e "\n[quote=转载来源][b]本种来自:[/b] ${source_site_URL}[/quote]" 198 | fi ) 199 | " 200 | 201 | # byrbt 所需要的 html 简介 202 | [[ $enable_byrbt = yes ]] && { 203 | : "$(< "$source_html")" 204 | source_html_tmp="${gen_desc_html}
    205 |
    iNFO 206 | $([[ -s $source_desc ]] && echo "$_" || echo 'Failed to get mediainfo!') 207 |





    208 | 转载来源 209 | $(if [ $source_t_id ]; then 210 | echo '本种来自: '${source_site_URL}/details.php?id=${source_t_id}'' 211 | else 212 | echo '本种来自: '${source_site_URL}'' 213 | fi) 214 |

    "; } 215 | 216 | # 简介覆盖保存至文件 217 | echo "$source_desc_tmp" > "$source_desc" 218 | [[ $enable_byrbt = yes ]] && echo "$source_html_tmp" > "$source_html" 219 | # 清空变量,防止不同种子简介互串 220 | unset source_t_id extra_subt source_site_URL s_site_uid 221 | unset imdb_url douban_url 222 | unset source_desc_tmp source_html_tmp 223 | unset chs_name_douban eng_name_douban douban_poster_url 224 | } 225 | 226 | #-------------------------------------# 227 | 228 | -------------------------------------------------------------------------------- /get_desc/hdsky_adoption.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/hdsky_adoption.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2020-02-10 7 | # 8 | #-------------------------------------# 9 | # 本 shell 脚本作用为 hdsky 认领种子。 10 | #-------------------------------------# 11 | call_hdsky_adoption(){ 12 | if [[ $s_site_uid == 'hds' && $source_t_id ]]; then 13 | local hds_adoption_url _uid hds_faq_url 14 | hds_faq_url="${post_site[hds]}/faq.php" 15 | _uid="$(http --verify=no --timeout=10 -Ib GET "$hds_faq_url" "$cookie_hds" \ 16 | "$user_agent"|grep -Eio 'userdetails.php\?id=[0-9]+'|grep -om1 '[0-9]*')" 17 | [[ $_uid ]] || debug_func "hdsky_adoption:获取用户id失败!" #----debug--- 18 | hds_adoption_url="${post_site[hds]}/adoption.php" 19 | if http --verify=no --timeout=10 --print=h -If POST "$hds_adoption_url" \ 20 | torrentid="$source_t_id" uid="$_uid" action='add' "$cookie_hds" \ 21 | "$user_agent" &> /dev/null; then 22 | debug_func "hdsky_adoption:成功认领-[$source_t_id]" #----debug--- 23 | else 24 | case $? in 25 | 2) debug_func 'hdsky_adoption:Request timed out!' ;; 26 | 3) debug_func 'hdsky_adoption:Unexpected HTTP 3xx Redirection!' ;; 27 | 4) debug_func 'hdsky_adoption:HTTP 4xx Client Error!' ;; 28 | 5) debug_func 'hdsky_adoption:HTTP 5xx Server Error!' ;; 29 | 6) debug_func 'hdsky_adoption:Exceeded --max-redirects= redirects!' ;; 30 | *) debug_func 'hdsky_adoption:Other Error!' ;; 31 | esac 32 | fi 33 | fi 34 | } 35 | 36 | -------------------------------------------------------------------------------- /get_desc/html2bbcode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/html2bbcode.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2018-12-12 7 | # 8 | #-------------------------------------# 9 | # 本 shell 脚本作用为转化原种 html 格式 iNFO 以及 screens页面至 bbcode。 10 | # 优先处理 font 标签,字体,颜色。 11 | # img 标签部分需要补全域名。 12 | #-------------------------------------# 13 | #---cmct---# 14 | sed -Ei '/下载信息/d;/郑重声明/d' "$source_desc" 15 | 16 | sed -i "s/id=\"[^\"]\"//g; s/alt=\"[^\"]\"//g" "$source_desc" 17 | 18 | sed -i "s##[b]#g;s##[/b]#g" "$source_desc" 19 | sed -i "s#]*>##g;s###g;s#]*>##g;s#

    ##g;s#]*>##g;s###g;s#]*>##g;s###g" "$source_desc" 20 | sed -i "s#]*>##g;s#
    ##g" "$source_desc" 21 | sed -i "s##[u]#g;s##[/u]#g;s#]\*>##g;s#

    ##g;" "$source_desc" # ttg 22 | 23 | #---color & size---# 24 | sed -i "s#\([^<]\+\)#[color=\1]\2[/color]#g" "$source_desc" 25 | 26 | sed -i "s#\(font size=.*\)#\1[/size]#g" "$source_desc" 27 | 28 | sed -i "s#]*>#[size=\1]#g" "$source_desc" 29 | #sed -i "s#]*>#[color=\1]#g" "$source_desc" 30 | 31 | #---br---# 32 | sed -i "s/
    //g;s///g;s/
    //g;s/ //g" "$source_desc" 33 | 34 | #---font face---# 35 | sed -i "s//[font=monospace]/g;s//[font=monospace]/g;s/<\/font>/[\/font]/g" "$source_desc" 36 | 37 | #---table---# 38 | sed -i "s#]\+>#[quote]#g;s##[/quote]\n#g;" "$source_desc" 39 | 40 | #---img---# 41 | sed -i "s!\"[^\"]*attachments\([^\"]\+\)!\"${source_site_URL}/attachments\1!g" "$source_desc" 42 | sed -i "s#]\+src=\"\(.[^\"]\+\)\"[^>]*>#[img]\1[/img]#g" "$source_desc" 43 | sed -i "s#\]attachments#\]${source_site_URL}/attachments#g" "$source_desc" 44 | 45 | #---a---# 46 | sed -i "s##[/url]#g;s#]\+href=\"\(.[^\"]\+\)\"[^<]*>#[url=\1]#g" "$source_desc" 47 | 48 | #---hdsky & hdchina---# 49 | sed -i "s#[^>]\+引用[^>]\+##g;s#fieldset#quote#g" "$source_desc" 50 | 51 | #---others---# 52 | sed -i "s#<#[#g;s#>#]#g" "$source_desc" 53 | 54 | #---double url---# 55 | sed -i "s!\[url=[^\]]\+/\]\[url=\(.*\)\[/url\]\[/url\]![url=\1[/url]!g" "$source_desc" 56 | 57 | #---ttg imdb url---# 58 | sed -i "s!\[url=http[s]*://www.imdb.com/title/tt[0-9]\{7,8\}[/]*\]\[url=http[s]*://www.imdb.com/title/tt[0-9]\{7,8\}[/]*\]\(http[s]*://www.imdb.com/title/tt[0-9]\{7,8\}[/]*\)\[/url\]\[/url\]!\1!g" "$source_desc" 59 | sed -i "s!\[url=http[s]*://movie.douban.com/subject/[0-9]\{8\}[/]*\]\[url=http[s]*://movie.douban.com/subject/[0-9]\{8\}[/]*\]\(http[s]*://movie.douban.com/subject/[0-9]\{8\}[/]*\)\[/url\]\[/url\]!\1!g" "$source_desc" 60 | 61 | sed -i -r '/quote/{s/font color=["]([a-zA-Z]+)["]/color=\1/g;s/\[\/font\]/[\/size]/;s/\[\/font\]/[\/color]/}' "$source_desc" 62 | 63 | #---cmct---# 64 | sed -i "s/^代码[\r\n]*$/[quote]/;/截图信息/i [/quote]" "$source_desc" 65 | 66 | -------------------------------------------------------------------------------- /get_desc/info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/info.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2020-01-07 7 | # 8 | #-------------------------------------# 9 | # 复制 nfo 文件内容至简介,如果没有 nfo 文件, 10 | # 则采用 mediainfo 生成主文件的编码信息至临时文件。 11 | # 自动判断 是否有 nfo 文件,以及 nfo 文件是否下载完成。 12 | #-------------------------------------# 13 | # 14 | # 使用 ffmpeg 生成视频缩略图 15 | gen_thumbnail_with_ffmpeg() { 16 | local step total file size ratio row column 17 | screen_file="${ROOT_PATH}/tmp/autoseed-$(date '+%s%N').jpg" 18 | file="$max_size_file" 19 | size=512 # 单个缩略图宽 512 pix,最好16的倍数 20 | row=4 # 行数 21 | column=3 # 列数 22 | ratio="$($mediainfo "$file" --Output="Video;%FrameRate%")" 23 | total="$($mediainfo "$file" --Output="Video;%FrameCount%")" 24 | # 首末去掉 1500 帧,等分 25 | step=$(bc <<< "($total - 3000)/(($row * $column) * $ratio)") 26 | for ((i=1;i<=(row * column);i++)); do 27 | # 多线程 28 | ( $ffmpeg -ss "$(bc <<< "(1500/$ratio)+($step * $i)")" -i "$file" -vframes 1 \ 29 | -vf "scale=$size:-1" "${ROOT_PATH}/tmp/thumbnail-$(printf "%03d" $i).jpg" -y 2>/dev/null ) & 30 | done 31 | wait # 等待所有 截图完成 32 | $ffmpeg -i "${ROOT_PATH}/tmp/thumbnail-%03d.jpg" -filter_complex \ 33 | "tile=3x4:nb_frames=0:padding=5:margin=5:color=random" "$screen_file" -y 2>/dev/null 34 | [[ $? -ne 0 ]] && debug_func "info:ffmpeg-have-failed!!!" #----debug--- 35 | \rm -f "${ROOT_PATH}/tmp"/thumbnail-[0-9]*.jpg # 通配符,不能使用引号包裹 36 | } 37 | # 使用 mtn 生成视频缩略图,http://moviethumbnail.sourceforge.net/ 38 | gen_thumbnail_with_mtn() { 39 | local _file _font _inf 40 | # 处理可能意外遗留的缩略图 41 | [[ "$(ls "${ROOT_PATH}/tmp/"*-autoseed.jpg 2> /dev/null)" ]] && { 42 | [[ -d "${ROOT_PATH}/tmp/old" ]] || mkdir -p "${ROOT_PATH}/tmp/old" 43 | \mv -f "${ROOT_PATH}/tmp/"*-autoseed.jpg "${ROOT_PATH}/tmp/old"; } 44 | 45 | _file="$max_size_file" # 截图文件,可以是路径 46 | _font="${ROOT_PATH}/get_desc/font/cyberbit.ttf" # 字体文件,兼顾中英文 47 | _inf="Powered by rachpt/Autoseed (https://github.com/rachpt/AutoSeed)" 48 | # 参数说明: -g 8小图间隔8pix,--shadow=3阴影3pix,-H文件大小友好显示 49 | # -B 180 跳过开头3min,-D 12 边缘检测,-b 0.8 全黑最大80% 50 | # -T 自定义文字,-w 图片宽度,-c column -r row -k 背景色 -L info和时间位置 51 | # -F info和时间戳字体和大小等,-o 后缀名 -f info字体 -O 输出路径dir 52 | # 详细:http://moviethumbnail.sourceforge.net/usage.en.html 53 | $mtn -g 8 --shadow=3 -H -B 180 -D 12 -b 0.8 -T "$_inf" -w 1568 -c 3 -r 4 -k 000000 -L 4:2 \ 54 | -F FFFF00:18:"$_font":ff0000:000000:24 -o '-autoseed.jpg' -f "$_font" \ 55 | "$_file" -O "${ROOT_PATH}/tmp" 56 | [[ $? -eq 0 ]] && { 57 | screen_file="$(Listf "${ROOT_PATH}/tmp" '-autoseed.jpg')" 58 | [[ "$(count "${ROOT_PATH}/tmp/"*-autoseed.jpg)" -gt 1 ]] && \ 59 | debug_func "info-mtn-生成了多张!!但是只会使用一张" 60 | screen_file="${screen_file/$'\n'*}" # 取第一张 61 | # 文件名包含特殊字符 62 | [[ $screen_file =~ ^[-/0-9a-zA-Z\._]+$ ]] || { 63 | local screen_file_old="$screen_file" # 临时旧文件名 64 | screen_file="${ROOT_PATH}/tmp/autoseed-$(date '+%s%N').jpg" 65 | \mv -f "$screen_file_old" "$screen_file"; } 66 | } || { debug_func "info:mtn-have-failed!!!"; } 67 | } 68 | #-------------------------------------# 69 | # 读取主文件以获得info,提前生成简介将失效 70 | generate_info_local() { 71 | local main_file_dir _file_l max_size_file info_gen_desc info_gen_html 72 | local _ext_desc _ext_html 73 | # ; } || { , the semicolon is essential! 74 | [[ $No_Headers != yes ]] && { 75 | _ext_desc="[b]以下是[url=https://github.com/rachpt/AutoSeed] [img]\ 76 | https://s2.ax1x.com/2019/05/04/Ea3qbQ.png[/img] [/url]自动完成的截图,不喜勿看。[/b]" 77 | _ext_html="

    以下是 \"AutoSeed\" \ 81 | 自动完成的截图,不喜勿看。
    "; } || { 82 | _ext_desc="[b]以下是 [img]\ 83 | https://s2.ax1x.com/2019/05/04/Ea3qbQ.png[/img] 自动完成的截图,不喜勿看。[/b]" 84 | _ext_html="

    以下是 \"AutoSeed\" 自动完成的截图,不喜勿看。
    "; } 87 | 88 | # 种子文件绝对路径 89 | main_file_dir="${one_TR_Dir}/${one_TR_Name}" 90 | debug_func "info:folder-dir[$main_file_dir]" #----debug--- 91 | #---使用 mediainfo 生成种子中体积最大文件的 iNFO---# 92 | _file_l="$(find "$main_file_dir" -type f -exec stat -c "%Y-%s %n" {} \;)" 93 | # 43200s 12小时,在修改时间12小时中找体积最大的文件 94 | max_size_file="$(echo "$_file_l"|awk -F - -v t=`date +%s` '{if ($1>(t-43200)) print}' \ 95 | |sed -E 's/^[0-9]+-//'|sort -nr|sed -E 's/^[0-9 ]+//;q')" 96 | # 如果没有符合要求的文件,则选一个体积最大的文件 97 | [[ "$max_size_file" ]] || \ 98 | max_size_file="$(echo "$_file_l"|sed -E 's/^[0-9]+-//'|sort -nr|sed -E 's/^[0-9 ]+//;q')" 99 | debug_func "info:max-file-path[$max_size_file]" #----debug--- 100 | #---本地简介大小为零,-s 大小不为零,! 取反---# 101 | if [[ ! -s "$source_desc" ]]; then 102 | info_gen_desc="$($mediainfo "$max_size_file"|sed "s%${one_TR_Dir}/%%"|sed \ 103 | '/Unique/d;/Encoding settings/d;/Writing library/d;/Writing application/d')" 104 | [[ $enable_byrbt == yes ]] && \ 105 | info_gen_html="$($mediainfo --Output=HTML "$max_size_file"|sed \ 106 | "s%${one_TR_Dir}/%%"|sed '/html>/d;/body>/d;/head>/d;/!g')" 111 | fi 112 | # 缩略图 113 | unset img_url_com img_url_byr screen_file # clean 114 | local screen_file 115 | if command -v $mtn &> /dev/null; then 116 | gen_thumbnail_with_mtn # 使用 mtn 生成缩略图 117 | fi 118 | [[ -s "$screen_file" ]] || gen_thumbnail_with_ffmpeg # 使用 ffmpeg 生成缩略图 119 | # 图片上传 img_url_com img_url_byr 120 | [[ -s "$screen_file" ]] && { 121 | upload_image_com "$screen_file" # static.sh 122 | [[ $enable_byrbt == yes ]] && upload_image_byrbt "$screen_file" 123 | # delete image if upload successed 124 | [[ "$img_url_com" || "$img_url_byr" ]] && \rm -f "$screen_file" 125 | } || debug_func "info:生成缩略图失败!!!" #----debug--- 126 | 127 | # 存档 128 | [[ "$img_url_com" ]] && \ 129 | printf '%s\n\n%s\n%s\n%s\n' "${info_gen_desc}" "${_ext_desc}" \ 130 | "${max_size_file##*/}" "[img]$img_url_com[/img]" > "$source_desc" 131 | # byrbt desc to html 132 | [[ $enable_byrbt == yes ]] && { \ 133 | [[ "$info_gen_html" ]] && { 134 | printf '%s\n\n%s\n%s\n%s\n' "${info_gen_html}" "${_ext_html}" \ 135 | "
    ${max_size_file##*/}
    " \ 136 | "
    " > "$source_html" 137 | } || { printf '%s\n' "$info_gen_html" > "$source_html"; }; } 138 | unset img_url_com img_url_byr screen_file # clean 139 | } 140 | 141 | #---------------main------------------# 142 | # 首先判断是否有 nfo 文件,以及nfo是否下载完成 143 | read_info_file() { 144 | [[ "$org_tr_name" == "$tr_name_hand" ]] && one_TR_Dir="$tr_path_hand" 145 | debug_func "info:one_TR_Dir.0[$one_TR_Dir]" #----debug--- 146 | if [[ ! "$one_TR_Dir" ]]; then 147 | one_TR_Dir="$(find "$default_FILE_PATH" -name \ 148 | "$one_TR_Name" 2> /dev/null|head -1)" 149 | one_TR_Dir="${one_TR_Dir%/*}" 150 | debug_func "info:one_TR_Dir.1[$one_TR_Dir]" #----debug--- 151 | fi 152 | 153 | if [[ "$one_TR_Dir" ]]; then 154 | local nfo_count 155 | [[ $one_TR_Dir =~ .*/$ ]] && one_TR_Dir=${one_TR_Dir%/} # move slash end 156 | nfo_count=$("$tr_show" "$torrent_Path"|grep -Eic '\.nfo \([0-9\. ]+[kb]+\)') 157 | if [[ $nfo_count -eq 1 ]]; then 158 | local nfo_file_size nfo_file_path nfo_file_downloaded 159 | nfo_file_size=$("$tr_show" "$torrent_Path"| \ 160 | grep -Eio '\.nfo \([0-9\. ]+[kb]+\)'|grep -Eo '[0-9]+\.?[0-9]*') 161 | if [[ $nfo_file_size ]]; then 162 | nfo_file_path="$(find "${one_TR_Dir}/${one_TR_Name}" -iname '*.nfo'|head -1)" 163 | nfo_file_downloaded=$(stat --format=%s "$nfo_file_path") 164 | if [[ $nfo_file_downloaded ]]; then 165 | local judge_download_nfo judge_nfo_file charset 166 | judge_download_nfo=$((nfo_file_downloaded/100)) # $(())中变量可以不要$ 167 | judge_nfo_file=$(bc <<< "$nfo_file_size * 10"|awk -F '.' '{print $1}') 168 | [[ "$judge_download_nfo" -eq "$judge_nfo_file" ]] && { 169 | charset="$(file -i "$nfo_file_path"|sed 's/.*charset=//')" 170 | [[ $charset ]] || charset='iso-8859-1' 171 | [[ $charset == 'binary' ]] && charset='IBM866' 172 | iconv -f "$charset" -t UTF-8 -c "$nfo_file_path" > "$source_desc" 173 | debug_func 'info:[one nfo file]use-nfo-file'; } #----debug--- 174 | fi 175 | else 176 | # 有一个nfo并且nfo未下载完成,使用主文件生成nfo信息 177 | debug_func 'info:[one nfo file]use-main-file-gen!' #----debug--- 178 | # gen from main file and gen screens 179 | [[ $only_tlfbits = 'yes' ]] || generate_info_local 180 | fi 181 | elif [[ $nfo_count -ge 2 ]]; then 182 | # 对于有多个nfo的种子,使用文件列表代替 nfo 183 | "$tr_show" "$torrent_Path"|sed '1,/FILES/d;/^ *$/d;\#https?://#d' > "$source_desc" 184 | debug_func 'info:[mult nfo file]use-file-lists' #----debug--- 185 | else 186 | # 对于没有 nfo 文件的种子 187 | # gen from main file and gen screens 188 | debug_func 'info:[no nfo file]use-main-file-gen' #----debug--- 189 | [[ $only_tlfbits = 'yes' ]] || generate_info_local 190 | fi 191 | fi 192 | debug_func 'info:exit' #----debug--- 193 | } 194 | 195 | #-------------------------------------# 196 | 197 | -------------------------------------------------------------------------------- /get_desc/match.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/match.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-07-22 7 | # 8 | #-------------------------------------# 9 | # 本文件匹配指定文件中的imdb或者豆瓣链接,用于生成简介以及post, 10 | # 支持中文名、英文名,和 # 号注释, 11 | # 调用第一个参数,$dot_name 或者 $org_tr_name, 12 | # 调用第二个参数,series 或则 无, 13 | # series 匹配文件路径 $ROOT_PATH/tmp/series-imdb.txt, 14 | # 其他 匹配文件路径 $ROOT_PATH/tmp/match-lists.txt。 15 | #-------------------------------------# 16 | 17 | # 匹配已知英文名,指定豆瓣或者imdb链接,用于剧集以及动漫 18 | match_douban_imdb() { 19 | local match_list _d i j _name _one_name _url 20 | if [[ $2 = series ]]; then 21 | match_list="$ROOT_PATH/tmp/series-imdb.txt" 22 | else 23 | match_list="$ROOT_PATH/tmp/match-lists.txt" 24 | fi 25 | # 过滤后的数据 26 | _d="$(sed -E 's/[##].*//g;s/[  ]+//g;/^$/d;s/[A-Z]/\l&/g' "$match_list")" 27 | if [[ -f $match_list && $(echo "$_d"|wc -l) -ge 2 ]]; then 28 | for ((i=1;i<=$(echo "$_d"|wc -l);i+=2)); do 29 | let j=i+1 30 | _name="$(echo "$1"|sed 'y/。,?;:‘“、()`~!@#%*ABCDEFGHIJKLMNOPQRSTUVWXYZ/.,?;:\"\",()`~!@#%*abcdefghijklmnopqrstuvwxyz/')" 31 | _name="$(echo "$_name"|sed 's/[\.  ]//g;s/[A-Z]/\l&/g')" 32 | _one_name="$(echo "$_d"|sed -n "${i}{s/[\.  ]//g;p;q}")" 33 | _one_name="$(echo "$_one_name"|sed 'y/。,?;:‘“、()`~!@#%*ABCDEFGHIJKLMNOPQRSTUVWXYZ/.,?;:\"\",()`~!@#%*abcdefghijklmnopqrstuvwxyz/')" 34 | [[ $_name =~ .*$_one_name.* ]] && { 35 | _url="$(echo "$_d"|sed -n "${j}{p;q}")" 36 | _url="$(echo "$_url"|sed 's![^\.a-z0-9/:]!!g')" # 清洗 37 | debug_func "match:get-url[$_url]" #----debug--- 38 | [[ $_url =~ .*imdb.*tt.* ]] && \ 39 | imdb_url="$(echo "$_url"|grep -E 'tt[0-9]{7,8}')" && break 40 | [[ $_url =~ .*douban.* ]] && douban_url="$(echo "$_url"| \ 41 | grep -Eo '(https?://)?(movie\.)?douban\.com/subject/[0-9]{7,8}')" && \ 42 | douban_url="https://movie.douban.com/subject/${douban_url##*/}" && break 43 | } 44 | done 45 | else 46 | debug_func 'match:no-match-lists-file!' #----debug--- 47 | fi 48 | } 49 | 50 | #-------------------------------------# 51 | # 使用预先编辑好的豆瓣简介信息, 52 | # 在 tmp/db 目录下使用 种子英文名+txt后缀命名, 53 | # 使用 .[dot] 分割。样例见 sample.txt 54 | #-------------------------------------# 55 | match_douban_desc() { 56 | local m_dir i db_name 57 | m_dir="$ROOT_PATH/tmp/db" 58 | for i in `cd "$m_dir" 2>/dev/null && \ls -1`; do 59 | if [[ $dot_name =~ ${i%.txt}.* ]]; then 60 | \cp -f "${m_dir%/}/$i" "$source_desc" 61 | # html 格式 62 | [[ $enable_byrbt = yes ]] && { 63 | sed "s%\[img\] *%%g;s%\$%&
    %g;/&[_a-z]*&/d" "$source_desc" > "$source_html" 64 | printf '\n%s\n' "
    转载来源 65 | 本种来自: ${source_site_URL}

    " >> "$source_html" 66 | } 67 | printf '\n%s\n' "[quote=转载来源][b]本种来自:[/b] ${source_site_URL}[/quote]" >> "$source_desc" 68 | # 副标题额外信息 69 | [[ $extra_subt ]] && { 70 | db_name="$(grep '&shc_name_douban&' "$source_desc")" 71 | db_name="${db_name//&shc_name_douban&/}" 72 | extra_subt="$(echo "${extra_subt/$db_name/}"|sed -E \ 73 | "s%^[ /]+%%;s/ +/ /g;s/"//g;s/\[ *\]//g")" 74 | sed -i "1c &extra_comment&${extra_subt}" "$source_desc" 75 | } 76 | unset source_t_id extra_subt source_site_URL s_site_uid 77 | unset imdb_url douban_url 78 | unset source_desc_tmp source_html_tmp 79 | unset chs_name_douban eng_name_douban douban_poster_url 80 | debug_func 'match:use-info-existed!' #----debug--- 81 | break; 82 | fi 83 | done 84 | } 85 | 86 | -------------------------------------------------------------------------------- /get_desc/screens.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: get_desc/screens.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-02-28 7 | # 8 | #-------------------------------------# 9 | # 本文件用于处理原种中所有screen图片问题 10 | #-------------------------------------# 11 | # 包括 bytbt 以及 tjupt 12 | #-------------------------------------# 13 | delete_screenshots_img() { 14 | debug_func 'screens:delete-screenshots' #----debug--- 15 | local desc_delete_screens="$1" 16 | sed -i '/\[url=http.*\]\[img\]http.*\[\/img\]\[\/url\]/d' "$desc_delete_screens" 17 | # hdsky tjupt 18 | sed -i '/20141003100205b81803ac0903724ad88de90649c5a36e\.jpg/d' "$desc_delete_screens" 19 | sed -i '/http:\/\/www.stonestudio2015.com/d' "$desc_delete_screens" 20 | sed -i "/.*<\/a>/d" "$desc_delete_screens" # small img 21 | sed -i "/截图赏析/d; /alt=\"screens.jpg\"/d; /www.stonestudio2015.com\/stonestudio\/created.png/d; /hds_logo.png/d" "$desc_delete_screens" # hds 22 | sed -i "/.More.Screens/d;/.Comparisons/d;/Source.*WiKi/d;/WiKi.*Source/d" "$desc_delete_screens" # ttg 23 | 24 | sed -i "/[Hh][Dd][Cc]hina.*vs.*[Ss]ource/d;/[Ss]ource.*vs.*[Hh][Dd][Cc]hina/d" "$desc_delete_screens" # hdc 25 | #---imdb and douban 26 | sed -Ei "s!(http://www.imdb.com/title/tt[0-9]{7,8}/)!\1!g" "$desc_delete_screens" 27 | sed -i "s!\(http[s]*://movie.douban.com/subject/.*\)!\1!g" "$desc_delete_screens" 28 | sed -i "s!\(http://www.imdb.com/title/tt[0-9]\{7\}6386132[/]\)!\1!g" "$desc_delete_screens" 29 | sed -i "s!\(http[s]*://movie.douban.com/subject/.*\)!\1!g" "$desc_delete_screens" 30 | } 31 | 32 | #-------------------------------------# 33 | deal_with_images() { 34 | debug_func 'screens:in' #----debug--- 35 | # delete small images 36 | [[ $enable_byrbt = yes && $just_poster_byrbt = yes ]] && \ 37 | delete_screenshots_img "$source_html" 38 | # tjupt 39 | if [ "$enable_tjupt" = 'yes' ]; then 40 | \cp -f "$source_desc" "$source_desc2tjupt" 41 | [ "$just_poster_tjupt" = "yes" ] && delete_screenshots_img "$source_desc2tjupt" 42 | fi 43 | 44 | # 遍历 html 简介中的非法图片 45 | local img_url img_url_d img_file img_url_byr img_url_com _ext 46 | local _counter=0 47 | while true; do 48 | if [ "$enable_byrbt" = 'yes' ]; then 49 | # 获取不包含 byrbt 域名的图片链接 50 | img_url="$(grep -Eo "src=[\"\']http[^\'\"]+" "$source_html"| \ 51 | sed "/bt\.byr\.cn/d"|head -1|sed "s/src=[\"\']//g")" 52 | debug_func "screens:desc-url-byr[$img_url]" #----debug--- 53 | #elif [ "$enable_tjupt" = 'yes' ]; then 54 | #img_url="$(grep -Eio "[img]http.*[/img]" "$source_desc2tjupt"| \ 55 | #sed "/i\.loli\.net/d"|head -1|sed -E "s!\[/?img\]!!ig")" 56 | #debug_func "screens:desc-url-tju[$img_url]" #----debug--- 57 | fi 58 | # ttg img use https url 59 | [[ $img_url =~ .*tu\.totheglory\.im.* ]] && \ 60 | img_url_d="${img_url/http:/https:/}" || img_url_d="$img_url" 61 | debug_func "screens-loop[$_counter]" #----debug--- 62 | # 跳出循环条件 63 | if [ ! "$img_url" ]; then 64 | debug_func 'screens-out:no-img' #----debug--- 65 | break # jump out 66 | elif [ $_counter -gt 24 ]; then 67 | debug_func 'screens-out:>24' #----debug--- 68 | break # jump out 69 | fi 70 | # 临时图片路径,使用时间作为文件名的一部分 71 | _ext="${img_url//"${img_url%.*}"}" 72 | img_file="${ROOT_PATH}/tmp/autoseed-pic-$(date '+%s%N')${_ext%%[%&=@]*}" 73 | http --verify=no --timeout=25 --ignore-stdin -o "$img_file" -d "$img_url_d" "$user_agent" 74 | [[ ! -s $img_file ]] && { 75 | curl -k -o "$img_file" "$img_url_d" 76 | debug_func 'screens_img:use-curl-download'; } 77 | [[ -s $img_file ]] && debug_func 'screens_img:downloaded' || \ 78 | debug_func 'screens_img:failed-to-dl' #----debug--- 79 | 80 | # byrbt image 81 | [[ $enable_byrbt = yes ]] && upload_image_byrbt "$img_file" && \ 82 | [[ $img_url_byr ]] && sed -i "s!$img_url!$img_url_byr!g" "$source_html" && \ 83 | debug_func "screens-byr[$img_url_byr]" 84 | # tjupt image 85 | [[ $enable_tjupt = yes ]] && [[ ! "$img_url" =~ *i.loli.net* ]] && \ 86 | upload_image_com "$img_file" && [[ $img_url_com ]] && \ 87 | sed -i "s!$img_url!$img_url_com!g" "$source_desc2tjupt" && \ 88 | debug_func "screens-byr[$img_url_com]" 89 | 90 | [[ $enable_byrbt = yes && $img_url_byr ]] && \rm -f "$img_file" 91 | #[[ $enable_tjupt = yes && $img_url_com ]] && \rm -f "$img_file" 92 | unset img_url img_url_d img_file img_url_byr img_url_com 93 | ((_counter++)) # C 形式的增1 94 | done 95 | # tjupt images 96 | #[ "$enable_tjupt" = 'yes' ] && sed -i \ 97 | #'/jpg\|png\|jpeg\|gif\|webp/ {/i\.loli\.net/!d}' "$source_desc2tjupt" 98 | debug_func 'screens:exit' #----debug--- 99 | } 100 | 101 | #-------------------------------------# 102 | 103 | -------------------------------------------------------------------------------- /main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: main.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-09-02 7 | # 8 | #-----------import settings-------------# 9 | ROOT_PATH="$(dirname "$(readlink -f "$0")")" 10 | # use source command run 11 | [[ $ROOT_PATH == /*bin* ]] && \ 12 | ROOT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 13 | source "$ROOT_PATH/settings.sh" 14 | source "$ROOT_PATH/static.sh" 15 | #---------------------------------------# 16 | # import extra functions 17 | source "$ROOT_PATH/get_desc/detail_page.sh" 18 | source "$ROOT_PATH/get_desc/customize.sh" 19 | source "$ROOT_PATH/get_desc/extract.sh" 20 | source "$ROOT_PATH/get_desc/match.sh" 21 | #----------------lock func--------------# 22 | remove_lock() { 23 | \rm -f "$lock_File" "$qb_rt_queue" "$ROOT_PATH/tmp/$$.debug" 24 | } 25 | is_locked() { 26 | if [ -f "$lock_File" ]; then 27 | exit 0 28 | else 29 | set -o noclobber # 禁止重定向覆盖 30 | printf "$$" > "$lock_File" # pid 写入文件 31 | set +o noclobber # 允许重定向覆盖 32 | trap remove_lock INT TERM EXIT 33 | fi 34 | } 35 | 36 | #----------------log func---------------# 37 | write_log_begin() { 38 | printf '%s\n' "-------------[start]-------------" >> "$log_Path" 39 | printf '%s' "[$(date '+%Y-%m-%d %H:%M:%S')]" >> "$log_Path" 40 | printf '%s\n' "准备发布:[$org_tr_name]" >> "$log_Path" 41 | } 42 | write_log_end() { 43 | printf '%s\n' "+++++++++++++++++++++++++++++++++" >> "$log_Path" 44 | printf '%s' "[$(date '+%Y-%m-%d %H:%M:%S')]" >> "$log_Path" 45 | printf '%s\n' "已经处理:[$org_tr_name]" >> "$log_Path" 46 | } 47 | 48 | #--------------is-completed-------------# 49 | torrent_completed_precent() { 50 | unset completion # clean, use_qbt use_trs cannot be setted here! 51 | case "$fg_client" in 52 | qbittorrent) 53 | qb_get_torrent_completion ;; 54 | transmission) 55 | tr_get_torrent_completion ;; 56 | *) 57 | debug_func 'main:Client-Error' #----debug--- 58 | esac 59 | } 60 | 61 | #----------------desc-------------------# 62 | generate_desc_func() { 63 | #---loop for torrent in flexget path---# 64 | for tr_i in "$flexget_path"/*.torrent; do [[ -f "$tr_i" ]] && { 65 | torrent_Path="${tr_i}" 66 | [[ $only_tlfbits == 'yes' ]] || { 67 | # test rar included torrent 68 | $tr_show "$torrent_Path"|grep -A 99 FILES|grep -Eq '.*\.rar |.*\.r[0-9]+ ' 69 | [[ "$?" -eq 0 ]] && \rm -f "$torrent_Path" && break; } # delete rar torrent 70 | # org_tr_name 用于和 transmission/qb 中的种子名进行比较, 71 | org_tr_name="$(get_torrents_name "$torrent_Path")" 72 | one_TR_Name="$org_tr_name" 73 | #---generate desc before done---# 74 | if [[ ! -s "${ROOT_PATH}/tmp/${org_tr_name}_desc.txt" ]]; then 75 | unset completion 76 | [[ "$test_func_probe" || $HAND == yes ]] && completion=100 || \ 77 | torrent_completed_precent # 获取下载完成百分比 78 | [[ "$completion" && $completion -ge 50 ]] && { 79 | debug_func "mainr:completed-[$completion]" #----debug--- 80 | debug_func 'main:gen_desc[生成简介]' #----debug--- 81 | source "$ROOT_PATH/get_desc/desc.sh" ; } 82 | fi 83 | }; done 84 | unset tr_i org_tr_name one_TR_Name one_TR_Dir # clean 85 | } 86 | 87 | #-------------main loop func-------------# 88 | main_loop_func() { 89 | #---loop for torrent in flexget path ---# 90 | for tr_i in "$flexget_path"/*.torrent; do [[ -f "$tr_i" ]] && { 91 | #---------------------------------------------- 92 | org_tr_name="$(get_torrents_name "$tr_i")" 93 | 94 | debug_func 'main:m-loop' #----debug--- 95 | #----------------------------------------------- 96 | if [[ "$org_tr_name" == "$one_TR_Name" ]]; then 97 | #---.torrient file path---# 98 | torrent_Path="$tr_i" 99 | #---desc---# 100 | if [[ ! -s "${ROOT_PATH}/tmp/${org_tr_name}_desc.txt" ]]; then 101 | debug_func 'main:failed to find desc' #----debug--- 102 | break 103 | else 104 | debug_func 'main:to-post' #----debug--- 105 | write_log_begin # write log 106 | source "$ROOT_PATH/post/post.sh" 107 | write_log_end # write log 108 | # delete uploaded torrent 109 | [[ ! "$test_func_probe" ]] && { 110 | \rm -f "$torrent_Path" 111 | clean_commit_main='yes'; } 112 | fi 113 | fi 114 | }; done 115 | #---clean & remove old torrent---# 116 | if [[ "$clean_commit_main" == 'yes' ]]; then 117 | debug_func 'main:clean' #----debug--- 118 | source "$ROOT_PATH/clean/clean.sh" 119 | printf '\n' >> "$log_Path" # new line 120 | fi 121 | } 122 | 123 | #--------------timeout func--------------# 124 | time_out_func() { 125 | [[ -s "$lock_File" ]] && { 126 | local waitfor main_pid user_hz start_time sys_uptime run_time 127 | waitfor=1200 # 单位秒, 1200=20 min 128 | main_pid=$(< "$lock_File") 129 | user_hz=$(getconf CLK_TCK) #mostly it's 100 on x86/x86_64 130 | [[ $main_pid =~ [0-9]+ ]] && { 131 | start_time=$(awk '{print $22}' /proc/$main_pid/stat) 132 | sys_uptime=$(awk '{print $1}' /proc/uptime) 133 | run_time=$(( ${sys_uptime%.*} - $start_time/$user_hz )); } 134 | } 135 | if [[ $main_pid && $run_time -gt $waitfor ]]; then 136 | # 处理超时 137 | kill -9 $main_pid 138 | \rm -f "$lock_File" "$qb_rt_queue" "$ROOT_PATH/tmp/autoseed-"* 139 | debug_func "程序因超时[$run_time]被强制终止!" #----debug--- 140 | else 141 | # 重复运行 142 | debug_func '主程序正在运行,稍后重试!' #----debug--- 143 | exit 0 144 | fi 145 | } 146 | hold_on_func() { 147 | [[ $HAND != yes || ! $test_func_probe ]] && { 148 | # 依据cpu负载设置一个延时,解决系统IO问题 149 | # ${var:-default} Use new value if undefined or null. 150 | local cpu_number cpu_load _time 151 | cpu_number="$(grep 'model name' /proc/cpuinfo|wc -l)" 152 | cpu_load="$(uptime|awk -F 'average:' '{print $2}'|awk \ 153 | -F ',' '{print $1}'|sed 's/ //g')" 154 | _time="$(bc <<< ${cpu_load:-0.4}*100/${cpu_number:-1}*0.4*${Speed:-1})" 155 | sleep "${_time:-0}" # 默认值 0 秒 156 | debug_func "main:hold-on[${_time:-0}]" #----debug--- 157 | unset Speed _time 158 | } 159 | } 160 | #---------------------------------------# 161 | #-------------start function------------# 162 | # 将种子追加到发布列队 163 | if [[ "$#" -ge 2 ]]; then 164 | # manual, 2 parameters; one is file path 165 | if [[ -f "$1" ]]; then 166 | flexget_path="$ROOT_PATH/tmp" 167 | Torrent_Name="$(get_torrents_name "$1")" 168 | Tr_Path="$2" 169 | HAND='yes' 170 | \cp -f "$1" "${flexget_path%/}/handTorrent-$RANDOM.torrent" 171 | elif [[ -f "$2" ]]; then 172 | flexget_path="$ROOT_PATH/tmp" 173 | Torrent_Name="$(get_torrents_name "$2")" 174 | Tr_Path="$1" 175 | HAND='yes' 176 | \cp -f "$2" "${flexget_path%/}/handTorrent-$RANDOM.torrent" 177 | # qbittorrent, 2 parameters; one is directory 178 | elif [[ -d "$1" ]]; then 179 | Torrent_Name="$2" 180 | Tr_Path="$1" 181 | debug_func 'main:run_from_QB' 182 | elif [[ -d "$2" ]]; then 183 | Torrent_Name="$1" 184 | Tr_Path="$2" 185 | debug_func 'main:run_from_QB' 186 | fi 187 | else 188 | # no parameter 189 | [[ $TR_TORRENT_NAME ]] && { 190 | # transmission 191 | Torrent_Name="$TR_TORRENT_NAME" 192 | Tr_Path="$TR_TORRENT_DIR" 193 | debug_func 'main:run_from_TR' 194 | } || { 195 | # 提前发布 196 | [[ -f "$ROOT_PATH/enhance.sh" ]] && \ 197 | source "$ROOT_PATH/enhance.sh" 198 | } 199 | fi 200 | [[ "$Torrent_Name" && "$Tr_Path" ]] && { 201 | [[ $HAND != yes ]] && { 202 | hold_on_func # main.sh, sleep some time 203 | [[ $only_tlfbits == 'yes' ]] || { 204 | extract_rar_files # get_desc/extract.sh 205 | } 206 | } || { 207 | tr_name_hand="$Torrent_Name" 208 | tr_path_hand="$Tr_Path" 209 | } 210 | while [[ ! -e $quene_lock ]]; do 211 | printf "$$" > "$quene_lock" # quene lock 212 | printf '%s\n%s\n' "${Torrent_Name}" "${Tr_Path%/}" >> "$queue" 213 | done 214 | \rm -f "$quene_lock" 215 | } 216 | unset Torrent_Name Tr_Path 217 | #---------------------------------------# 218 | [[ "$Disable_AutoSeed" == yes ]] && exit 0 219 | #---------------------------------------# 220 | # move the end slash 221 | flexget_path=${flexget_path%/} 222 | [[ $HAND == yes ]] && { 223 | while [[ -f "$lock_File" ]]; do 224 | sleep 1 225 | done 226 | } || { 227 | # 禁止重复运行; crontab 会开两个 main.sh 进程 228 | [[ "$(ps -C 'main.sh' --no-headers|wc -l)" -gt 2 ]] && time_out_func 229 | } 230 | is_locked # 锁住进程,防止多开 231 | # 生成简介于发布循环不能异步运行,\ 232 | # 否则有可能出现 .torrent 文件被改名\ 233 | # 而出现路径错误,因此只能顺序执行 234 | generate_desc_func # 提前生成简介 235 | #-------------start check---------------# 236 | main_counter=0 237 | while [[ $main_counter -le 20 ]]; do 238 | one_TR_Name="$(head -1 "$queue")" 239 | one_TR_Dir="$(head -2 "$queue"|tail -1)" 240 | one_TR_Dir="${one_TR_Dir%/}" # no slash end 241 | [[ "$one_TR_Name" && "$one_TR_Dir" ]] || break 242 | debug_func "main:queue-loop[$main_counter]" #----debug--- 243 | 244 | if [[ $(count "$flexget_path"/*.torrent) -ne 0 ]]; then 245 | hold_on_func # dynamic delay 246 | debug_func 'main:queue-in' #----debug--- 247 | main_loop_func 248 | fi 249 | sed -i '1,2d' "$queue" # delete record 250 | ((main_counter++)) # C 形式的增1 251 | done 252 | 253 | #---------------------------------------# 254 | # qbittorrent set ratio 255 | qb_set_ratio_loop 256 | # reannounce 257 | #debug_func "end-进程[$(ps -C 'main.sh' --no-headers|wc -l)]个" #----debug--- 258 | [[ "$(ps -C 'main.sh' --no-headers|wc -l)" -le 2 ]] && { 259 | [[ $use_trs == yes ]] && tr_reannounce 260 | [[ $use_qbt == yes ]] && qb_reannounce; } 261 | #---------------------------------------# 262 | 263 | -------------------------------------------------------------------------------- /post/add.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/add.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-07-16 7 | # 8 | #---------------------------------------# 9 | # 将发布后的种子添加到客户端做种 10 | #-------------call function-------------# 11 | if [ "$one_TR_Dir" ]; then 12 | if [ "$postUrl" = "${post_site[whu]}/takeupload.php" ]; then 13 | whu_tr="${ROOT_PATH}/tmp/${t_id}.torrent" 14 | dl_whu_tr() { 15 | http --verify=no --timeout=25 --ignore-stdin -o "$whu_tr" -d \ 16 | "${downloadUrl}${t_id}" "$user_agent" "$cookie" && sleep 3 17 | [[ ! -s $whu_tr ]] && curl -b "`echo "$cookie"|sed -E 's/^Cookie:[ ]?//i'`" \ 18 | -A "`echo "$user_agent"|sed -E 's/^User-Agent:[ ]?//i'`" -k \ 19 | -o "$whu_tr" "${downloadUrl}${t_id}" && debug_func "add:whu-curl-dl" 20 | } 21 | #$tr_edit -r 'http://' 'https://' "${ROOT_PATH}/tmp/${t_id}.torrent" 22 | for ((a=1;a<5;a++)); do [[ ! -s $whu_tr ]] && dl_whu_tr || break; done 23 | debug_func "add:whu-tr-size:[`stat -c "%s" "$whu_tr"`]" #----debug--- 24 | [ ! "`stat -c "%s" "$whu_tr"`" ] && debug_func \ 25 | "add:whu-prarm:[${downloadUrl}${t_id}][$user_agent][$cookie]" #----debug--- 26 | if [ "$to_client" = 'qbittorrent' ]; then 27 | qb_add_torrent_file # transmission.sh 28 | elif [ "$to_client" = 'transmission' ]; then 29 | tr_add_torrent_file # transmission.sh 30 | else 31 | debug_func "add:Client-Error!-[whu]" #----debug--- 32 | fi 33 | [[ $test_func_probe ]] || \rm -f "$whu_tr" 34 | unset whu_tr a && unset -f dl_whu_tr 35 | else 36 | if [ "$to_client" = 'qbittorrent' ]; then 37 | qb_add_torrent_url # qbittorrent.sh 38 | elif [ "$to_client" = 'transmission' ]; then 39 | tr_add_torrent_url # qbittorrent.sh 40 | else 41 | debug_func "add:Client-Error!" #----debug--- 42 | fi 43 | fi 44 | echo "-------------[added]-------------" >> "${log_Path}-$index" 45 | # 更新豆瓣外部信息 46 | if http --verify=no --ignore-stdin --timeout=16 GET "${postUrl%/*}/retriver.php" \ 47 | id=="$t_id" type==2 siteid==2 "$cookie" "$user_agent" &> /dev/null; then 48 | debug_func 'add:更新外部信息成功!' #----debug--- 49 | else 50 | case $? in 51 | 2) debug_func 'add:Request timed out!' ;; 52 | 3) debug_func 'add:Unexpected HTTP 3xx Redirection!' ;; 53 | 4) debug_func 'add:HTTP 4xx Client Error!' ;; 54 | 5) debug_func 'add:HTTP 5xx Server Error!' ;; 55 | 6) debug_func 'add:Exceeded --max-redirects= redirects!' ;; 56 | *) debug_func 'add:Other Error!' ;; 57 | esac 58 | sleep 1 59 | # 备用更新方法 60 | curl -k -b "`echo "$cookie"|sed -E 's/^cookie:[ ]?//i'`" \ 61 | -A "`echo "$user_agent"|sed -E 's/^User-Agent:[ ]?//i'`" \ 62 | "${postUrl%/*}/retriver.php?id=$t_id&type=2&siteid=2" && \ 63 | debug_func 'add:used-curl-update' 64 | fi 65 | 66 | else 67 | echo "没有找到本地文件!" >> "${log_Path}-$index" 68 | fi 69 | #---------------------------------------# 70 | 71 | -------------------------------------------------------------------------------- /post/byrbt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/byrbt.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-01-02 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_byrbt" 10 | passkey="$passkey_byrbt" 11 | anonymous="$anonymous_byrbt" 12 | ratio_set=$ratio_byrbt 13 | to_client="$client_byrbt" 14 | #---static---# 15 | postUrl="${post_site[byrbt]}/takeupload.php" 16 | editUrl="${post_site[byrbt]}/takeedit.php" 17 | downloadUrl="${post_site[byrbt]}/download.php?id=" 18 | #-------------------------------------# 19 | # 需要的参数 20 | gen_byrbt_parameter() { 21 | 22 | if [ -s "$source_html" ]; then 23 | byrbt_des="$descrCom_complex_html 24 | $(< "$source_html")" 25 | else 26 | byrbt_des="$descrCom_complex_html 27 |


    \ 28 | 获取简介失败!!!

    " 29 | fi 30 | 31 | # 判断类型,纪录片、电影、剧集 32 | if [ "$documentary" = 'yes' ]; then 33 | byrbt_type='410' 34 | byrbt_second_type='10' 35 | # 是否完结 36 | if [[ $is_package == yes ]]; then 37 | byrbt_rend='合集' 38 | elif [[ $season =~ .*[eE].* ]]; then 39 | byrbt_rend='连载' 40 | else 41 | byrbt_rend='单集' 42 | fi 43 | # 季度信息 44 | byrbt_season="$season" 45 | # 分辨率 46 | if [[ $is_1080p == yes ]]; then 47 | byrbt_filetype='1080p' 48 | elif [[ $is_1080i == yes ]]; then 49 | byrbt_filetype='1080i' 50 | elif [[ $is_720p == yes ]]; then 51 | byrbt_filetype='720p' 52 | else 53 | byrbt_filetype='其他' 54 | fi 55 | # 片源 56 | if [[ $is_bd == yes ]]; then 57 | byrbt_source='Blu-ray' 58 | elif [[ $is_hdtv == yes ]]; then 59 | byrbt_source='TV' 60 | elif [[ $is_webdl == yes ]]; then 61 | byrbt_source='Web-DL' 62 | else 63 | byrbt_source='' 64 | fi 65 | # 格式 66 | byrbt_format="$file_type" 67 | # 英文名 68 | [[ $(echo $foreign_title|grep -Ei '[a-z]+') ]] && \ 69 | byrbt_engname="$foreign_title" || \ 70 | byrbt_engname="$(echo "$noDot_name"|sed -E \ 71 | 's/(720|1080)[pi].*//i;s/(blu-?ray|hdtv|web-?dl).*//i;s/ [0-9]{4} $//;s/ +$//')" 72 | # 制作小组,取英文名-后面部分 73 | byrbt_group="$(echo "$dot_name"|sed -E 's/.*-([a-z0-9]+$)/\1/i')" 74 | elif [ "$serials" = 'yes' ]; then 75 | # 剧集 76 | byrbt_type='401' 77 | # 二级分类 78 | case "$region" in 79 | *中国大陆*) 80 | byrbt_tv_type='大陆' 81 | byrbt_second_type='15' ;; 82 | *香港*|*台湾*|*澳门*) 83 | byrbt_tv_type='港台' 84 | byrbt_second_type='18' ;; 85 | *日本*|*韩国*) 86 | byrbt_tv_type='日韩' 87 | byrbt_second_type='16' ;; 88 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*) 89 | byrbt_tv_type='欧美' 90 | byrbt_second_type='17' ;; 91 | *) 92 | byrbt_tv_type='其他' 93 | byrbt_second_type='2' ;; 94 | esac 95 | byrbt_tv_season="$season" 96 | byrbt_tv_filetype="$file_type" 97 | else 98 | # 默认电影类 99 | byrbt_type='408' 100 | # 二级分类 101 | case "$region" in 102 | *中国大陆*|*香港*|*台湾*|*澳门*) 103 | byrbt_second_type='11' ;; 104 | *日本*|*韩国*|*印度*|*新加坡*|*泰国*|*菲律宾*) 105 | byrbt_second_type='14' ;; 106 | *英国*|*德国*|*法国*|*俄罗斯*|*西班牙*|*澳大利亚*) 107 | byrbt_second_type='12' ;; 108 | *美国*|*墨西哥*|*加拿大*) 109 | byrbt_second_type='13' ;; 110 | *) 111 | byrbt_second_type='1' ;; 112 | esac 113 | fi 114 | } 115 | #-------------------------------------# 116 | # type -> 类型(*),second_type -> 二级分类 117 | # file -> 种子文件(*),[tv_type -> 剧集类型],movie_cname -> 中文名 118 | # [ename0day -> 英文名|tv_ename ->剧集],movie_type -> 电影类别(喜剧/动作/爱情) 119 | # movie_country -> 国家地区,small_descr -> 副标题 120 | # url -> imdb链接,dburl -> 豆瓣链接,bgmtv_url -> 番组计划链接 121 | # nfo -> nfo 文件,descr -> 简介(*),uplver -> 匿名发布('yes') 122 | 123 | # tv_season -> 剧集季度,tv_filetype -> 剧集文件格式['MKV,MP4...'] 124 | 125 | #-------------------------------------# 126 | # 408 电影 127 | # 401 剧集 128 | # 404 动漫 129 | # 402 音乐 130 | # 405 综艺 131 | # 403 游戏 132 | # 406 软件 133 | # 407 资料 134 | # 409 体育 135 | # 410 纪录 136 | 137 | #---电影二级分类---# 138 | # 11 华语 139 | # 12 欧洲 140 | # 13 北美 141 | # 14 亚洲 142 | # 1 其他 143 | 144 | #---剧集二级分类---# 145 | # 15 大陆 146 | # 16 日韩 147 | # 17 欧美 148 | # 18 港台 149 | # 2 其他 150 | #-------------------------------------# 151 | byrbt_post_func() { 152 | gen_byrbt_parameter 153 | if [[ "$byrbt_type" == '408' ]]; then 154 | # 电影 POST 155 | t_id="$(http --verify=no --ignore-stdin -f --print=h --timeout=10 POST "$postUrl"\ 156 | 'movie_cname'="$chinese_title"\ 157 | 'ename0day'="$dot_name"\ 158 | 'type'="$byrbt_type"\ 159 | 'small_descr'="$chs_included"\ 160 | 'url'="$imdb_url"\ 161 | 'dburl'="$( [ ! "$imdb_url" ] && echo "$douban_url" || echo 'none')"\ 162 | 'descr'="$byrbt_des"\ 163 | 'type'="$byrbt_type"\ 164 | 'second_type'="$byrbt_second_type"\ 165 | 'movie_type'="$genre"\ 166 | 'movie_country'="$region"\ 167 | 'uplver'="$anonymous_byrbt"\ 168 | file@"${torrent_Path}"\ 169 | "$cookie_byrbt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 170 | 171 | if [[ -z "$t_id" ]]; then 172 | # 辅种 173 | reseed_torrent 174 | fi 175 | elif [[ "$byrbt_type" == '401' ]]; then 176 | # 剧集 POST 177 | t_id="$(http --verify=no --ignore-stdin -f --print=h --timeout=10 POST "$postUrl"\ 178 | 'type'="$byrbt_type"\ 179 | 'second_type'="$byrbt_second_type"\ 180 | 'tv_type'="$byrbt_tv_type"\ 181 | 'cname'="$chinese_title"\ 182 | 'tv_ename'="$dot_name"\ 183 | 'tv_season'="$byrbt_tv_season"\ 184 | 'tv_filetype'="$byrbt_tv_filetype"\ 185 | 'type'="$byrbt_type"\ 186 | 'small_descr'="$chs_included"\ 187 | 'url'="$imdb_url"\ 188 | 'dburl'="$( [ ! "$imdb_url" ] && echo "$douban_url" || echo 'none')"\ 189 | 'descr'="$byrbt_des"\ 190 | 'movie_type'="$genre"\ 191 | 'uplver'="$anonymous_byrbt"\ 192 | file@"${torrent_Path}"\ 193 | "$cookie_byrbt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 194 | if [[ -z "$t_id" ]]; then 195 | # 辅种 196 | reseed_torrent 197 | fi 198 | elif [[ "$byrbt_type" == '410' ]]; then 199 | # 纪录片 POST 200 | t_id="$(http --verify=no --ignore-stdin -f --print=h --timeout=10 POST "$postUrl"\ 201 | 'type'="$byrbt_type"\ 202 | 'second_type'="$byrbt_second_type"\ 203 | 'record_whetherend'="$byrbt_rend"\ 204 | 'cname'="$chinese_title"\ 205 | 'record_ename'="$byrbt_engname"\ 206 | 'record_season'="$byrbt_season"\ 207 | 'record_filetype'="$byrbt_filetype"\ 208 | 'record_source'="$byrbt_source"\ 209 | 'record_format'="$byrbt_format"\ 210 | 'record_group'="$byrbt_group"\ 211 | 'type'="$byrbt_type"\ 212 | 'small_descr'="$chs_included"\ 213 | 'url'="$imdb_url"\ 214 | 'dburl'="$( [ ! "$imdb_url" ] && echo "$douban_url" || echo 'none')"\ 215 | 'descr'="$byrbt_des"\ 216 | 'uplver'="$anonymous_byrbt"\ 217 | file@"${torrent_Path}"\ 218 | "$cookie_byrbt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 219 | 220 | if [[ -z "$t_id" ]]; then 221 | # 辅种 222 | reseed_torrent 223 | fi 224 | else 225 | # 其他 POST 226 | : 227 | fi 228 | } 229 | 230 | #-------------------------------------# 231 | 232 | -------------------------------------------------------------------------------- /post/cmct.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/cmct.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2018-12-08 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_cmct" 10 | passkey="$passkey_cmct" 11 | anonymous="$anonymous_cmct" 12 | ratio_set=$ratio_cmct 13 | to_client="$client_cmct" 14 | #---static---# 15 | postUrl="${post_site[cmct]}/takeupload.php" 16 | editUrl="${post_site[cmct]}/takeedit.php" 17 | downloadUrl="${post_site[cmct]}/download.php?id=" 18 | #-------------------------------------# 19 | gen_cmct_parameter() { 20 | 21 | if [ -s "$source_desc" ]; then 22 | cmct_des="${descrCom_simple//&ratio_in_desc&/$ratio_cmct} 23 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 24 | else 25 | cmct_des="${descrCom_simple//&ratio_in_desc&/$ratio_cmct} 26 | $failed_to_get_des" 27 | fi 28 | 29 | #-------------------------------------# 30 | # 判断类型,纪录片、电影、剧集 31 | if [ "$documentary" = 'yes' ]; then 32 | cmct_type='503' 33 | else 34 | if [ "$serials" = 'yes' ]; then 35 | # 剧集分类 36 | cmct_type='502' 37 | else 38 | # 电影类别 39 | cmct_type='501' 40 | fi 41 | fi 42 | #-------------------------------------# 43 | # 封装格式 44 | if [ "$file_type" = 'MKV']; then 45 | cmct_medium=6 46 | elif [ "$file_type" = 'MP4']; then 47 | cmct_medium=7 48 | elif [ "$file_type" = 'TS']; then 49 | [ "$is_bd" ] && cmct_medium=4 50 | [ "$is_hdtv" ] && cmct_medium=5 51 | else 52 | cmct_medium=0 53 | fi 54 | # 视频编码 55 | if [ "$is_264" = 'yes' ]; then 56 | cmct_codec=2 57 | elif [ "$is_265" = 'yes' ]; then 58 | cmct_codec=1 59 | else 60 | cmct_codec=0 61 | fi 62 | 63 | # 音频编码 64 | if [ "$is_dts" = 'yes' ]; then 65 | cmct_audio=3 66 | elif [ "$is_ac3" = 'yes' ]; then 67 | cmct_audio=4 68 | elif [ "$is_aac" = 'yes' ]; then 69 | cmct_audio=5 70 | elif [ "$is_flac" = 'yes' ]; then 71 | cmct_audio=7 72 | else 73 | cmct_audio=0 74 | fi 75 | 76 | # 分辨率 77 | if [ "$is_4k" = 'yes' ]; then 78 | cmct_standard='1' 79 | elif [ "$is_1080p" = 'yes' ]; then 80 | cmct_standard='2' 81 | elif [ "$is_1080i" = 'yes' ]; then 82 | cmct_standard='3' 83 | elif [ "$is_720p" = 'yes' ]; then 84 | cmct_standard='4' 85 | else 86 | cmct_standard='0' 87 | fi 88 | 89 | # 地区 90 | case "$region" in 91 | *中国大陆*) 92 | cmct_source='1' ;; 93 | *香港*|*台湾*|*澳门*) 94 | cmct_source='2' ;; 95 | *日本*|*韩国*) 96 | cmct_source='10' ;; 97 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*) 98 | cmct_source='9' ;; 99 | *) 100 | cmct_source='3' ;; 101 | esac 102 | 103 | cmct_small_descr="$chinese_title $chs_included" 104 | } 105 | #-------------------------------------# 106 | 107 | #---类型---# 108 | # 0 请选择 109 | # 501 Movies(电影) 110 | # 502 TV Series(剧集) 111 | # 503 Docs(纪录) 112 | # 504 Animations(动画) 113 | # 505 TV Shows(综艺) 114 | # 506 Sports(体育) 115 | # 507 MV(音乐视频) 116 | # 508 Music(音乐) 117 | # 509 Others(其他) 118 | # 119 | #---格式---# 120 | # 0 请选择 121 | # 1 Blu-ray(原盘) 122 | # 2 MiniBD 123 | # 3 DVD(原盘) 124 | # 4 TS/REMUX 125 | # 5 TS/HDTV 126 | # 6 Matroska 127 | # 7 MP4 128 | # 129 | #---视频---# 130 | # 0 请选择 131 | # 1 HEVC 132 | # 2 H.264 133 | # 3 VC-1 134 | # 4 MPEG-2 135 | # 136 | #---音频---# 137 | # 0 请选择 138 | # 1 DTS-HD 139 | # 2 TrueHD 140 | # 6 LPCM 141 | # 3 DTS 142 | # 4 AC-3 143 | # 5 AAC 144 | # 7 FLAC 145 | # 8 APE 146 | # 9 WAV 147 | # 148 | #---分辨率---# 149 | # 0 请选择 150 | # 1 UHD 151 | # 2 1080p 152 | # 3 1080i 153 | # 4 720p 154 | # 5 SD 155 | # 156 | #---地区---# 157 | # 0 请选择 158 | # 1 China(大陆) 159 | # 2 HK&TW(港台) 160 | # 9 EU&US(欧美) 161 | # 10 JP&KR(日韩) 162 | # 3 Other(其他) 163 | # 164 | # pack="yes" 合集 165 | 166 | #-------------------------------------# 167 | cmct_post_func() { 168 | gen_cmct_parameter 169 | #---post data---# 170 | id="$(http --verify=no --ignore-stdin -f --print=h POST "$postUrl"\ 171 | 'name'="$dot_name"\ 172 | 'small_descr'="$cmct_small_descr"\ 173 | 'url'="$imdb_url"\ 174 | 'descr'="$cmct_des"\ 175 | 'type'="$cmct_type"\ 176 | 'medium_sel'="$cmct_medium"\ 177 | 'codec_sel'="$cmct_codec"\ 178 | 'audiocodec_sel'="$cmct_audio"\ 179 | 'standard_sel'="$cmct_standard"\ 180 | 'source_sel'="$cmct_source"\ 181 | 'pack'="$is_package"\ 182 | 'uplver'="$anonymous_cmct"\ 183 | file@"${torrent_Path}"\ 184 | "$cookie_cmct"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 185 | 186 | if [[ -z "$t_id" ]]; then 187 | # 辅种 188 | reseed_torrent 189 | fi 190 | } 191 | 192 | #-------------------------------------# 193 | -------------------------------------------------------------------------------- /post/hudbt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/hudbt.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-02-21 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_hudbt" 10 | passkey="$passkey_hudbt" 11 | anonymous="$anonymous_hudbt" 12 | ratio_set=$ratio_hudbt 13 | to_client="$client_hudbt" 14 | #---static---# 15 | postUrl="${post_site[hudbt]}/takeupload.php" 16 | editUrl="${post_site[hudbt]}/takeedit.php" 17 | downloadUrl="${post_site[hudbt]}/download.php?id=" 18 | #-------------------------------------# 19 | gen_hudbt_parameter() { 20 | 21 | if [ -s "$source_desc" ]; then 22 | hudbt_des="${descrCom_complex//&ratio_in_desc&/$ratio_hudbt} 23 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d;s/ / /g' "$source_desc")" 24 | else 25 | hudbt_des="${descrCom_complex//&ratio_in_desc&/$ratio_hudbt} 26 | $failed_to_get_des" 27 | fi 28 | 29 | #-------------------------------------# 30 | # 判断类型,纪录片、电影、剧集、动漫 31 | if [[ $documentary = yes ]]; then 32 | hudbt_type='404' 33 | elif [[ $theater = yes ]]; then 34 | # 动漫 剧场版 35 | hudbt_type='428' #剧场版 36 | elif [[ $is_ipad = yes ]]; then 37 | # 移动视频 38 | hudbt_type='430' 39 | elif [[ $serials = yes ]]; then 40 | # 剧集分类 41 | case "$region" in 42 | *中国大陆*) 43 | hudbt_type='402' ;; 44 | *香港*|*台湾*|*澳门*) 45 | hudbt_type='417' ;; 46 | *日本*|*韩国*|*印度*|*新加坡*|*泰国*|*菲律宾*) 47 | hudbt_type='416' ;; 48 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*|*瑞典*|*芬兰*|*爱尔兰*|*阿联酋*|*土耳其*|*意大利*) 49 | hudbt_type='418' ;; 50 | *) 51 | hudbt_type='409' ;; 52 | esac 53 | [[ $animation = yes ]] && hudbt_type='427' #连载动画 54 | else 55 | # 电影类别 56 | case "$region" in 57 | *中国大陆*) 58 | hudbt_type='401' ;; 59 | *香港*|*台湾*|*澳门*) 60 | hudbt_type='413' ;; 61 | *日本*|*韩国*|*印度*|*新加坡*|*泰国*|*菲律宾*) 62 | hudbt_type='414' ;; 63 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*|*瑞典*|*芬兰*|*爱尔兰*|*阿联酋*|*土耳其*|*意大利*) 64 | hudbt_type='415' ;; 65 | *) 66 | hudbt_type='409' ;; 67 | esac 68 | fi 69 | 70 | #-------------------------------------# 71 | # 设置分辨率 72 | if [ "$is_4k" = 'yes' ]; then 73 | hudbt_stardand='0' 74 | elif [ "$is_1080p" = 'yes' ]; then 75 | hudbt_stardand='1' 76 | elif [ "$is_1080i" = 'yes' ]; then 77 | hudbt_stardand='2' 78 | elif [ "$is_720p" = 'yes' ]; then 79 | hudbt_stardand='3' 80 | else 81 | hudbt_stardand='0' 82 | fi 83 | 84 | #-------------------------------------# 85 | # 副标题 86 | hudbt_small_descr="$chinese_title $chs_included" 87 | } 88 | #-------------------------------------# 89 | # file -> 种子文件(*),dl-url -> 网盘下载 90 | # name -> 主标题(0day 不要点*),url -> imdb链接 91 | # nfo -> nfo 文件,descr -> 简介(*),type -> 类型(*) 92 | # standard_sel -> 分辨率,uplver -> 匿名上传('yes') 93 | #---类型---# 94 | # 401 大陆电影 95 | # 413 港台电影 96 | # 414 亚洲电影 97 | # 415 欧美电影 98 | # 430 iPad 99 | # 433 抢先视频 100 | # 402 大陆剧集 101 | # 417 港台剧集 102 | # 416 亚洲剧集 103 | # 418 欧美剧集 104 | # 404 纪录片 105 | # 407 体育 106 | # 403 大陆综艺 107 | # 419 港台综艺 108 | # 420 亚洲综艺 109 | # 421 欧美综艺 110 | # 408 华语音乐 111 | # 422 日韩音乐 112 | # 423 欧美音乐 113 | # 424 古典音乐 114 | # 425 原声音乐 115 | # 406 音乐MV 116 | # 409 其他 117 | # 432 电子书 118 | # 405 完结动漫 119 | # 427 连载动漫 120 | # 428 剧场OVA 121 | # 429 动漫周边 122 | # 410 游戏 123 | # 431 游戏视频 124 | # 411 软件 125 | # 412 学习 126 | # 426 MAC 127 | # 1037 HUST 128 | #---分辨率---# 129 | # 0 请选择 130 | # 1 1080p 131 | # 2 1080i 132 | # 3 720p 133 | # 4 SD 134 | # 6 Lossy 135 | # 5 Lossless 136 | 137 | #-------------------------------------# 138 | hudbt_post_func() { 139 | gen_hudbt_parameter 140 | t_id="$(http --verify=no --ignore-stdin -f --print=h --timeout=10 POST "$postUrl"\ 141 | 'name'="$noDot_name"\ 142 | 'small_descr'="$hudbt_small_descr"\ 143 | 'url'="$imdb_url"\ 144 | 'descr'="$hudbt_des"\ 145 | 'type'="$hudbt_type"\ 146 | 'standard_sel'="$hudbt_stardand"\ 147 | 'uplver'="$anonymous_hudbt"\ 148 | file@"${torrent_Path}"\ 149 | "$cookie_hudbt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 150 | 151 | if [[ -z "$t_id" ]]; then 152 | # 辅种 153 | t_id="$(http --verify=no --ignore-stdin -f --timeout=10 POST "$postUrl"\ 154 | name="$noDot_name"\ 155 | small_descr="$hudbt_small_descr"\ 156 | url="$imdb_url"\ 157 | descr="$hudbt_des"\ 158 | type="$hudbt_type"\ 159 | standard_sel="$hudbt_stardand"\ 160 | uplver="$anonymous_hudbt"\ 161 | file@"${torrent_Path}"\ 162 | "$cookie_hudbt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 163 | fi 164 | } 165 | 166 | #-------------------------------------# 167 | -------------------------------------------------------------------------------- /post/judge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/judge.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-07-16 7 | # 8 | #----------------------------------------# 9 | judge_torrent_func() { 10 | local year quality is_pad _source base pre_url url result 11 | local count_720p count_1080p count_720p_pad count_1080p_pad this_t 12 | # 年份 13 | year="$(echo "$dot_name"|grep -Eo '[12][098][0-9]{2}')" 14 | # 分辨率 15 | quality="$(echo "$dot_name"|grep -Eio '1080[pi]|720p|4k|2160p')" 16 | # ipad? 17 | is_pad="$(echo "$dot_name"|grep -Eio 'ipad|chdpad|ihd|mpad')" 18 | # 介质 19 | _source="$(echo "$dot_name"|grep -Eio 'hdtv|blu-?ray|web-?dl|bdrip|dvdrip|webrip')" 20 | # 名字 21 | base="$(echo "$dot_name"|grep -Eo '.*[12][098][0-9]{2}')" 22 | base="$(echo "$base"|sed -E 's/(1080[pi]|720p|4k|2160p).*//i')" 23 | base="$(echo "$base"|sed -E 's/(hdtv|blu-?ray|web-?dl|bdrip|dvdrip|webrip).*//i')" 24 | # 搜索链接 25 | pre_url="${postUrl%/*}/torrents.php?search=" 26 | url="${pre_url}${base}+${quality}+${is_pad}+${_source}+${year}" 27 | # 结果页面 28 | result="$(http -b --verify=no --ignore-stdin GET "$url" "$cookie" "$user_agent")" 29 | 30 | if [ "$(echo "$result"|grep -E '搜索结果|Search results for')" ]; then 31 | if [ "$(echo "$result"|grep -E '没有种子。请用准确的关键字重试|没有种子|找到0条结果')" ]; then 32 | up_status='yes' # upload 33 | else 34 | count_720p=$(echo "$result"|grep 'torrentname'|grep -i '720p'|grep -i 'x264'|wc -l) 35 | count_1080p=$(echo "$result"|grep 'torrentname'|grep -i '1080p'|grep -i 'x264'|wc -l) 36 | count_720p_pad=$(echo "$result"|grep 'torrentname'|grep -i 'ipad'|grep -i '720p'|wc -l) 37 | count_1080p_pad=$(echo "$result"|grep 'torrentname'|grep -i 'ipad'|grep -i '1080p'|wc -l) 38 | this_t="$(echo "$result"|grep -io "$dot_name")" # 辅种 39 | [[ $this_t ]] && up_status='yes' || { 40 | #----debug--- 41 | debug_func "dupe:[720.$count_720p][720-pad.$count_720p_pad][1080.$count_1080p][1080-pad.$count_1080p_pad]" 42 | #---nanyangpt dupe judge---# 43 | if [ "$postUrl" = "${post_site[nanyangpt]}/takeupload.php" ]; then 44 | if (( count_720p - count_720p_pad > 1 )); then 45 | up_status='yes' # upload 46 | elif (( count_1080p - count_1080p_pad > 1 )); then 47 | up_status='yes' # upload 48 | else 49 | up_status='no' # give up upload 50 | echo "Dupe! [${postUrl%/*}]" >> "${log_Path}-$index" 51 | fi 52 | #---normal dupe judge---# 53 | else 54 | if [ ! "$(echo "$result"|grep -E 'torrent-title|torrentname'|grep -i "$(echo "$dot_name" |grep -Eo '.*[12][098][0-9]{2}.*0p')")" ]; then 55 | up_status='yes' # upload 56 | else 57 | up_status='no' # give up upload 58 | echo "Dupe! [${postUrl%/*}]" >> "${log_Path}-$index" 59 | fi 60 | fi # nanyang 61 | } # 辅种 62 | fi # no result 63 | fi 64 | } 65 | # 66 | #----------------------------------------# 67 | 68 | -------------------------------------------------------------------------------- /post/mteam.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/mteam.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-08-15 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_mt" 10 | passkey="$passkey_mt" 11 | anonymous="$anonymous_mt" 12 | ratio_set=$ratio_mt 13 | to_client="$client_mt" 14 | #---static---# 15 | postUrl="${post_site[mt]}/takeupload.php" 16 | editUrl="${post_site[mt]}/takeedit.php" 17 | downloadUrl="${post_site[mt]}/download.php?id=" 18 | #-------------------------------------# 19 | gen_mt_parameter() { 20 | 21 | if [[ -s "$source_desc" ]]; then 22 | [[ $header_mt = yes ]] && { 23 | mt_des="${descrCom_simple//&ratio_in_desc&/$ratio_mt} 24 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 25 | } || { 26 | mt_des="$(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 27 | } 28 | else 29 | mt_des="${descrCom_simple//&ratio_in_desc&/$ratio_mt} 30 | $failed_to_get_des" 31 | fi 32 | 33 | #-------------------------------------# 34 | # 判断类型,纪录片、电影、剧集 35 | if [ "$documentary" = 'yes' ]; then 36 | mt_type='404' 37 | else 38 | if [ "$serials" = 'yes' ]; then 39 | # 剧集分类 40 | mt_type='402' 41 | else 42 | # 电影类别 43 | mt_type='419' 44 | fi 45 | fi 46 | #-------------------------------------# 47 | # 视频编码 48 | if [ "$is_264" = 'yes' ]; then 49 | mt_codec=1 50 | elif [ "$is_265" = 'yes' ]; then 51 | mt_codec=16 52 | else 53 | mt_codec=0 54 | fi 55 | 56 | # 分辨率 57 | if [ "$is_4k" = 'yes' ]; then 58 | mt_standard='6' 59 | elif [ "$is_1080p" = 'yes' ]; then 60 | mt_standard='1' 61 | elif [ "$is_1080i" = 'yes' ]; then 62 | mt_standard='2' 63 | elif [ "$is_720p" = 'yes' ]; then 64 | mt_standard='3' 65 | else 66 | mt_standard='0' 67 | fi 68 | 69 | # 地区 70 | case "$region" in 71 | *中国大陆*) 72 | mt_source='1' ;; 73 | *香港*|*台湾*|*澳门*) 74 | mt_source='3' ;; 75 | *日本*) 76 | mt_source='4' ;; 77 | *韩国*) 78 | mt_source='5' ;; 79 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*) 80 | mt_source='2' ;; 81 | *) 82 | mt_source='6' ;; 83 | esac 84 | [[ $is_package = yes ]] && mt_team=8 || mt_team=0 85 | mt_small_descr="$chinese_title $chs_included" 86 | # mt_chs 定义在parameter.sh里面 87 | } 88 | #-------------------------------------# 89 | 90 | #---类型---# type 91 | #419 Movie(電影)/HD 92 | #420 Movie(電影)/DVDiSo 93 | #421 Movie(電影)/Blu-Ray 94 | #439 Movie(電影)/Remux 95 | #403 TV Series(影劇/綜藝)/SD 96 | #402 TV Series(影劇/綜藝)/HD 97 | #435 TV Series(影劇/綜藝)/DVDiSo 98 | #438 TV Series(影劇/綜藝)/BD 99 | #404 紀錄教育 100 | #405 Anime(動畫) 101 | #406 MV(演唱) 102 | #408 Music(AAC/ALAC) 103 | #434 Music(無損) 104 | #407 Sports(運動) 105 | #422 Software(軟體) 106 | #423 PCGame(PC遊戲) 107 | #427 eBook(電子書) 108 | #410 AV(有碼)/HD Censored 109 | #429 AV(無碼)/HD Uncensored 110 | #424 AV(有碼)/SD Censored 111 | #430 AV(無碼)/SD Uncensored 112 | #426 AV(無碼)/DVDiSo Uncensored 113 | #437 AV(有碼)/DVDiSo Censored 114 | #431 AV(有碼)/Blu-Ray Censored 115 | #432 AV(無碼)/Blu-Ray Uncensored 116 | #436 AV(網站)/0Day 117 | #425 IV(寫真影集)/Video Collection 118 | #433 IV(寫真圖集)/Picture Collection 119 | #411 H-Game(遊戲) 120 | #412 H-Anime(動畫) 121 | #413 H-Comic(漫畫) 122 | #409 Misc(其他) 123 | #---编码---# codec_sel 124 | # 0 請選擇 125 | # 1 H.264 126 | # 2 VC-1 127 | # 3 Xvid 128 | # 4 MPEG-2 129 | # 5 FLAC 130 | # 10 APE 131 | # 11 DTS 132 | # 12 AC-3 133 | # 13 WAV 134 | # 14 MP3 135 | # 15 MPEG-4 136 | # 16 H.265 137 | # 17 ALAC 138 | # 18 AAC 139 | # 140 | #---解析度---# standard_sel 141 | # 0 請選擇 142 | # 1 1080p 143 | # 2 1080i 144 | # 3 720p 145 | # 5 SD 146 | # 6 4K 147 | # 148 | #---地区---# processing_sel 149 | # 0 請選擇 150 | # 1 CN 151 | # 2 US/EU 152 | # 3 HK/TW 153 | # 4 JP 154 | # 5 KR 155 | # 6 OT 156 | #---制作组---# team_sel 157 | # 0 請選擇 ! 158 | # 6 BMDru 159 | # 7 KiSHD 160 | # 8 Pack ! 161 | # 9 MTeam 162 | # 10 MPAD 163 | # 23 TnP 164 | # 17 MTeamTV 165 | # 18 OneHD 166 | # 19 CNHK 167 | # 20 StBOX 168 | # 21 R2HD 169 | # 22 LowPower-Raws 170 | 171 | # uplver 匿名 yes 172 | #-------------------------------------# 173 | mt_post_func() { 174 | gen_mt_parameter 175 | #---post data---# 176 | id="$(http --verify=no --ignore-stdin -f --print=h POST "$postUrl"\ 177 | 'name'="$noDot_name"\ 178 | 'small_descr'="$mt_small_descr"\ 179 | 'url'="$imdb_url"\ 180 | 'descr'="$mt_des"\ 181 | 'type'="$mt_type"\ 182 | 'codec_sel'="$mt_codec"\ 183 | 'standard_sel'="$mt_standard"\ 184 | 'processing_sel'="$mt_source"\ 185 | 'l_sub'=${mt_chs:-0}\ 186 | 'team_sel'=${mt_team:-0}\ 187 | 'uplver'="$anonymous_mt"\ 188 | file@"${torrent_Path}"\ 189 | "$user_agent"\ 190 | "Referer: ${post_site[mt]}/upload.php"\ 191 | "$cookie_mt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 192 | 193 | if [[ -z "$t_id" ]]; then 194 | # 辅种 195 | reseed_torrent 196 | fi 197 | } 198 | 199 | #-------------------------------------# 200 | -------------------------------------------------------------------------------- /post/nanyangpt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/nanyangpt.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2018-12-05 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_nanyangpt" 10 | passkey="$passkey_nanyangpt" 11 | anonymous="$anonymous_nanyangpt" 12 | ratio_set=$ratio_nanyangpt 13 | to_client="$client_nanyangpt" 14 | #---static---# 15 | postUrl="${post_site[nanyangpt]}/takeupload.php" 16 | editUrl="${post_site[nanyangpt]}/takeedit.php" 17 | downloadUrl="${post_site[nanyangpt]}/download.php?id=" 18 | #-------------------------------------# 19 | # 需要的参数 20 | gen_nanyangpt_parameter() { 21 | 22 | if [[ -s "$source_desc" ]]; then 23 | nanyangpt_des="${descrCom_simple//&ratio_in_desc&/$ratio_nanyangpt} 24 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 25 | else 26 | nanyangpt_des="${descrCom_simple//&ratio_in_desc&/$ratio_nanyangpt} 27 | $failed_to_get_des" 28 | fi 29 | 30 | if [ "$documentary" = 'yes' ]; then 31 | # 纪录片 32 | nanyangpt_type='406' 33 | else 34 | if [ "$serials" = 'yes' ]; then 35 | # 剧集 36 | nanyangpt_type='402' 37 | else 38 | # 电影 39 | nanyangpt_type='401' 40 | fi 41 | fi 42 | 43 | # 副标题 44 | nanyangpt_small_descr="$chinese_title $chs_included" 45 | } 46 | #-------------------------------------# 47 | # file -> 种子文件(*) 48 | # type -> 类型(*) ,name -> 主标题(0day 不要点*) 49 | # [movie_enname | series_enname |doc_enname],small_descr -> 副标题 50 | # url -> imdb链接,dburl -> 豆瓣链接(没有 imdb 才使用) 51 | # nfo -> nfo 文件,descr -> 简介(*) 52 | # uplver -> 匿名上传('yes'),prohibit_transfer -> 禁转('yes') 53 | #---类型---# 54 | # 401 电影 55 | # 402 剧集 56 | # 403 动漫 57 | # 404 综艺 58 | # 405 体育 59 | # 406 纪录 60 | # 407 音乐 61 | # 408 学习 62 | # 409 软件 63 | # 410 游戏 64 | # 411 其它 65 | 66 | #-------------------------------------# 67 | nanyangpt_post_func() { 68 | gen_nanyangpt_parameter 69 | #---post data---# 70 | if [[ "$nanyangpt_type" == '401' ]]; then 71 | # 电影 POST 72 | t_id="$(http --verify=no --ignore-stdin -f --print=h POST "$postUrl"\ 73 | 'name'="$dot_name"\ 74 | 'movie_enname'="$dot_name"\ 75 | 'small_descr'="$nanyangpt_small_descr"\ 76 | 'url'="$imdb_url"\ 77 | 'dburl'="$([[ ! "$imdb_url" ]] && echo "$douban_url" || echo 'none')"\ 78 | 'descr'="$nanyangpt_des"\ 79 | 'type'="$nanyangpt_type"\ 80 | 'uplver'="$anonymous_nanyangpt"\ 81 | file@"${torrent_Path}"\ 82 | "$cookie_nanyangpt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 83 | 84 | if [[ -z "$t_id" ]]; then 85 | # 辅种 86 | reseed_torrent 87 | fi 88 | elif [[ "$nanyangpt_type" == '402' ]]; then 89 | # 剧集 POST 90 | t_id="$(http --verify=no --ignore-stdin -f --print=h POST "$postUrl"\ 91 | 'name'="$dot_name"\ 92 | 'series_enname'="$dot_name"\ 93 | 'small_descr'="$nanyangpt_small_descr"\ 94 | 'url'="$imdb_url"\ 95 | 'dburl'="$([[ ! "$imdb_url" ]] && echo "$douban_url" || echo 'none')"\ 96 | 'descr'="$nanyangpt_des"\ 97 | 'type'="$nanyangpt_type"\ 98 | 'uplver'="$anonymous_nanyangpt"\ 99 | file@"${torrent_Path}"\ 100 | "$cookie_nanyangpt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 101 | 102 | if [[ -z "$t_id" ]]; then 103 | # 辅种 104 | reseed_torrent 105 | fi 106 | 107 | elif [[ "$nanyangpt_type" == '406' ]]; then 108 | # 纪录片 POST 109 | t_id="$(http --verify=no --ignore-stdin -f --print=h POST "$postUrl"\ 110 | 'name'="$dot_name"\ 111 | 'doc_enname'="$dot_name"\ 112 | 'small_descr'="$nanyangpt_small_descr"\ 113 | 'url'="$imdb_url"\ 114 | 'dburl'="$([[ ! "$imdb_url" ]] && echo "$douban_url" || echo 'none')"\ 115 | 'descr'="$nanyangpt_des"\ 116 | 'type'="$nanyangpt_type"\ 117 | 'uplver'="$anonymous_nanyangpt"\ 118 | file@"${torrent_Path}"\ 119 | "$cookie_nanyangpt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 120 | 121 | if [[ -z "$t_id" ]]; then 122 | # 辅种 123 | reseed_torrent 124 | fi 125 | else 126 | # 其他 POST 127 | : 128 | fi 129 | } 130 | 131 | #-------------------------------------# 132 | 133 | -------------------------------------------------------------------------------- /post/neu6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/neu6.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2018-12-05 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_neu6" 10 | passkey="$passkey_neu6" 11 | anonymous="$anonymous_neu6" 12 | ratio_set=$ratio_neu6 13 | to_client="$client_neu6" 14 | #---static---# 15 | postUrl="${post_site[neu6]}/forum.php" 16 | editUrl="${post_site[neu6]}/takeedit.php" 17 | downloadUrl="${post_site[neu6]}/forum.php?mod=attachment&aid=NTMxNjc3NHw3OTU0OWY0NXwxNTUxNDEyMTUxfDY0NDE2OHwxNjQ2NDM5&ck=bfc4cae3" 18 | #-------------------------------------# 19 | # 需要的参数 20 | gen_neu6_parameter() { 21 | 22 | if [ -s "$source_desc" ]; then 23 | neu6_des="${descrCom_simple//&ratio_in_desc&/$ratio_neu6} 24 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 25 | else 26 | neu6_des="${descrCom_simple//&ratio_in_desc&/$ratio_neu6} 27 | $failed_to_get_des" 28 | fi 29 | 30 | #-------------------------------------# 31 | # 判断类型,纪录片、电影、剧集 32 | if [ "$documentary" = 'yes' ]; then 33 | neu6_type='404' 34 | neu6_source='41' 35 | else 36 | if [ "$serials" = 'yes' ]; then 37 | # 剧集分类 38 | neu6_type='402' 39 | case "$region" in 40 | *中国大陆*) 41 | neu6_source='23' ;; 42 | *香港*|*台湾*|*澳门*) 43 | neu6_source='24' ;; 44 | *日本*) 45 | neu6_source='26' ;; 46 | *韩国*) 47 | neu6_source='27' ;; 48 | *美国*) 49 | neu6_source='25' ;; 50 | *英国*) 51 | neu6_source='65' ;; 52 | *) 53 | neu6_source='63' ;; 54 | esac 55 | else 56 | # 电影类别 57 | neu6_type='401' 58 | case "$region" in 59 | *中国大陆*|*香港*|*台湾*|*澳门*) 60 | neu6_source='6' ;; 61 | *日本*|*韩国*) 62 | neu6_source='4' ;; 63 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*) 64 | neu6_source='5' ;; 65 | *) 66 | neu6_source='7' ;; 67 | esac 68 | 69 | fi 70 | fi 71 | 72 | # 副标题 73 | neu6_small_descr="$chinese_title $chs_included" 74 | #-------------------------------------# 75 | #---base64 encode---# 76 | des_enc="$(echo "$neu6_des"|base64)" 77 | name_enc="$(echo "$dot_name"|base64)" 78 | sub_title_enc="$(echo "$neu6_small_descr"|base64)" 79 | } 80 | neu6_tmp="$ROOT_PATH/tmp/neu6_tmp.html" 81 | http 'http://bt.neu6.edu.cn/home.php' "$cookie_neu6" > "$neu6_tmp" 82 | formhash="$(iconv -f GBK -t utf-8 neu6.html |grep -Eio 'formhash=[0-9a-z]+'|sed 's/.*=//')" 83 | if [[ $formhash ]] && \rm -f "$neu6_tmp" 84 | #-------------------------------------# 85 | neu6_post_func() { 86 | gen_neu6_parameter 87 | #---post data---# 88 | t_id="$(http --verify=no --ignore-stdin --print=h -f POST "$postUrl"\ 89 | mod==post action==newthread fid==156 topicsubmit==yes \ 90 | 'formhash'="$formhash"\ 91 | 'posttime'="$(date +%s)"\ 92 | 'subject'="$name_enc"\ 93 | 'wysiwyg'="1"\ 94 | 'message'="$des_enc"\ 95 | 'typeid'="$neu6_type"\ 96 | 'specialextra'="torrent"\ 97 | 'special'="127"\ 98 | torrent@"${torrent_Path}"\ 99 | "$cookie_neu6"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 100 | 101 | if [[ -z "$t_id" ]]; then 102 | # 辅种 103 | reseed_torrent 104 | fi 105 | } 106 | 107 | #-------------------------------------# 108 | 109 | -------------------------------------------------------------------------------- /post/npupt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/npupt.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2018-12-05 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_npupt" 10 | passkey="$passkey_npupt" 11 | anonymous="$anonymous_npupt" 12 | ratio_set=$ratio_npupt 13 | to_client="$client_npupt" 14 | #---static---# 15 | postUrl="${post_site[npupt]}/takeupload.php" 16 | editUrl="${post_site[npupt]}/takeedit.php" 17 | downloadUrl="${post_site[npupt]}/download.php?id=" 18 | #-------------------------------------# 19 | # 需要的参数 20 | gen_npupt_parameter() { 21 | 22 | if [ -s "$source_desc" ]; then 23 | npupt_des="${descrCom_simple//&ratio_in_desc&/$ratio_npupt} 24 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 25 | else 26 | npupt_des="${descrCom_simple//&ratio_in_desc&/$ratio_npupt} 27 | $failed_to_get_des" 28 | fi 29 | 30 | #-------------------------------------# 31 | # 判断类型,纪录片、电影、剧集 32 | if [ "$documentary" = 'yes' ]; then 33 | npupt_type='404' 34 | npupt_source='41' 35 | else 36 | if [ "$serials" = 'yes' ]; then 37 | # 剧集分类 38 | npupt_type='402' 39 | case "$region" in 40 | *中国大陆*) 41 | npupt_source='23' ;; 42 | *香港*|*台湾*|*澳门*) 43 | npupt_source='24' ;; 44 | *日本*) 45 | npupt_source='26' ;; 46 | *韩国*) 47 | npupt_source='27' ;; 48 | *美国*) 49 | npupt_source='25' ;; 50 | *英国*) 51 | npupt_source='65' ;; 52 | *) 53 | npupt_source='63' ;; 54 | esac 55 | else 56 | # 电影类别 57 | npupt_type='401' 58 | case "$region" in 59 | *中国大陆*|*香港*|*台湾*|*澳门*) 60 | npupt_source='6' ;; 61 | *日本*|*韩国*) 62 | npupt_source='4' ;; 63 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*) 64 | npupt_source='5' ;; 65 | *) 66 | npupt_source='7' ;; 67 | esac 68 | 69 | fi 70 | fi 71 | 72 | # 副标题 73 | npupt_small_descr="$chinese_title $chs_included" 74 | #-------------------------------------# 75 | #---base64 encode---# 76 | des_enc="$(echo "$npupt_des"|base64)" 77 | name_enc="$(echo "$dot_name"|base64)" 78 | sub_title_enc="$(echo "$npupt_small_descr"|base64)" 79 | } 80 | 81 | #-------------------------------------# 82 | npupt_post_func() { 83 | gen_npupt_parameter 84 | #---post data---# 85 | t_id="$(http --verify=no --ignore-stdin --print=h -f POST "$postUrl"\ 86 | 'name'="$name_enc"\ 87 | 'small_descr'="$sub_title_enc"\ 88 | 'descr'="$des_enc"\ 89 | 'type'="$npupt_type"\ 90 | 'source_sel'="$npupt_source"\ 91 | 'uplver'="$anonymous_npupt"\ 92 | file@"${torrent_Path}"\ 93 | "$cookie_npupt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 94 | 95 | if [[ -z "$t_id" ]]; then 96 | # 辅种 97 | reseed_torrent 98 | fi 99 | } 100 | 101 | #-------------------------------------# 102 | 103 | -------------------------------------------------------------------------------- /post/parameter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/parameter.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-09-02 7 | # 8 | #-------------------------------------# 9 | # 通过之前生成的 desc 简介文档,提取其中的各种参数。 10 | # 一次获取,多站重复使用。 11 | # 对参数有特殊要求的站点,其规则会写到其对应的 post 文件中。 12 | #-------------------------------------# 13 | unset_all_parameter() { 14 | unset noDot_name region serials season normal documentary genre language 15 | unset chs_included chinese_title foreign_title imdb_url douban_url is_ipad 16 | unset is_bd is_hdtv is_webdl is_4k is_1080p is_720p is_other file_type mt_chs 17 | unset is_package is_264 is_265 is_dts is_ac3 is_aac is_flac animation theater 18 | } 19 | #-------------------------------------# 20 | # 处理不规范的打包(伪complete) 21 | complete_episode() { 22 | local _f_data _total _real _ep 23 | _real="$(grep -E '^.集  数 .*$' "$source_desc"|grep -Eo '[0-9]+')" 24 | _f_data="$($tr_show "$torrent_Path"|sed '1,/FILES/d;/^ *$/d'|grep -Eo \ 25 | 'E[0-9]{1,2}'|sed 's/E0*//')" # 超过一百集的电视剧应该木有吧? 26 | _total="$(echo "$_f_data"|wc -l)" 27 | # 初略判断,如果获取失败,使用默认值 10,6 28 | if [[ ${_real:-10} -gt ${_total:-6} ]]; then 29 | _ep="$(echo "$_f_data"|awk '{if (NR==1) min=max=$1; else 30 | {min=min<$1?min:$1; max=max>$1?max:$1} }END{ 31 | if (min!= max) printf("E%02d-E%02d",min,max); else printf("E%02d", min)}')" 32 | [[ $_ep ]] && { season="$_ep" && \ 33 | dot_name="$(echo "$dot_name"|sed "s/Complete/$_ep/i")"; } || \ 34 | debug_func "parameter:episode-[$_real]-[$_total]-[$_ep]" #----debug--- 35 | # noDot_name 后面有处理 36 | is_package='no' # 不是合集 37 | fi 38 | unset _f_data _total _real _ep 39 | } 40 | #---------------main------------------# 41 | from_desc_get_param() { 42 | unset_all_parameter 43 | # httpie 对文件名有要求,如包含特殊字符,可能 POST 失败,只改torrent文件名。 44 | local pl_name_tmp="autoseed.$(date +%s%N).torrent" 45 | mv "$torrent_Path" "${flexget_path}/${pl_name_tmp}" 46 | torrent_Path="${flexget_path}/${pl_name_tmp}" 47 | # -e 直接修改该文件,-n 不改变hash,-c 改 comment。 48 | [[ $No_Headers != yes && -f "$ROOT_PATH/post/xseed" ]] && "$ROOT_PATH/post/xseed" -enc \ 49 | 'Powered by rachpt/AutoSeed. https://github.com/rachpt/AutoSeed' "$torrent_Path" 50 | [[ $? -ne 0 ]] && debug_func "para:xseed[bencode unstall]!!" #----debug--- 51 | 52 | #----------操作 desc 简介文件-------- 53 | # 获取国家,取第一个 54 | region="$(grep -E '^.产  地 .*$' "$source_desc"| \ 55 | sed -r 's/.[产][  ]*[地][  ]*//'|sed -r 's![ ]*([^/ ]+).*!\1!')" 56 | # 剧集或者普通类别 57 | if [ "$(grep -E '^.集  数 .*$' "$source_desc")" ]; then 58 | serials='yes' 59 | # 剧集季度 60 | season="$(echo "$dot_name"|grep -Eio '[ \.]s0?(10|20|[1-9]+).?(ep?[0-9]+)?[ \.]'| \ 61 | sed 's/[a-z]/\u&/g;s/\.//g')" 62 | [[ $season ]] || \ 63 | season="$(echo "$dot_name"|grep -Eio '[ \.]ep?[0-9]{1,3}-?(e?p?[0-9]{1,3})?[\. ]'| \ 64 | sed 's/[a-z]/\u&/g;s/\.//g')" 65 | # 文件名没有集数信息,使用原简介中的集数信息 66 | [[ $season ]] || { 67 | season="$(grep -Eiom1 'Ep?[0-9]{1,2}(-Ep?[0-9]{1,2})?' "$source_desc")" 68 | season="${season/$'\n'*/}" 69 | # 对于没有 Complete 标记的补上 集数 信息 70 | [[ $season && ! $dot_name =~ .*[cC][oO][mM][pP][lL][eE][tT][eE].* ]] && { 71 | dot_name="${dot_name/2160/$season.2160}" 72 | dot_name="${dot_name/1080/$season.1080}" 73 | dot_name="${dot_name/720/$season.720}" 74 | dot_name="${dot_name/4[kK]/$season.4K}"; } 75 | } 76 | else 77 | normal='yes' 78 | fi 79 | genre="$(grep -E '^.类  别 .*$' "$source_desc"| \ 80 | sed -r 's/.类  别 //;s/ //g')" 81 | # 是否为纪录片 82 | if [[ $genre =~ .*纪录片.* ]]; then 83 | # 纪录片 84 | documentary='yes' 85 | elif [[ $genre =~ .*动画.* ]]; then 86 | # 国创动漫 87 | animation='yes' 88 | else 89 | normal='yes' 90 | fi 91 | # 是否为剧场版 92 | [[ $(grep -E '^.标  签 .*$' "$source_desc"|grep -o '剧场版') ]] && \ 93 | theater='yes' || theater='no' 94 | # 语言 95 | language="$(grep -E '^.语  言 .*$' "$source_desc"| \ 96 | sed -r 's/.语  言 //'|sed -r 's#[ ]+##g')" 97 | 98 | imdb_url="$(grep -Eo 'tt[0-9]{7,8}' "$source_desc"|head -1)" 99 | douban_url="$(grep -Eo 'https?://movie\.douban\.com/subject/[0-9]{7,8}/?' \ 100 | "$source_desc"|head -1)" 101 | 102 | #----------操作 0day 名-------- 103 | # 识别 iPad 以及视频分辨率,以及介质(BD、hdtv、web-dl) 104 | case "$dot_name" in 105 | *[IiMm][Pp][Aa][Dd]*|*iHD*) 106 | is_ipad='yes' 107 | ;; 108 | *) 109 | is_ipad='no' 110 | ;; 111 | esac 112 | # 介质 113 | case "$dot_name" in 114 | *[Bb][Ll][Uu][Rr][Aa][Yy]*|*[Bb][Ll][Uu]-[Rr][Aa][Yy]*|*[Bb][Dd][Rr][Ii][Pp]*) 115 | is_bd='yes' 116 | ;; 117 | *[Hh][Dd][Tt][Vv]*) 118 | is_hdtv='yes' 119 | ;; 120 | *[Ww][Ee][Bb]-[Dd][Ll]*) 121 | is_webdl='yes' 122 | ;; 123 | *) 124 | is_bd='no' 125 | ;; 126 | esac 127 | # 1080p or 720p ... 128 | case "$dot_name" in 129 | *2160[Pp]*|*4[Kk]*) 130 | is_4k='yes' 131 | ;; 132 | *1080[Pp]*) 133 | is_1080p='yes' 134 | ;; 135 | *1080[Ii]*) 136 | is_1080i='yes' 137 | ;; 138 | *720[Pp]*) 139 | is_720p='yes' 140 | ;; 141 | *) 142 | is_other='yes' 143 | ;; 144 | esac 145 | # 是否为合集(package|complete) 146 | case "$dot_name" in 147 | *[Cc][Oo][Mm][Pp][Ll][Ee][Tt][Ee]*) 148 | is_package='yes' 149 | complete_episode # 处理伪合集 150 | ;; 151 | *) 152 | if [[ $season =~ [sS][0-9]+(-[sS][0-9]+)? ]]; then 153 | is_package='yes' 154 | else 155 | is_package='no' 156 | fi 157 | ;; 158 | esac 159 | 160 | # 文件格式 161 | if [ "$("$tr_show" "$torrent_Path"|grep -A10 'FILES'|grep -i '\.mkv')" ]; then 162 | file_type='MKV' 163 | elif [ "$("$tr_show" "$torrent_Path"|grep -A10 'FILES'|grep -i '\.mp4')" ]; then 164 | file_type='MP4' 165 | elif [ "$("$tr_show" "$torrent_Path"|grep -A10 'FILES'|grep -i '\.ts')" ]; then 166 | file_type='TS' 167 | elif [ "$("$tr_show" "$torrent_Path"|grep -A10 'FILES'|grep -i '\.avi')" ]; then 168 | file_type='AVI' 169 | else 170 | file_type='其他' 171 | fi 172 | 173 | # 音频编码格式 174 | case "$dot_name" in 175 | *[Dd][Tt][Ss]*) 176 | is_dts='yes' 177 | ;; 178 | *[Aa][Cc]-3*) 179 | is_ac3='yes' 180 | ;; 181 | *[Aa][Aa][Cc]*) 182 | is_aac='yes' 183 | ;; 184 | *[Ff][Ll][Aa][Cc]*) 185 | is_flac='yes' 186 | ;; 187 | esac 188 | # 视频编码格式 189 | case "$dot_name" in 190 | *264*) 191 | is_264='yes' 192 | ;; 193 | *265*) 194 | is_265='yes' 195 | ;; 196 | esac 197 | 198 | #-------------------------------------------------------------# 199 | #---name for post---# 200 | noDot_name="$(echo "$dot_name"|sed -E \ 201 | 's/\./ /g;s/ DD2 0/ DD2.0/i;s/ H 26/ H.26/i;s/([^0-9]5) 1/\1.1/;s/([^0-9]7) 1/\1.1/')" 202 | 203 | # 添加额外信息 ---1 204 | chs_included="$(grep '&extra_comment&' "$source_desc"|sed 's/&extra_comment&//')" 205 | # 中文字幕 ---2 206 | [[ "$(grep -i "CH[ST]" "$source_desc")" ]] && { 207 | chs_included="${chs_included:-中文字幕}" 208 | mt_chs=1; } 209 | # 剧集集数信息 ---3 210 | [[ ! $chs_included && $serials = yes ]] && chs_included="$season" 211 | # 删除 212 | sed -i '/&extra_comment&/d' "$source_desc" 213 | 214 | # 中文名 215 | chinese_title="$(grep '&shc_name_douban&' "$source_desc"| \ 216 | sed 's/&shc_name_douban&//')" 217 | 218 | # 英文名 219 | foreign_title="$(grep '&eng_name_douban&' "$source_desc"| \ 220 | sed 's/&eng_name_douban&//')" 221 | 222 | # 删除 简介中的中英文名 223 | #sed -i '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc" 224 | } 225 | 226 | #-------------------------------# 227 | 228 | -------------------------------------------------------------------------------- /post/post.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/post.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-12-21 7 | # 8 | #---------------------------------------# 9 | # 将简介以及种子以post方式发布 10 | #---------------------------------------# 11 | # import functions 12 | source "$ROOT_PATH/get_desc/desc.sh" # get source site 13 | [[ `type -t from_desc_get_param` != "function" ]] && \ 14 | source "$ROOT_PATH/post/parameter.sh" 15 | [[ `type -t judge_torrent_func` != "function" ]] && \ 16 | source "$ROOT_PATH/post/judge.sh" 17 | [[ `type -t match_douban_imdb` != "function" ]] && \ 18 | source "$ROOT_PATH/get_desc/match.sh" 19 | #---------------------------------------# 20 | judge_before_upload() { 21 | up_status='yes' # judge code 22 | yellow_mv='no' 23 | #---judge to get away from dupe---# 24 | #[ "$postUrl" = "${post_site[whu]}/takeupload.php" ] && \ 25 | #judge_torrent_func # $ROOT_PATH/post/judge.sh 26 | [ "$postUrl" = "${post_site[nanyangpt]}/takeupload.php" ] && \ 27 | judge_torrent_func # $ROOT_PATH/post/judge.sh 28 | #---necessary judge---# 29 | if [ "$(grep -Em1 '禁止转载|禁转|独占资源' "$source_desc")" ]; then 30 | up_status='no' # give up upload 31 | printf '%b' "禁转禁发资源\n" >> "${log_Path}-$index" 32 | elif [[ "$(grep -Em1 '.类.*别.*情色' "$source_desc")" ]]; then 33 | up_status='no' # give up upload 34 | yellow_mv='yes' 35 | printf '%b' "情色电影。--\n" >> "${log_Path}-$index" 36 | fi 37 | 38 | unset t_id # set t_id to none 39 | #---post---# 40 | if [[ $up_status = yes ]]; then 41 | #---log---# 42 | printf '%s\n' "-----------[post data]-----------" >> "${log_Path}-$index" 43 | printf '%s\n' "name=${dot_name}" >> "${log_Path}-$index" 44 | printf '%s\n' "small_descr=${chinese_title}" >> "${log_Path}-$index" 45 | printf '%s\n' "imdburl=${imdb_url}" >> "${log_Path}-$index" 46 | printf '%s\n' "uplver=${anonymous}" >> "${log_Path}-$index" 47 | printf '%s\n' "${postUrl%/*}" >> "${log_Path}-$index" 48 | fi 49 | } 50 | 51 | add_t_id_2_client() { 52 | #---if get t_id then add it to tr---# 53 | t_id="${t_id/$'\n'*/}" # use first line 54 | [[ $up_status = yes ]] && if [[ -z $t_id ]]; then 55 | printf '%s\n' '=!==!=[failed to get tID]==!==!==' >> "${log_Path}-$index" 56 | else 57 | printf '%s\n' "t_id: [$t_id]" >> "${log_Path}-$index" 58 | #---add torrent---# 59 | if [[ $downloadUrl =~ .*m-team.cc.* ]]; then 60 | torrent2add="${downloadUrl}${t_id}&passkey=${passkey}&https=1" # &ipv6=1 61 | else 62 | torrent2add="${downloadUrl}${t_id}&passkey=${passkey}" 63 | fi 64 | source "$ROOT_PATH/post/add.sh" 65 | fi 66 | unset t_id torrent2add 67 | } 68 | #---------------------------------------# 69 | # 用于辅种 70 | reseed_torrent() { 71 | local result name 72 | shopt -s extglob # 开启扩展匹配 73 | # 分辨率 74 | name="${dot_name//*(1080[PpIi]|720[Pp]|4[Kk]|2160[Pp])}" 75 | name="${name,,}" # 小写 76 | # 介质 77 | name="${name//*(hdtv|blu?(-)ray|web?(-)dl|bdrip|dvdrip|webrip)}" 78 | # 删除季数 79 | name="${name//*([ \.]s(?[012][1-9])?(e?p+[0-9])[ \.]*)}" 80 | name="${name//*([ \.]e?p[0-9]?[0-9]?(-?e?p[0-9]?[0-9])[ \.]*)}" 81 | #name="$(echo "$name"|sed -E 's/[ \.]ep?[0-9]{1,2}(-e?p?[0-9]{1,2})?[ \.].*//i')" 82 | # 删除合集 83 | name="${name//[ \.][Cc]omplete[\. ].*/}" 84 | name="${name//+(.)/.}" 85 | result="$(http --verify=no --ignore-stdin -b --timeout=25 GET "${postUrl%/*}/torrents.php?search=${name}&incldead=1" "$cookie" "$user_agent")" 86 | t_id=$(printf '%s' "$result"|grep "$dot_name"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*') 87 | [[ ! $t_id ]] && { 88 | result="$(http --verify=no --ignore-stdin -b --timeout=25 GET "${postUrl%/*}/torrents.php?search=${dot_name}&incldead=1" "$cookie" "$user_agent")" 89 | t_id=$(printf '%s' "$result"|grep "$dot_name"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*') 90 | } 91 | t_id="${t_id/$'\n'*/}" # use first line 92 | debug_func "post:reseed-get[$t_id]" #----debug--- 93 | shopt -u extglob # 关闭扩展匹配 94 | } 95 | 96 | #---------------------------------------# 97 | unset_tempfiles() { 98 | [[ -f "${log_Path}-1" ]] && { 99 | local tmp f 100 | for f in "${log_Path}-"[0-9]*;do tmp="${tmp}$(< "$f")\n";done 101 | printf '%b' "$tmp" >> "$log_Path" 102 | unset tmp f 103 | #\cat "${log_Path}-"[0-9]* >> "$log_Path" 104 | \rm -f "${log_Path}-"[0-9]* ; } 105 | 106 | [ ! "$test_func_probe" ] && \ 107 | \rm -f "$source_desc" "$source_html" "$source_desc2tjupt" 108 | unset source_desc source_html source_desc2tjupt index 109 | unset douban_poster_url source_site_URL source_t_id imdb_url douban_url 110 | echo "----------[deleted tmp]----------" >> "$log_Path" 111 | } 112 | 113 | #-----import and call functions---------# 114 | # 获得发布所需参数 115 | from_desc_get_param # $ROOT_PATH/post/parameter.sh 116 | # 简介头 117 | [[ $No_Headers = yes ]] || set_desc_headers # static.sh 118 | # 美剧imdb链接修正 119 | match_douban_imdb "$dot_name" 'series' 120 | match_douban_imdb "$org_tr_name" 'series' 121 | index=0 # 线程标识符 122 | if [ "$enable_whu" = 'yes' ]; then 123 | ((index++)) 124 | (source "$ROOT_PATH/post/whu.sh" 125 | judge_before_upload 126 | [[ $up_status = yes ]] && whu_post_func 127 | add_t_id_2_client) & 128 | fi 129 | 130 | if [ "$enable_hudbt" = 'yes' ]; then 131 | ((index++)) 132 | (source "$ROOT_PATH/post/hudbt.sh" 133 | judge_before_upload 134 | [[ $up_status = yes ]] && hudbt_post_func 135 | add_t_id_2_client) & 136 | fi 137 | 138 | if [ "$enable_npupt" = 'yes' ]; then 139 | ((++index)) 140 | (source "$ROOT_PATH/post/npupt.sh" 141 | judge_before_upload 142 | [[ $up_status = yes ]] && npupt_post_func 143 | add_t_id_2_client) & 144 | fi 145 | 146 | if [ "$enable_nanyangpt" = 'yes' ]; then 147 | ((++index)) 148 | (source "$ROOT_PATH/post/nanyangpt.sh" 149 | judge_before_upload 150 | [[ $up_status = yes ]] && nanyangpt_post_func 151 | add_t_id_2_client) & 152 | fi 153 | 154 | if [ "$enable_byrbt" = 'yes' ]; then 155 | ((++index)) 156 | (source "$ROOT_PATH/post/byrbt.sh" 157 | judge_before_upload 158 | [[ $up_status = yes ]] && byrbt_post_func 159 | add_t_id_2_client) & 160 | fi 161 | 162 | if [ "$enable_cmct" = 'yes' ]; then 163 | ((++index)) 164 | (source "$ROOT_PATH/post/cmct.sh" 165 | judge_before_upload 166 | [[ $up_status = yes || $yellow_mv = yes ]] && cmct_post_func 167 | add_t_id_2_client) & 168 | fi 169 | # 只转发特定小组资源 170 | [[ $dot_name =~ .*-(WiKi|HDChina)$ ]] && { 171 | if [ "$enable_mt" = 'yes' ]; then 172 | ((++index)) 173 | (source "$ROOT_PATH/post/mteam.sh" 174 | judge_before_upload 175 | [[ $up_status = yes || $yellow_mv = yes ]] && mt_post_func 176 | add_t_id_2_client) & 177 | fi 178 | } 179 | 180 | if [ "$enable_tjupt" = 'yes' ]; then 181 | ((++index)) 182 | (source "$ROOT_PATH/post/tjupt.sh" 183 | judge_before_upload 184 | [[ $up_status = yes ]] && tjupt_post_func 185 | add_t_id_2_client) & 186 | fi 187 | 188 | if [ "$enable_tlfbits" = 'yes' ]; then 189 | ((++index)) 190 | (source "$ROOT_PATH/post/tlfbits.sh" 191 | #judge_before_upload 192 | up_status='yes' 193 | tlfbits_post_func 194 | add_t_id_2_client) & 195 | fi 196 | #---------------------------------------# 197 | wait 198 | #---------------unset-------------------# 199 | 200 | unset_tempfiles 201 | 202 | #---------------------------------------# 203 | 204 | -------------------------------------------------------------------------------- /post/tjupt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/tjupt.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2018-12-09 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_tjupt" 10 | passkey="$passkey_tjupt" 11 | anonymous="$anonymous_tjupt" 12 | ratio_set=$ratio_tjupt 13 | to_client="$client_tjupt" 14 | #---static---# 15 | postUrl="${post_site[tjupt]}/takeupload.php" 16 | editUrl="${post_site[tjupt]}/takeedit.php" 17 | downloadUrl="${post_site[tjupt]}/download.php?id=" 18 | #-------------------------------------# 19 | gen_tjupt_parameter() { 20 | 21 | if [ -s "$source_desc2tjupt" ]; then 22 | tjupt_des="${descrCom_simple/&ratio_in_desc&/$ratio_tjupt} 23 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d;/&extra_comment&/d' "$source_desc2tjupt")" 24 | else 25 | tjupt_des="${descrCom_simple/&ratio_in_desc&/$ratio_tjupt} 26 | $failed_to_get_des" 27 | fi 28 | 29 | #-------------------------------------# 30 | # 类型 31 | if [ "$documentary" = 'yes' ]; then 32 | # 纪录片 33 | tjupt_type='411' 34 | elif [ "$is_ipad" = 'yes' ]; then 35 | tjupt_type='412' 36 | else 37 | if [ "$serials" = 'yes' ]; then 38 | # 剧集 39 | tjupt_type='402' 40 | else 41 | # 电影 42 | tjupt_type='401' 43 | fi 44 | fi 45 | # 年份 46 | tjupt_year="$(echo "$dot_name"|grep -Eo '[12][089][0-9]{2}'|sed '/1080/d'|tail -1)" 47 | [ ! "$tjupt_year" ] && tjupt_year=2018 # 默认年份 48 | 49 | # 电影格式 50 | if [ "$is_1080p" = 'yes' ]; then 51 | jutpt_stardand='1080p' 52 | elif [ "$is_720p" = 'yes' ]; then 53 | jutpt_stardand='720p' 54 | else 55 | jutpt_stardand='none' 56 | fi 57 | 58 | if [ "$chs_included" ]; then 59 | tjupt_subsinfo=2 60 | else 61 | tjupt_subsinfo=6 62 | fi 63 | 64 | #-------------------------------------# 65 | # 来源 66 | if [ "$is_bd" = 'yes' ]; then 67 | tjupt_source='1' 68 | elif [ "$is_hdtv" = 'yes' ]; then 69 | tjupt_source='4' 70 | elif [ "$is_webdl" = 'yes' ]; then 71 | tjupt_source='7' 72 | else 73 | tjupt_source='8' 74 | fi 75 | 76 | #-------------------------------------# 77 | # 地区 78 | case "$region" in 79 | *中国大陆*) 80 | tjupt_team='2' ;; 81 | *香港*|*台湾*|*澳门*) 82 | tjupt_team='5' ;; 83 | *日本*|*韩国*) 84 | tjupt_team='3' ;; 85 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*) 86 | tjupt_team='1' ;; 87 | *) 88 | tjupt_team='7' ;; 89 | esac 90 | } 91 | #-------------------------------------# 92 | tjupt_post_func() { 93 | gen_tjupt_parameter 94 | #---post data---# 95 | t_id="$(http --verify=no --ignore-stdin -f --print=h POST "$postUrl"\ 96 | 'small_descr'="$chs_included"\ 97 | 'url'="$imdb_url"\ 98 | 'descr'="$tjupt_des"\ 99 | 'type'="$tjupt_type"\ 100 | 'cname'="$chinese_title"\ 101 | 'ename'="$dot_name"\ 102 | 'issuedate'="$tjupt_year"\ 103 | 'language'="$language"\ 104 | 'format'="$jutpt_stardand"\ 105 | 'formatratio'="$jutpt_stardand"\ 106 | 'subsinfo'="$tjupt_subsinfo"\ 107 | 'district'="$region"\ 108 | 'specificcat'="$region"\ 109 | 'source_sel'="$tjupt_source"\ 110 | 'team_sel'="$tjupt_team"\ 111 | 'uplver'="$anonymous_tjupt"\ 112 | file@"${torrent_Path}"\ 113 | "$cookie_tjupt"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 114 | 115 | if [[ -z "$t_id" ]]; then 116 | # 辅种 117 | reseed_torrent 118 | fi 119 | } 120 | 121 | #-------------------------------------# 122 | -------------------------------------------------------------------------------- /post/tlfbits.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/tlfbits.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-12-21 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_tlfbits" 10 | passkey="$passkey_tlfbits" 11 | anonymous="$anonymous_tlfbits" 12 | ratio_set=$ratio_tlfbits 13 | to_client="$client_tlfbits" 14 | #---static---# 15 | postUrl="${post_site[tlfbits]}/takeupload.php" 16 | editUrl="${post_site[tlfbits]}/takeedit.php" 17 | downloadUrl="${post_site[tlfbits]}/download.php?id=" 18 | #-------------------------------------# 19 | gen_tlfbits_parameter() { 20 | # 简介 21 | if [ -s "$source_desc" ]; then 22 | tlfbits_des="${descrCom_simple//&ratio_in_desc&/$ratio_tlfbits} 23 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 24 | else 25 | tlfbits_des="${descrCom_simple//&ratio_in_desc&/$ratio_tlfbits} 26 | $failed_to_get_des" 27 | fi 28 | #-------------------------------------# 29 | # 0day分类 30 | tlfbits_type='423' 31 | #-------------------------------------# 32 | # 类型 33 | tlfbits_source='14' 34 | # 分辨率 35 | tlfbits_standard='0' 36 | # 副标题 37 | tlfbits_small_descr="$chinese_title $chs_included" 38 | } 39 | #-------------------------------------# 40 | 41 | #---类型---# 42 | # 0 请选择 43 | # 426 TLF-MiniSD 44 | # 432 TLF-Fayea 45 | # 436 TLF-iNT 46 | # 411 Movie/XviD 47 | # 430 Movie/X264 48 | # 415 TV/XviD 49 | # 413 TV/DVDRip 50 | # 414 TV/x264 51 | # 416 Game/PC 52 | # 417 Game/PS2 53 | # 418 Game/PS3 54 | # 419 Game/PSP 55 | # 420 Game/WII 56 | # 421 Game/Xbox360 57 | # 429 Game/Archive 58 | # 422 APPS 59 | # 423 0day 60 | # 428 0DAY/Archive 61 | # 424 MP3 62 | # 425 MVID 63 | # 435 Lossless 64 | # 427 MISC 65 | # 437 Unknown# 66 | #---质量 类型---# 67 | # name="source_sel" 68 | # 0 请选择 69 | # 1 剧情文艺 70 | # 3 喜剧爱情 71 | # 4 动画魔幻 72 | # 5 科幻探险 73 | # 7 动作战争 74 | # 8 罪案悬疑 75 | # 9 恐怖灾难 76 | # 10 纪录 77 | # 11 剧集 78 | # 12 音乐 79 | # 13 游戏 80 | # 15 软件 81 | # 14 其他# 82 | #---分辨率---# 83 | # name="standard_sel"> 84 | # 0 请选择 85 | # 1 1080p 86 | # 2 1080i 87 | # 3 720p 88 | # 4 SD 89 | # 5 Blu-ray/HD DVD# 90 | # 91 | #-------------------------------------# 92 | tlfbits_post_func() { 93 | gen_tlfbits_parameter 94 | #---post data---# 95 | t_id="$(http --verify=no --ignore-stdin -f --print=h POST "$postUrl"\ 96 | 'name'="$dot_name"\ 97 | 'small_descr'="$tlfbits_small_descr"\ 98 | 'descr'="$tlfbits_des"\ 99 | 'type'="$tlfbits_type"\ 100 | 'source_sel'="$tlfbits_source"\ 101 | 'standard_sel'="$tlfbits_standard"\ 102 | 'uplver'="$anonymous_tlfbits"\ 103 | file@"${torrent_Path}"\ 104 | "$cookie_tlfbits"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 105 | 106 | if [[ -z "$t_id" ]]; then 107 | # 辅种 108 | reseed_torrent 109 | fi 110 | } 111 | 112 | #-------------------------------------# 113 | -------------------------------------------------------------------------------- /post/whu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: post/whu.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-02-21 7 | # 8 | #-------------settings---------------# 9 | cookie="$cookie_whu" 10 | passkey="$passkey_whu" 11 | anonymous="$anonymous_whu" 12 | ratio_set=$ratio_whu 13 | to_client="$client_whu" 14 | #---static---# 15 | postUrl="${post_site[whu]}/takeupload.php" 16 | editUrl="${post_site[whu]}/takeedit.php" 17 | downloadUrl="${post_site[whu]}/download.php?id=" 18 | #-------------------------------------# 19 | gen_whu_parameter() { 20 | 21 | if [[ -s "$source_desc" ]]; then 22 | whu_des="${descrCom_complex//&ratio_in_desc&/$ratio_whu} 23 | $(sed '/&shc_name_douban&/d;/&eng_name_douban&/d' "$source_desc")" 24 | else 25 | whu_des="${descrCom_complex//&ratio_in_desc&/$ratio_whu} 26 | $failed_to_get_des" 27 | fi 28 | 29 | #-------------------------------------# 30 | # 判断类型,纪录片、电影、剧集、动漫 31 | if [[ $documentary = yes ]]; then 32 | # 纪录片 33 | whu_type='404' 34 | elif [[ $theater = yes ]]; then 35 | # 动漫 剧场版 36 | whu_type='428' #剧场版 37 | elif [[ $serials = yes ]]; then 38 | # 剧集 39 | case "$region" in 40 | *中国大陆*) 41 | whu_type='402' ;; 42 | *香港*|*台湾*|*澳门*) 43 | whu_type='417' ;; 44 | *日本*|*韩国*|*印度*|*新加坡*|*泰国*|*菲律宾*) 45 | whu_type='416' ;; 46 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*|*瑞典*|*芬兰*|*爱尔兰*|*阿联酋*|*土耳其*|*意大利*) 47 | whu_type='418' ;; 48 | *) 49 | whu_type='409' ;; 50 | esac 51 | [[ $animation = yes ]] && whu_type='427' #连载动画 52 | else 53 | # 电影 54 | case "$region" in 55 | *中国大陆*) 56 | whu_type='401' ;; 57 | *香港*|*台湾*|*澳门*) 58 | whu_type='413' ;; 59 | *日本*|*韩国*|*印度*|*新加坡*|*泰国*|*菲律宾*) 60 | whu_type='414' ;; 61 | *美国*|*英国*|*德国*|*法国*|*墨西哥*|*俄罗斯*|*西班牙*|*加拿大*|*澳大利亚*|*瑞典*|*芬兰*|*爱尔兰*|*阿联酋*|*土耳其*|*意大利*) 62 | whu_type='415' ;; 63 | *) 64 | whu_type='409' ;; 65 | esac 66 | fi 67 | 68 | #-------------------------------------# 69 | # 设置分辨率 70 | if [ "$is_ipad" = 'yes' ]; then 71 | # 移动视频 72 | whu_stardand='9' 73 | else 74 | if [ "$is_4k" = 'yes' ]; then 75 | whu_stardand='10' 76 | elif [ "$is_1080p" = 'yes' ]; then 77 | whu_stardand='1' 78 | elif [ "$is_1080i" = 'yes' ]; then 79 | whu_stardand='2' 80 | elif [ "$is_720p" = 'yes' ]; then 81 | whu_stardand='3' 82 | else 83 | whu_stardand='0' 84 | fi 85 | fi 86 | #-------------------------------------# 87 | # 副标题 88 | whu_small_descr="$chinese_title $chs_included" 89 | } 90 | 91 | #-------------------------------------# 92 | # file -> 种子文件(*),dl-url -> 网盘下载 93 | # type -> 类型(*) ,name -> 主标题(0day 不要点*) 94 | # small_descr -> 副标题 95 | # url -> imdb链接,url_douban -> 豆瓣链接(没有 imdb 才使用) 96 | # nfo -> nfo 文件,descr -> 简介(*) 97 | # standard_sel -> 分辨率,uplver -> 匿名上传('yes') 98 | # noshoutbox -> 通知('yes') 99 | #---类型---# 100 | # 401 大陆电影 101 | # 413 港台电影 102 | # 414 亚洲电影 103 | # 415 欧美电影 104 | # 402 大陆剧集 105 | # 417 港台剧集 106 | # 416 亚洲剧集 107 | # 418 欧美剧集 108 | # 404 纪录片 109 | # 407 体育 110 | # 403 大陆综艺 111 | # 419 港台综艺 112 | # 420 亚洲综艺 113 | # 421 欧美综艺 114 | # 408 华语音乐 115 | # 422 日韩音乐 116 | # 423 欧美音乐 117 | # 424 古典音乐 118 | # 425 原声音乐 119 | # 406 音乐MV 120 | # 405 完结动漫 121 | # 427 连载动漫 122 | # 428 剧场OVA 123 | # 429 动漫周边 124 | # 410 游戏 125 | # 411 软件 126 | # 412 学习 127 | # 430 武汉大学 128 | # 409 其他 129 | #---分辨率---# 130 | # 0 请选择 131 | # 10 4K 132 | # 1 1080p 133 | # 2 1080i 134 | # 3 720p 135 | # 9 移动视频 136 | # 4 标清 137 | # 5 无损音乐 138 | # 6 有损音乐 139 | 140 | #-------------------------------------# 141 | whu_post_func() { 142 | gen_whu_parameter 143 | #---post data---# 144 | t_id="$(http --verify=no --ignore-stdin -f --print=h --timeout=10 POST "$postUrl"\ 145 | 'name'="$noDot_name"\ 146 | 'small_descr'="$whu_small_descr"\ 147 | 'url'="$imdb_url"\ 148 | 'url_douban'="$( [ ! "$imdb_url" ] && echo "$douban_url" || echo '11')"\ 149 | 'descr'="$whu_des"\ 150 | 'type'="$whu_type"\ 151 | 'standard_sel'="$whu_stardand"\ 152 | 'uplver'="$anonymous_whu"\ 153 | file@"${torrent_Path}"\ 154 | "$cookie_whu"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 155 | 156 | if [[ -z "$t_id" ]]; then 157 | # 辅种 158 | t_id="$(http --verify=no --ignore-stdin -f -b --timeout=10 POST "$postUrl"\ 159 | name="$noDot_name"\ 160 | small_descr="$whu_small_descr"\ 161 | url="$imdb_url"\ 162 | url_douban="$( [ ! "$imdb_url" ] && echo "$douban_url")"\ 163 | descr="$whu_des"\ 164 | type="$whu_type"\ 165 | standard_sel="$whu_stardand"\ 166 | uplver="$anonymous_whu"\ 167 | file@"${torrent_Path}"\ 168 | "$cookie_whu"|grep -om1 '[^a-z]detail[^;"]*id=[0-9]*'|grep -om1 '[0-9]*')" 169 | fi 170 | } 171 | 172 | #-------------------------------------# 173 | 174 | -------------------------------------------------------------------------------- /post/xseed: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | # Copyright (C) 2010 SuperSnout 4 | 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 18 | # MA 02110-1301, USA. 19 | 20 | # Modifies .torrent files 21 | 22 | 23 | # Use raw_input if we're still using python 2 24 | try: 25 | input = raw_input 26 | except NameError: 27 | pass 28 | 29 | 30 | import argparse 31 | from bencode import bencode, bdecode 32 | import os 33 | import string 34 | import random 35 | 36 | parser = argparse.ArgumentParser() 37 | 38 | parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="switch on verbose mode") 39 | parser.add_argument("-e", "--edit-in-place", action="store_true", dest="replace", help="overwrite files without prompting") 40 | parser.add_argument("-o", "--output", dest="outfile", help="specify output filename. (can not be used if multiple files are given)") 41 | parser.add_argument("-d", "--directory", dest="path", help="specify a directory to save output to") 42 | parser.add_argument("-a", "--announce", dest="url", help="replace announce-url with the one specified") 43 | parser.add_argument("-p", "--private", action="store_true", dest="private", help="make torrent private") 44 | parser.add_argument("-n", "--no-cross-seed", action="store_false", dest="cross", default=True, help="do not randomize info hashes") 45 | parser.add_argument("-c", "--comment", dest="comment", help="replace comment with the one specified") 46 | parser.add_argument("files", nargs='+', help='files to be modified') 47 | 48 | args = parser.parse_args() 49 | 50 | 51 | def random_string(n): 52 | """Generate a random string of length n""" 53 | 54 | return ''.join(random.choice(string.ascii_letters + string.digits) for i in range(n)) 55 | 56 | 57 | def change_announce(torrent_dict, url): 58 | """Change announce url.""" 59 | 60 | torrent_dict['announce'] = url 61 | verbose("announce url changed to '%s'" % url) 62 | 63 | if 'announce-list' in torrent_dict: 64 | del torrent_dict['announce-list'] 65 | verbose("removed all multitracker announce urls") 66 | 67 | return torrent_dict 68 | 69 | 70 | def change_comment(torrent_dict, comment): 71 | """Change comment.""" 72 | 73 | if not comment: 74 | if 'comment' in torrent_dict: 75 | del torrent_dict['comment'] 76 | verbose('removed comment') 77 | else: 78 | torrent_dict['comment'] = comment 79 | verbose("comment changed to '%s'" % comment) 80 | 81 | return torrent_dict 82 | 83 | 84 | def make_unique(torrent_dict): 85 | """Add random string to info torrent_dict.""" 86 | 87 | torrent_dict['info']['unique'] = uniquestr = random_string(32) 88 | verbose("random string '%s' added to info torrent_dict" % uniquestr) 89 | return torrent_dict 90 | 91 | 92 | def verbose(msg): 93 | if args.verbose: 94 | print(msg) 95 | 96 | 97 | def read_bencode(stream): 98 | """ Decode a file to an object.""" 99 | 100 | with open(stream, "rb") as handle: 101 | torrent_dict = bdecode(handle.read()) 102 | 103 | if torrent_dict: 104 | verbose("dict read from '%s'" % stream) 105 | 106 | return torrent_dict 107 | 108 | 109 | def write_bencode(stream, obj): 110 | """ Encode a given object to a file.""" 111 | 112 | with open(stream, "wb") as handle: 113 | handle.write(bencode(obj)) 114 | 115 | verbose("modified dict written to '%s'" % stream) 116 | 117 | 118 | def confirm(prompt, resp=False): 119 | """prompts for yes or no response from the user. Returns True for yes and 120 | False for no. 121 | 122 | 'resp' should be set to the default value assumed by the caller when 123 | user simply types ENTER. 124 | 125 | >>> confirm(prompt='Create Directory?', resp=True) 126 | Create Directory? Y/n: 127 | True 128 | >>> confirm(prompt='Create Directory?', resp=False) 129 | Create Directory? y/N: 130 | False 131 | >>> confirm(prompt='Create Directory?', resp=False) 132 | Create Directory? y/N: y 133 | True 134 | 135 | """ 136 | 137 | if resp: 138 | prompt = '%s Y/n: ' % prompt 139 | else: 140 | prompt = '%s y/N: ' % prompt 141 | 142 | while True: 143 | ans = input(prompt) 144 | if not ans: 145 | return resp 146 | if ans not in ['y', 'Y', 'n', 'N']: 147 | print('please enter y or n.') 148 | continue 149 | if ans == 'y' or ans == 'Y': 150 | return True 151 | if ans == 'n' or ans == 'N': 152 | return False 153 | 154 | 155 | if len(args.files) > 1 and args.outfile: 156 | parser.error("output filename specified but multiple files given") 157 | 158 | for infile in args.files: 159 | torrent_dict = read_bencode(infile) 160 | if args.cross: 161 | torrent_dict = make_unique(torrent_dict) 162 | if args.url: 163 | torrent_dict = change_announce(torrent_dict, args.url) 164 | if args.comment is not None: 165 | torrent_dict = change_comment(torrent_dict, args.comment) 166 | if args.private: 167 | torrent_dict['info']['private'] = 1 168 | verbose("private set to 1") 169 | if args.path and args.outfile: 170 | stream = args.path + args.outfile 171 | if not os.path.exists(args.path): 172 | os.makedirs(args.path) 173 | elif args.path: 174 | stream = args.path + infile 175 | if not os.path.exists(args.path): 176 | os.makedirs(args.path) 177 | elif args.outfile: 178 | stream = args.outfile 179 | else: 180 | stream = infile 181 | if args.replace: 182 | write_bencode(stream, torrent_dict) 183 | elif os.path.exists(stream) or stream == infile: 184 | choice = confirm("%s already exists. Overwrite?" % stream, True) 185 | if choice is not True: 186 | continue 187 | else: 188 | write_bencode(stream, torrent_dict) 189 | else: 190 | write_bencode(stream, torrent_dict) 191 | -------------------------------------------------------------------------------- /qbittorrent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: qbittorrent.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2020-01-10 7 | # 8 | #--------------------------------------# 9 | qb_login="${qb_HOST}:$qb_PORT/api/v2/auth/login" 10 | qb_add="${qb_HOST}:$qb_PORT/api/v2/torrents/add" 11 | qb_delete="${qb_HOST}:$qb_PORT/api/v2/torrents/delete" 12 | qb_ratio="${qb_HOST}:$qb_PORT/api/v2/torrents/setShareLimits" 13 | qb_lists="${qb_HOST}:$qb_PORT/api/v2/torrents/info" 14 | qb_reans="${qb_HOST}:$qb_PORT/api/v2/torrents/reannounce" 15 | qb_addTker="${qb_HOST}:$qb_PORT/api/v2/torrents/addTrackers" 16 | #--------------------------------------# 17 | qbit_webui_cookie() { 18 | if [ "$(http --ignore-stdin -b GET "${qb_HOST}:$qb_PORT" "$qb_Cookie"| \ 19 | grep 'id="username"')" ]; then 20 | qb_Cookie="cookie:$(http --ignore-stdin -hf POST "$qb_login" \ 21 | username="$qb_USER" password="$qb_PASSWORD"| \ 22 | sed -En '/set-cookie:/{s/.*(SID=[^;]+).*/\1/i;p;q}')" 23 | # 更新 qb cookie 24 | if [ "$qb_Cookie" ]; then 25 | sed -i "s/^qb_Cookie=.*/qb_Cookie=\'$qb_Cookie\'/" "$ROOT_PATH/settings.sh" 26 | else 27 | debug_func 'qb:failed-to-get-cookie' #----debug--- 28 | fi 29 | debug_func 'qb:update-cookie' #----debug--- 30 | fi 31 | } 32 | 33 | #--------------------------------------# 34 | qb_reannounce() { 35 | if [[ $qb_USER ]]; then 36 | qbit_webui_cookie 37 | http --ignore-stdin -f POST "$qb_reans" hashes=all "$qb_Cookie" 38 | fi 39 | } 40 | #--------------------------------------# 41 | qb_delete_torrent() { 42 | qbit_webui_cookie 43 | # delete torrent, need a parameter; used in clean/qb.sh 44 | http --ignore-stdin -f POST "$qb_delete" hashes="$1" \ 45 | deleteFiles=false "$qb_Cookie" 46 | debug_func "qb:del:[$1]" #----debug--- 47 | } 48 | 49 | #---------------------------------------# 50 | qb_set_ratio_queue() { 51 | local add_site_tracker 52 | for site in ${!post_site[*]}; do 53 | [[ "$postUrl" =~ ${post_site[$site]}.* ]] && { 54 | add_site_tracker="${trackers[$site]}" 55 | break; } 56 | done 57 | 58 | debug_func "qb:set-ratio-queue[$site]" #----debug--- 59 | echo -e "${org_tr_name}\n${add_site_tracker}\n${ratio_set}" >> \ 60 | "${qb_rt_queue}-$index" 61 | # say thanks 62 | [[ $Allow_Say_Thanks == yes ]] && \ 63 | [[ "$(eval echo '$'"say_thanks_$site")" == yes ]] && \ 64 | if http --verify=no --ignore-stdin -h -f POST "${post_site[$site]}/thanks.php" \ 65 | id="$t_id" "$(eval echo '$'"cookie_$site")" "$user_agent" &> /dev/null; then 66 | debug_func "qb:set-ratio-say-thanks-[$site]" #----debug--- 67 | else 68 | case $? in 69 | 2) debug_func 'qbit[thx]:Request timed out!' ;; 70 | 3) debug_func 'qbit[thx]:Unexpected HTTP 3xx Redirection!' ;; 71 | 4) debug_func 'qbit[thx]:HTTP 4xx Client Error!' ;; 72 | 5) debug_func 'qbit[thx]:HTTP 5xx Server Error!' ;; 73 | 6) debug_func 'qbit[thx]:Exceeded --max-redirects= redirects!' ;; 74 | *) debug_func 'qbit[thx]:Other Error!' ;; 75 | esac 76 | curl -k -b "`eval echo '$'"cookie_$site"|sed -E 's/^cookie:[ ]?//i'`" -X POST \ 77 | -F "id=$t_id" -A "`echo "$user_agent"|sed -E 's/^User-Agent:[ ]?//i'`" \ 78 | "${post_site[$site]}/thanks.php" && debug_func 'qbit:used-curl-say-thanks' 79 | fi 80 | 81 | unset site 82 | } 83 | 84 | #---------------------------------------# 85 | qb_get_hash() { 86 | # $1 name; $2 tracker; $3 qb info lists; return hash(echo), used in qb_set_ratio_loop 87 | local _hash _one _pos 88 | echo "$3"|sed -n "/name.*$1/="|while read _pos; do 89 | _hash="$(echo "$3"|sed -n "$((_pos - 1)) {s/hash: *//;p}")" 90 | _one="$(echo "$3"|sed -n "$((_pos + 1)) {s/tracker: *//;s/passkey=.*//;p}")" 91 | [[ "$(echo "$_one"|grep "$2")" ]] && echo "$_hash" && break 92 | done 93 | } 94 | 95 | #---------------------------------------# 96 | qb_set_ratio_loop() { 97 | [[ -f "${qb_rt_queue}-1" ]] && { 98 | local tmp f 99 | for f in "${qb_rt_queue}-"[0-9]*;do tmp="${tmp}$(< "$f")\n";done 100 | printf '%b' "$tmp" > "$qb_rt_queue" 101 | unset tmp f 102 | #\cat "${qb_rt_queue}-"[0-9]* > "$qb_rt_queue" 103 | \rm -f "${qb_rt_queue}-"[0-9]* ; } 104 | if [ -s "$qb_rt_queue" ]; then 105 | local data qb_lp_counter trker rtio tr_hash 106 | sleep 20 # 延时 107 | qbit_webui_cookie 108 | data="$(http --ignore-stdin --pretty=format -f POST "$qb_lists" sort=added_on reverse=true \ 109 | "$qb_Cookie"|sed -E '/^[ ]*[},]+$/d;s/^[ ]+//;s/[ ]+[{]+//;s/[},]+//g'| \ 110 | grep -B18 -A19 'name":'|sed -E \ 111 | '/"hash":/{s/"//g};/"name":/{s/"//g};/"tracker":/{s/"//g};'|sed '/"/d')" 112 | qb_lp_counter=0 113 | while true; do 114 | name="$(head -1 "$qb_rt_queue")" # line one 115 | [[ ! $name ]] && break # jump out 116 | [[ $qb_lp_counter -gt 50 ]] && break # jump out 117 | trker="$(head -2 "$qb_rt_queue"|tail -1)" # line second 118 | rtio="$(head -3 "$qb_rt_queue"|tail -1)" # line third 119 | tr_hash="$(qb_get_hash "$name" "$trker" "$data")" # get hash 120 | # 设置qbit 做种时间以及做种分享率,一天1440分钟,qbt时间分钟 121 | [ "${#tr_hash}" -eq 40 ] && debug_func "find[$tr_hash]" && \ 122 | if http --ignore-stdin -f POST "$qb_ratio" hashes="$tr_hash" \ 123 | ratioLimit=$rtio seedingTimeLimit="$(echo "$MAX_SEED_TIME * 1440"|bc)" \ 124 | "$qb_Cookie" &> /dev/null; then 125 | # mteam 添加 ipv6 tracker 链接 126 | [[ $trker = ${trackers[mt]} ]] && { 127 | local mt_ipv6 128 | sleep 10 129 | mt_ipv6="https://ipv6.${post_site[mt]##*//}/announce.php?passkey=$passkey_mt" 130 | http -If POST "$qb_addTker" hash="$tr_hash" urls="$mt_ipv6" "$qb_Cookie" 131 | } 132 | debug_func "qb:sussess_set_rt[$trker]" #----debug--- 133 | else 134 | case $? in 135 | 2) debug_func 'qbit[rtio]:Request timed out!' ;; 136 | 3) debug_func 'qbit[rtio]:Unexpected HTTP 3xx Redirection!' ;; 137 | 4) debug_func 'qbit[rtio]:HTTP 4xx Client Error!' ;; 138 | 5) debug_func 'qbit[rtio]:HTTP 5xx Server Error!' ;; 139 | 6) debug_func 'qbit[rtio]:Exceeded --max-redirects= redirects!' ;; 140 | *) debug_func 'qbit[rtio]:Other Error!' ;; 141 | esac 142 | curl -k -b "`echo "$qb_Cookie"|sed -E 's/^cookie:[ ]?//i'`" -X POST \ 143 | -F "hashes=$tr_hash" -F "ratioLimit=$rtio" \ 144 | -F "seedingTimeLimit=$(echo "$MAX_SEED_TIME * 1440"|bc)" \ 145 | "$qb_ratio" && debug_func "qb:sussess_set_rt-curl[$trker]" 146 | fi 147 | sed -i '1,3d' "$qb_rt_queue" # delete record 148 | ((qb_lp_counter++)) # C 形式的增1 149 | done 150 | debug_func 'main:exit\n' #----debug--- 151 | fi 152 | } 153 | 154 | #---------------------------------------# 155 | qb_add_torrent_url() { 156 | sleep 2 157 | qbit_webui_cookie 158 | # add url 159 | debug_func 'qb:add-from-url' #----debug--- 160 | if http --ignore-stdin -f POST "$qb_add" urls="$torrent2add" root_folder=true \ 161 | savepath="$one_TR_Dir" skip_checking=true "$qb_Cookie" &> /dev/null; then 162 | echo 'qbit添加种子成功' 163 | debug_func 'qbit:添加种子成功' #----debug--- 164 | else 165 | case $? in 166 | 2) debug_func 'qbit:Request timed out!' ;; 167 | 3) debug_func 'qbit:Unexpected HTTP 3xx Redirection!' ;; 168 | 4) debug_func 'qbit:HTTP 4xx Client Error!' ;; 169 | 5) debug_func 'qbit:HTTP 5xx Server Error!' ;; 170 | 6) debug_func 'qbit:Exceeded --max-redirects= redirects!' ;; 171 | *) debug_func 'qbit:Other Error!' ;; 172 | esac 173 | echo 'qbit添加种子失败' 174 | sleep 5 175 | debug_func "urls=${torrent2add/passkey*/} path=$one_TR_Dir $qb_Cookie" 176 | curl -k -b "`echo "$qb_Cookie"|sed -E 's/^cookie:[ ]?//i'`" -X POST \ 177 | -F "urls=$torrent2add" -F 'root_folder=true' -F "savepath=$one_TR_Dir" \ 178 | -F 'skip_checking=true' "$qb_add" && debug_func 'qbit:used-curl-POST' 179 | fi 180 | 181 | sleep 12 # 保证tracker字段值 182 | qb_set_ratio_queue 183 | } 184 | #---------------------------------------# 185 | qb_add_torrent_file() { 186 | sleep 2 187 | qbit_webui_cookie 188 | # add file 189 | debug_func 'qb:add-from-file' #----debug--- 190 | http --ignore-stdin -f POST "$qb_add" skip_checking=true root_folder=true \ 191 | name@"${ROOT_PATH}/tmp/${t_id}.torrent" savepath="$one_TR_Dir" "$qb_Cookie" 192 | # ----> ok 193 | # curl 194 | # curl -k -b "`echo "$qb_Cookie"|sed -E 's/^cookie:[ ]?//i'`" -X POST -F 'root_folder=true' \ 195 | # -F "name=@$${ROOT_PATH}/tmp/${t_id}.torrent" -F "savepath=$one_TR_Dir" \ 196 | # -F 'skip_checking=true' "$qb_add" && debug_func 'qbit:used-curl-POST' 197 | sleep 12 198 | qb_set_ratio_queue 199 | } 200 | 201 | #---------------------------------------# 202 | # call in main.sh 203 | qb_get_torrent_completion() { 204 | qbit_webui_cookie 205 | # need a parameter 206 | local data pos compl_one size_one 207 | data="$(http --ignore-stdin --pretty=format -f POST "$qb_lists" sort=added_on reverse=true \ 208 | "$qb_Cookie"|sed -E '/^[ ]*[},]+$/d;s/^[ ]+//;s/[ ]+[{]+//;s/[},]+//g'| \ 209 | grep -B17 -A15 'name":'|sed -E \ 210 | '/"completed":/{s/"//g};/"name":/{s/"//g};/"save_path":/{s/"//g};/"size":/{s/"//g};'|sed '/"/d')" 211 | # match the torrent recently added. 212 | pos=$(echo "$data"|sed -n "/name.*$org_tr_name/{=;q}") 213 | [[ $pos =~ [0-9]+ ]] && { 214 | compl_one="$(echo "$data"|sed -n "$((pos - 1)) p"|grep -Eo '[0-9]{4,}')" 215 | size_one="$(echo "$data"|sed -n "$((pos + 2)) p"|grep -Eo '[0-9]{4,}')" 216 | # one_TR_Dir is not local variable 217 | one_TR_Dir="$(echo "$data"|sed -n "$((pos + 1)) p"|grep -o '/.*$')"; 218 | } || { 219 | debug_func "qbit:completion-pos[$pos]" #----debug--- 220 | } 221 | # return completed precent 222 | [[ $compl_one && $size_one ]] && \ 223 | completion=$(awk -v a="$compl_one" -v b="$size_one" 'BEGIN{printf "%d",(a/b)*100}') 224 | unset data compl_one size_one pos 225 | #debug_func 'qb:complete-func' #----debug--- 226 | } 227 | #---------------------------------------# 228 | 229 | -------------------------------------------------------------------------------- /settings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: settings.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-12-21 7 | # 8 | # Environmental requirements: 9 | # - transmission-[remote,daemon or gtk] or qbittorrent 10 | # - transmission-edit and transmission-show 11 | # - httpie, awk, sed, find, grep, 12 | # - sort, tail, head, stat, python3 13 | # - base64, iconv, mediainfo 14 | # 15 | #---------------[caption]--------------# 16 | # usually, value can set 'yes' or 'no' 17 | # path should use absolutely one and no slash end best 18 | #----------------[main]----------------# 19 | # you can use source to import this file to test each func 20 | [[ ! $ROOT_PATH ]] && \ 21 | ROOT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 22 | #---use 'yes' to disable all---# 23 | Disable_AutoSeed='no' 24 | # change this value to change delay 25 | Speed=0.6 26 | # set 'yes' allow say thanks 27 | Allow_Say_Thanks='yes' 28 | # no headers 29 | No_Headers='yes' 30 | # set 'yes', will uselocal python gen while web method failed 31 | Use_Local_Gen='yes' 32 | # 33 | #---torrent file path---# 34 | flexget_path="/home/rachpt/Downloads/tmp" 35 | #---transmission or qbittorrent---# 36 | fg_client='transmission' # download source torrent 37 | # 38 | # data folder 39 | # for find nfo file in get_desc/info.sh 40 | default_FILE_PATH='/mnt' 41 | # 42 | #----------------[clean]---------------# 43 | # Do not delete for some time after the modification, 44 | # unit seconds, default 2 days(172800 s). 45 | TimeINTERVAL=172800 46 | # 47 | # The minimum allowed disk (G). 48 | DISK_AVAIL_MIN=20 49 | # Over this time, torrent will be deleted (unit day). 50 | # It will NOT delete data. 51 | MAX_SEED_TIME=10 52 | # 53 | #-------------[post site]--------------# 54 | ##===################################### 55 | #---[hudbt]---# 56 | enable_hudbt='yes' 57 | say_thanks_hudbt='yes' 58 | # 59 | client_hudbt='transmission' 60 | anonymous_hudbt='no' 61 | #---ratio of uploaded torrent---# 62 | ratio_hudbt='4' 63 | cookie_hudbt='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 64 | #---your passkey---# 65 | passkey_hudbt='1234567890987654321123423442' 66 | #####===################################ 67 | #---[whu]---# 68 | enable_whu='yes' 69 | say_thanks_whu='yes' 70 | client_whu='transmission' 71 | # 72 | anonymous_whu='yes' 73 | #---ratio of uploaded torrent---# 74 | ratio_whu='4' 75 | cookie_whu='Cookie:c_secure_uid=XXXXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==; c_session_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 76 | #---your passkey---# 77 | passkey_whu='12345678909876543211123456789987' 78 | ########===############################# 79 | #---[npupt]---# 80 | enable_npupt='yes' 81 | say_thanks_npupt='yes' # not work 82 | client_npupt='qbittorrent' 83 | # 84 | anonymous_npupt='yes' 85 | #---ratio of uploaded torrent---# 86 | ratio_npupt='4' 87 | cookie_npupt='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 88 | #---your passkey---# 89 | passkey_npupt='12345678909876543211234567887' 90 | ###########===########################## 91 | #---[nanyangpt]---# 92 | enable_nanyangpt='yes' 93 | say_thanks_nanyangpt='yes' 94 | client_nanyangpt='qbittorrent' 95 | # 96 | anonymous_nanyangpt='yes' 97 | #---ratio of uploaded torrent---# 98 | ratio_nanyangpt='4' 99 | cookie_nanyangpt='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 100 | #---your passkey---# 101 | passkey_nanyangpt='12345678909876543212345654' 102 | ##############===####################### 103 | #---[byrbt]---# 104 | enable_byrbt='yes' 105 | say_thanks_byrbt='yes' 106 | client_byrbt='qbittorrent' 107 | #---use 'yes' delete screens img---# 108 | just_poster_byrbt='yes' 109 | anonymous_byrbt='yes' 110 | #---ratio of uploaded torrent---# 111 | ratio_byrbt='4' 112 | cookie_byrbt='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 113 | #---your passkey---# 114 | passkey_byrbt='12345678909876543212345654' 115 | #################===#################### 116 | #---[cmct]---# 117 | enable_cmct='no' 118 | say_thanks_cmct='yes' 119 | client_cmct='qbittorrent' 120 | # 121 | anonymous_cmct='yes' 122 | #---ratio of uploaded torrent---# 123 | ratio_cmct='4' 124 | cookie_cmct='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 125 | #---your passkey---# 126 | passkey_cmct='12345678909876543212345654' 127 | #######################===############## 128 | #---[mt]---# 129 | enable_mt='yes' 130 | say_thanks_mt='no' 131 | header_mt='no' 132 | client_mt='qbittorrent' 133 | #---delete screens img---# 134 | # 135 | anonymous_mt='yes' 136 | #---ratio of uploaded torrent---# 137 | ratio_mt='5' 138 | cookie_mt='Cookie:tp=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==' 139 | #---your passkey---# 140 | passkey_mt='12345678909876543212345654' 141 | ###########################===########## 142 | #---[tjupt]---# 143 | enable_tjupt='yes' 144 | say_thanks_tjupt='yes' 145 | client_tjupt='qbittorrent' 146 | #---use 'yes' delete screens img---# 147 | just_poster_tjupt='yes' 148 | anonymous_tjupt='yes' 149 | #---ratio of uploaded torrent---# 150 | ratio_tjupt='4' 151 | cookie_tjupt='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 152 | #---your passkey---# 153 | passkey_tjupt='12345678909876543212345654' 154 | ##############################===####### 155 | #---[neu6]---# 156 | enable_neu6='no' 157 | say_thanks_neu6='yes' 158 | client_neu6='qbittorrent' 159 | #---use 'yes' delete screens img---# 160 | just_poster_neu6='yes' 161 | anonymous_tjupt='yes' 162 | #---ratio of uploaded torrent---# 163 | ratio_neu6='4' 164 | cookie_neu6='Cookie: LRpW_2132_saltkey=xxx; LRpW_2132_auth=xxxxxxx' 165 | #---your passkey---# 166 | passkey_neu6='12345678909876543212345654' 167 | 168 | #################################===#### 169 | #---[tlfbits]---# 170 | enable_tlfbits='no' 171 | say_thanks_tlfbits='no' 172 | client_tlfbits='qbittorrent' 173 | anonymous_tlfbits='yes' 174 | [[ $enable_tlfbits == 'yes' ]] && only_tlfbits='yes' 175 | #---ratio of uploaded torrent---# 176 | ratio_tlfbits='4' 177 | cookie_tlfbits='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 178 | #---your passkey---# 179 | passkey_tlfbits='12345678909876543212345654' 180 | ###################################===## 181 | #------------[transmission]------------# 182 | #---authoriz for transmission---# 183 | tr_HOST='127.0.0.1' 184 | tr_PORT='9091' 185 | tr_USER='tr-username' 186 | tr_PASSWORD='tr-passkey' 187 | #-------------[qbittorrent]------------# 188 | #---authoriz for qbittorrent---# 189 | qb_HOST='http://127.0.0.1' 190 | qb_PORT='8080' 191 | qb_USER='qbit-username' 192 | qb_PASSWORD='qbit-passkey' 193 | qb_Cookie='cookie:SID=xxx' 194 | #----------------[site]----------------# 195 | #---cookie for source site---# 196 | cookie_hds='Cookie:c_secure_uid=XXXXXX; c_secure_pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx; c_secure_login=bm9wZQ==' 197 | ratio_hds='2' # just for fg_client='qbittorrent' case 198 | # 199 | cookie_ttg='Cookie:uid=000000; pass=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; PHPSESSID=xxxxxxxxxxxxxxxxxxxxxxxxx' 200 | ratio_ttg='2' # just for fg_client='qbittorrent' case 201 | # 202 | cookie_hdc='Cookie:mv_secure_uid=xxxx; mv_secure_pass=xxx;hdchina=xxx;PHPSESSID=xxx;mv_secure_login=bm9wZQ==' 203 | ratio_hdc='2' # just for fg_client='qbittorrent' case 204 | # 205 | #-----------------[EOF]----------------# 206 | 207 | -------------------------------------------------------------------------------- /static.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: static.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2020-01-09 7 | # 8 | # This file defines constants and functions 9 | #--------------------------------------# 10 | export LANGUAGE=en_US 11 | source "$ROOT_PATH/test.sh" 12 | #--log path (do not change)---# 13 | log_Path="$ROOT_PATH/tmp/log" 14 | #--log path (do not change)---# 15 | debug_Log="$ROOT_PATH/tmp/debug" 16 | #---lock path (do not change)---# 17 | lock_File="$ROOT_PATH/tmp/LOCK" 18 | #---queue path (do not change)---# 19 | queue="$ROOT_PATH/tmp/queue" 20 | quene_lock="$ROOT_PATH/tmp/queue-lock" 21 | #---for qbit (do not change)---# 22 | qb_rt_queue="$ROOT_PATH/tmp/qb-ratio-queue" 23 | # 24 | #--------------------------------------# 25 | #---path of transmission-show---# 26 | tr_show='transmission-show' 27 | tr_edit='transmission-edit' 28 | tr_remote='transmission-remote' 29 | #---path of python3---# 30 | python3='python3' 31 | #---path of mediainfo---# 32 | mediainfo='mediainfo' 33 | #---path of ffmpeg---# 34 | ffmpeg='ffmpeg' 35 | #---path of mtn---# 36 | mtn='mtn' 37 | #---path of dottorrent---# 38 | dottorrent='dottorrent' # example /home/rachpt/.local/bin/dottorrent 39 | #--- 40 | user_agent='User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0' 41 | #--------------------------------------# 42 | # 豆瓣 api 43 | db_api_1='https://api.rhilip.info/tool/movieinfo/gen' 44 | db_api_2='https://api.nas.ink/infogen' 45 | #--------------------------------------# 46 | # 图片上传 API 47 | upload_poster_api_0='https://sm.ms/api/v2/upload?inajax=1' 48 | upload_poster_api_1='https://i.endpot.com/api/upload' 49 | upload_poster_api_2='https://catbox.moe/user/api.php' 50 | upload_poster_api_3='https://apis.yum6.cn/api/5bd44dc94bcfc' #https://wiki.yum6.cn 51 | upload_poster_api_4='https://pic.xiaojianjian.net/webtools/picbed/upload.htm' 52 | upload_poster_api_5='http://upload.ouliu.net/' 53 | upload_poster_api_6='https://ooxx.ooo/upload' 54 | upload_poster_api_7='https://imgchr.com' # 路过图床,20/h 限制 55 | upload_poster_api_8='https://whoimg.com' # 无名图床 56 | upload_poster_api_9='https://upload.cc' 57 | upload_poster_api_10='https://imgbb.com' 58 | upload_poster_api_11='http://myjd.jd.com/afs/common/upload.action' # 京东图床 59 | byrbt_upload_api='https://bt.byr.cn/ckfinder/core/connector/php/connector.php' 60 | #-------------desc headers-------------# 61 | failed_to_get_des='[size=6][color=Magenta][em11] 获取简介失败!!![/color][/size]' 62 | set_desc_headers() { 63 | descrCom_simple="[quote] [b]这是一个自动发布的种子[/b] [em2] 64 | [*]所有信息以种子文件名为准,标题、简介信息仅供参考,若发现有误请以[举报]或[留言]的形式通知工作人员审查编辑。 65 | [*]最长保种[${MAX_SEED_TIME}]天,保种分享率[&ratio_in_desc&],断种恕不补种。 66 | [*]使用 Shell(bash) 脚本实现,开源在:[url=https://github.com/rachpt/AutoSeed]rachpt/AutoSeed[/url][em13],欢迎star。 67 | [/quote]" 68 | # 69 | ( [ "$enable_hudbt" = 'yes' ] || [ "$enable_whu" = 'yes' ] ) && \ 70 | descrCom_complex="[quote] 71 | [align=center][span style='inline-block:block;background-color:slateblue;padding:30px;border:dashed silver 1px;border-radius:px;box-shadow: 2px 2px 5px gray;width:100px;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap;margin:6em auto;'][b][color=White]这是一个自动发布的种子[/color][/b] [em57][/span] 72 | [/align] 73 | 74 | 75 | 76 | [span style='nline-block:block;background-color:pink;padding:10px;border:dashed silver 1px;border-radius:3px;box-shadow: 2px 2px 5px gray;width:110px;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap;margin:2em auto;'][b]所有信息以种子文件名为准,标题、简介信息仅供参考,若发现有误请以[举报]或[留言]的形式通知工作人员审查编辑。[/b] [/span] 77 | 78 | [span style='nline-block:block;background-color:greenyellow;padding:10px;border:dashed silver 1px;border-radius:3px;box-shadow: 2px 2px 5px gray;width:100px;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap;margin:2em auto;'][b]最长保种[${MAX_SEED_TIME}]天,保种分享率[&ratio_in_desc&],断种恕不补种。[/b] [/span] 79 | 80 | [span style='inline-block:block;background-color:steelblue;padding:10px;border:dashed silver 1px;border-radius:3px;box-shadow: 2px 2px 5px gray;width:110px;overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap;margin:2em auto;'][b]使用 Shell(bash) 脚本实现,开源在:[url=https://github.com/rachpt/AutoSeed]rachpt/AutoSeed[/url][em108],欢迎star。[/b] [/span] 81 | [/quote]" 82 | # 83 | [ "$enable_byrbt" = 'yes' ] && \ 84 | descrCom_complex_html="
    85 | 89 |


    90 | 所有信息以种子文件名为准,标题、简介信息仅供参考,若发现有误请以[举报]或[留言]的形式通知工作人员审查编辑。
    91 |
    92 | 最长保种[${MAX_SEED_TIME}]天,保种分享率[${ratio_byrbt}],断种恕不补种。
    93 |
    94 | 使用 Shell(bash) 脚本实现,开源在:rachpt/AutoSeed\"[em108]\",欢迎star。
    95 |
    96 |
    " 97 | } 98 | # 99 | #--------------------------------------# 100 | # declare -A 定义关联数组 类似字典键值对 101 | declare -A trackers 102 | declare -A post_site 103 | # 104 | trackers[hudbt]='hudbt.hust.edu.cn' 105 | post_site[hudbt]='https://hudbt.hust.edu.cn' 106 | trackers[whu]='tracker.whupt.net' 107 | post_site[whu]='https://whu.pt' 108 | trackers[npupt]='npupt.com' 109 | post_site[npupt]='https://npupt.com' 110 | trackers[nanyangpt]='tracker.nanyangpt.com' 111 | post_site[nanyangpt]='https://nanyangpt.com' 112 | trackers[byrbt]='tracker.byr.cn' 113 | post_site[byrbt]='https://bt.byr.cn' 114 | trackers[cmct]='on.springsunday.net' 115 | post_site[cmct]='https://springsunday.net' 116 | trackers[tjupt]='.tjupt.org' 117 | post_site[tjupt]='https://tjupt.org' 118 | trackers[tlfbits]='pt.eastgame.org' 119 | post_site[tlfbits]='https://pt.eastgame.org' 120 | #--------------------------------------# 121 | # source tracker url 122 | post_site[ttg]='https://totheglory.im' 123 | trackers[ttg]='tracker.totheglory.im' 124 | post_site[hdc]='https://hdchina.org' 125 | trackers[hdc]='tracker.hdchina.org' 126 | post_site[hds]='https://hdsky.me' 127 | trackers[hds]='tracker.hdsky.me' 128 | post_site[mt]='https://pt.m-team.cc' 129 | trackers[mt]='tracker.m-team.cc' 130 | #--------------------------------------# 131 | # import functions 132 | source "$ROOT_PATH/qbittorrent.sh" 133 | source "$ROOT_PATH/transmission.sh" 134 | # 135 | #--------------------------------------# 136 | # set client mode 137 | unset _site use_qbt use_trs # clean 138 | for _site in hudbt whu nanyangpt npupt byrbt mt cmct tjupt; do 139 | [[ "$(eval echo '$'enable_$_site)" = yes ]] && \ 140 | case $(eval echo '$'client_$_site) in 141 | qbittorrent) 142 | use_qbt='yes' ;; 143 | transmission) 144 | use_trs='yes' ;; 145 | esac 146 | done 147 | case "$fg_client" in 148 | qbittorrent) 149 | use_qbt='yes' ;; 150 | transmission) 151 | use_trs='yes' ;; 152 | esac 153 | unset _site # clean 154 | #--------------------------------------# 155 | # 普通 图片上传 156 | upload_image_com() { 157 | unset img_url_com # clean 158 | local _file="$1" # 参数:图片路径 159 | local _rand_=$((RANDOM % 12)) # choose an api randomly 160 | up_case_func() { 161 | case $_rand_ in 162 | 0) 163 | # https://sm.ms 164 | img_url_com="$(http --verify=no --timeout=25 --ignore-stdin -bf POST \ 165 | "$upload_poster_api_0" smfile@"$_file" "$user_agent"|grep -Eo \ 166 | "\"url\".{0,4}\"[^\"]+\""|awk -F "\"" '{print $4}'|sed 's/\\//g')" ;; 167 | 1) 168 | # https://i.endpot.com 169 | img_url_com="$(http --pretty=format --timeout=25 --ignore-stdin -bf POST \ 170 | --verify=no "$upload_poster_api_1" image@"$_file" "$user_agent"|grep -Eo \ 171 | "\"link\".{0,4}\"[^\"]+\""|awk -F "\"" '{print $4}'|sed 's/\\//g')" ;; 172 | 2) 173 | # https://catbox.moe 174 | img_url_com="$(http --verify=no --timeout=25 --ignore-stdin -bf POST \ 175 | "$upload_poster_api_2" fileToUpload@"$_file" reqtype='fileupload' \ 176 | "$user_agent"|grep -Eio 'http[:/a-z0-9\.]+'|sed 's/\\//g')" ;; 177 | 3) 178 | # sina 图床,YoungxjApis 179 | # 更多请看: https://www.youngxj.cn/565.html 180 | local _tok='f07b711396f9a05bc7129c4507fb65c5' 181 | img_url_com="$(http --verify=no --timeout=25 --ignore-stdin -bf POST \ 182 | "$upload_poster_api_3" "token==$_tok" file@"$_file" "$user_agent"| \ 183 | grep -Eio 'https?:[/\\a-z0-9\.]+'|sed 's/\\//g;s/cdn.sinaimg.cn.52ecy.cn/tva1.sinaimg.cn/')" ;; 184 | 4) 185 | # sina 图床, 小贱贱api: https://pic.xiaojianjian.net 186 | img_url_com="$(http --verify=no --timeout=25 --ignore-stdin -bf POST \ 187 | "$upload_poster_api_4" file@"$_file" "$user_agent"|grep -Eio \ 188 | 'https?:[/\\a-z0-9\.]+'|sed 's/\\//g;s/http:/http:/')" ;; 189 | # https 外链被封? 190 | 5) 191 | # http://upload.ouliu.net 192 | img_url_com="$(http --verify=no --timeout=25 --ignore-stdin -bf POST \ 193 | "$upload_poster_api_5" ifile@"$_file" "$user_agent"|grep 'id="codedirect"'| \ 194 | grep -Eio 'https?:[/\\a-z0-9\.]+'|sed 's/\\//g;s/http:/https:/'|head -1)" ;; 195 | 66) 196 | # https://ooxx.ooo # 下线,2019-04-25 197 | img_url_com="$(http --verify=no --timeout=25 --ignore-stdin -bf POST \ 198 | "$upload_poster_api_6" files[]@"$_file" "$user_agent"|grep -Eio '[0-9a-z/\.]+')" 199 | [[ $img_url_com ]] && img_url_com="https://i.ooxx.ooo/$img_url_com" ;; 200 | 7) 201 | # https://imgchr.com 路过图床 202 | unset _data _sessid _tok2; local _data _sessid _tok2 203 | _data="$(http -v "$upload_poster_api_7" "$user_agent"|grep -Ei 'auth_token|Set-Cookie')" 204 | _sessid="$(echo "$_data"|grep -Eio 'PHPSESSID=[0-9a-z]+'|head -1)" 205 | _tok2="$(echo "$_data"|grep -i 'auth_token'|head -1|grep -Eio '[0-9a-z]{30,}')" 206 | # 恶心... 207 | [[ $_tok2 && $_sessid ]] && \ 208 | img_url_com="$(http --pretty=format --verify=no --timeout=25 --ignore-stdin \ 209 | -bf POST "${upload_poster_api_7}/json" source@"$_file" auth_token="$_tok2" \ 210 | nsfw=0 timestamp=`date +%s`${RANDOM: -3} action='upload' type='file' "cookie:$_sessid" \ 211 | "$user_agent"|grep -i '"image":'|grep -Eio 'https?:[/\\a-z0-9\.]+')" ;; 212 | 8) 213 | # https://whoimg.com 无名图床 214 | unset _data _sessid _tok2; local _data _sessid _tok2 215 | _data="$(http -v "$upload_poster_api_8" "$user_agent"|grep -Ei 'auth_token|Set-Cookie')" 216 | _sessid="$(echo "$_data"|grep -Eio 'PHPSESSID=[0-9a-z]+'|head -1)" 217 | _tok2="$(echo "$_data"|grep -i 'auth_token'|head -1|grep -Eio '[0-9a-z]{30,}')" 218 | # 恶心... 219 | [[ $_tok2 && $_sessid ]] && \ 220 | img_url_com="$(http --pretty=format --verify=no --timeout=25 --ignore-stdin \ 221 | -bf POST "${upload_poster_api_8}/json" source@"$_file" auth_token="$_tok2" \ 222 | nsfw=0 timestamp=`date +%s`${RANDOM: -3} action='upload' type='file' "cookie:$_sessid" \ 223 | "$user_agent"|grep -i '"image":'|grep -Eio 'https?:[/\\a-z0-9\.]+')" ;; 224 | 9) 225 | # https://upload.cc 226 | img_url_com="$(http --pretty=format --verify=no --timeout=25 -Ibf POST \ 227 | "${upload_poster_api_9}/image_upload" uploaded_file[]@"$_file" "$user_agent"| \ 228 | grep '"url":'|grep -Eio '[0-9a-z/\.]{14,}')" 229 | [[ $img_url_com ]] && img_url_com="${upload_poster_api_9}/${img_url_com}" ;; 230 | 10) 231 | # 京东 232 | img_url_com="$(http --pretty=format --verify=no --timeout=25 -Ibf POST \ 233 | "${upload_poster_api_11}" filedata@"$_file" op='applyUpload' "$user_agent"| \ 234 | grep 'optDescription'|grep -io 'jfs[^"]*')" 235 | [[ $img_url_com ]] && img_url_com="https://img30.360buyimg.com/myjd/$img_url_com" ;; 236 | 237 | esac 238 | } 239 | up_case_func 240 | # 遍历所有 api 直到上传图片成功 241 | local _count=1 242 | while [[ ! $img_url_com && $_count -le 11 ]]; do 243 | [[ $_rand_ -eq 11 ]] && _rand_=0 || _rand_=$((_rand_ + 1)) 244 | up_case_func 245 | ((_count++)) 246 | done 247 | unset -f up_case_func 248 | debug_func "img:com-img-url[$img_url_com][$_rand_][$_count]" #----debug--- 249 | } 250 | #--------------------------------------# 251 | # byr 图片上传 252 | upload_image_byrbt() { 253 | unset img_url_byr # clean 254 | local _file="$1" # 参数:图片路径 255 | img_url_byr="$(http --verify=no --ignore-stdin --timeout=40 -bf POST \ 256 | "$byrbt_upload_api" command==QuickUpload type==Images upload@"$_file" \ 257 | "$user_agent" "$cookie_byrbt"|grep -Eio "https?://[^\'\"]+"|sed "s/http:/https:/g")" 258 | 259 | #----debug--- 260 | [[ $img_url_byr ]] || debug_func "$byrbt_up_api command==QuickUpload type==Images upload@$_file $user_agent $cookie_byrbt" 261 | debug_func "img:byr-img-url[$img_url_byr]" #----debug--- 262 | } 263 | # 264 | #-------------------------------------# 265 | # test tracker is down? 266 | is_tracker_down() { 267 | local _site 268 | for _site in hudbt whu nanyangpt npupt byrbt mt cmct tjupt tlfbits; do 269 | [[ "$(eval echo '$'enable_$_site)" = yes ]] && \ 270 | if http --verify=no --timeout=40 --ignore-stdin GET "${post_site[$_site]}/login.php" \ 271 | "$(eval echo '$'"cookie_$_site")" "$user_agent" &> /dev/null; then 272 | debug_func "static-[$_site is OK]" #----debug--- 273 | else 274 | case $? in 275 | 2|3|4) 276 | : ;; 277 | 5|6) 278 | eval "enable_$_site"='no' 279 | debug_func "static-[$_site is Down !!!]" #----debug--- 280 | ;; 281 | *) 282 | debug_func "static-[$_site http error!!]" #----debug--- 283 | ;; 284 | esac 285 | fi 286 | done 287 | unset _site 288 | } 289 | #-------------------------------------# 290 | count(){ [[ -f $1 ]] && printf '%s' "$#"|| printf 0; } 291 | Listf(){ local i;for i in "${1%/}/"*"$2";do [[ -f $i ]] && printf '%s\n' "$i";done; } 292 | #-------------------------------------# 293 | get_torrents_name() { 294 | [[ -f $1 ]] && $tr_show "$1"|grep -m1 '^Name:'|sed 's/Name:[ ]*//' || \ 295 | debug_func "get-tr-name:[$1]not a file" 296 | } 297 | #-------------------------------------# 298 | 299 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: test.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-08-17 7 | # 8 | #--------------------------------------# 9 | # 说明:该文件用于逐个测试站点情况, 10 | # 仅用于 debug。 11 | # 使用该测试文件的效果: 12 | # - 快速设置发布站点, 13 | # - 不会删除 tmp 中的简介文件,方便 debug, 14 | # - 不会删除已经发布的 .torrent 文件, 15 | # - 不会进入脚本超时控制模块,不会进入清理种子模块, 16 | # - 使用 test_func,会跳过种子下载完成检测(*)。 17 | #--------------------------------------# 18 | test_func() { 19 | test_func_probe=1 20 | #---[hudbt]---# 21 | enable_hudbt='no' 22 | #---[whu]---# 23 | enable_whu='no' 24 | #---[npupt]---# 25 | enable_npupt='no' 26 | #---[nanyangpt]---# 27 | enable_nanyangpt='no' 28 | #---[byrbt]---# 29 | enable_byrbt='no' 30 | #---[cmct]---# 31 | enable_cmct='no' 32 | #---[mteam]---# 33 | enable_mt='yes' 34 | #---[tjupt]---# 35 | enable_tjupt='no' 36 | #---[tlfbits]---# 37 | enable_tlfbits='yes' 38 | # 39 | } 40 | #--------------------------------------# 41 | #test_func #--Uncomment to debug!---# 42 | # 43 | debug_func() { 44 | # set true to debug, false to close 45 | if true; then 46 | #if false; then 47 | # 减少 debug 记录大量重复无用信息 48 | if [[ ${completion:-100} -ge 50 ]]; then 49 | printf '%b\n' "[$(date '+%m-%d %H:%M:%S')]:$*" >> "$debug_Log" 50 | fi 51 | fi 52 | } 53 | -------------------------------------------------------------------------------- /tmp/db/sample.txt: -------------------------------------------------------------------------------- 1 | &shc_name_douban&长安十二时辰 2 | &eng_name_douban&The Longest Day In Chang'an 3 | 4 | [img]https://img5.mtime.cn/pi/2018/10/17/115158.29316943_1000X1000.jpg[/img] 5 | 6 | ◎译  名 The Longest Day In Chang'an 7 | ◎片  名 长安十二时辰 8 | ◎年  代 2019 9 | ◎产  地 中国大陆 10 | ◎类  别 悬疑 / 历史 / 古装 11 | ◎语  言 汉语普通话 12 | ◎上映日期 2019-06-27(中国大陆) 13 | ◎IMDb评分 8.5/10 from 47 users 14 | ◎IMDb链接 http://www.imdb.com/title/tt10551640 15 | ◎豆瓣评分 8.6/10 from 117575 users 16 | ◎豆瓣链接 https://movie.douban.com/subject/26849758/ 17 | ◎集  数 48 18 | ◎片  长 45分钟 19 | ◎导  演 曹盾 Dun Cao 20 | ◎编  剧 爪子工作室 / 马伯庸 Marberionius 21 | ◎主  演 雷佳音 Jiayin Lei 22 |       易烊千玺 Jackson Yi 23 |       热依扎 Rayza 24 |       蔡鹭 Lu Cai 25 |       赵魏 Wei Zhao 26 |       芦芳生 Fangsheng Lu 27 |       吴晓亮 Xiaoliang Wu 28 |       韩童生 Tongsheng Han 29 |       周陆拉 Lula Zhou 30 |       尹铸胜 Zhusheng Yin 31 |       李媛 Yuan Li 32 |       周一围 Yiwei Zhou 33 |       王鹤润 Herun Wang 34 |       艾如 Ru Ai 35 |       高叶 Ye Gao 36 |       杰曼·翰苏 Djimon Hounsou 37 |       王思思 Sisi Wang 38 |       彭冠英 Guanying Peng 39 |       曲栅栅 Shanshan Qu 40 |       杨镒 Yi Yang 41 |       吕凉 Liang Lü 42 |       宝弟 Andy Ge 43 |       余皑磊 Ailei Yu 44 |       徐正运 Zhengyun Xu 45 |       徐璐 Lu Xu 46 |       冯嘉怡 Jiayi Feng 47 |       李品夆 Pinfeng Li 48 |       法智远 Zhiyuan Fa 49 |       王沐霖 Mulin Wang 50 |       寇智国 Zhiguo Kou 51 |       毛凡 Michael Mao 52 |       李全有 Quanyou Li 53 |       Sukhaa Ariunbyamba 54 |       王添 Tian Wang 55 |       周野芒 Yemang Zhou 56 |       伊利多斯 Eriedos 57 | 58 | 59 | ◎标  签 唐朝 | 历史 | 悬疑 | 佳作 | 良心剧 | 古装 | 长安 | 动作 60 | 61 | ◎简  介  62 | 63 |   上元节前夕,长安城混入可疑人员,身陷囹圄的张小敬临危受命,与少年天才李必携手在十二时辰内破除隐患。全篇运用了创新的探案剧集结构与人物关系设定,把故事嵌套在当时的世界文化中心城市长安这样一个完美的切入点。在展现跌宕紧凑的故事架构、反脸谱化的英雄人物、脑洞大开的细节设计同时,也带给观众丰富的文化价值。 64 | 65 | ◎获奖情况  66 | 67 |   第5届豆瓣电影年度榜单(2018) 68 |   最值得期待的剧集(提名) 69 | 70 | -------------------------------------------------------------------------------- /tmp/dupe-rules.txt: -------------------------------------------------------------------------------- 1 | # 说明: '井' 号后面部分没有效果,空格空行不影响结果,大小写不敏感。 2 | # 资源名中 '.'和 空格 不影响结果。 3 | # 注意分隔符(+)个数,可少,可多,最后一个须为资源名,对号入座。 4 | # 0 或者 no 表示不发布,1 或则 yes 表示发布。 5 | 6 | # 示例: 7 | # hudbt + whu + npupt + nanyangpt + byrbt + cmct + tjupt + 资源名字(部分或全部,支持匹配) 8 | 9 | # 1 + 1 + 0 + 0 + 0 + 0 + 0 + Cinderella.Chef.E # 萌妻食神 仅发 hudbt 和 whu 10 | # yes + yes + no + no + no + no + no + Douro.Mainland.E # 斗罗大陆 仅发 hudbt 和 whu 11 | # 1 + Great.Journey.Of.Teenagers # 少年歌行 仅发 hudbt 12 | # 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + The.Wrath.Of.Time.2019 # 鬼吹灯之怒晴湘西 仅发 hudbt 13 | -------------------------------------------------------------------------------- /tmp/log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rachpt/AutoSeed/2fe4f723cbe00e0159af698e8aef8ee65ec91ec6/tmp/log -------------------------------------------------------------------------------- /tmp/match-lists.txt: -------------------------------------------------------------------------------- 1 | # 说明: '井' 号后面部分没有效果,空格空行不影响结果,大小写不敏感。 2 | # 奇数行(先)为电影电视剧名,豆瓣中文英文名, '.'和 空格 不影响结果。 3 | # 偶数行(接着)为imdb或则豆瓣链接,全连接(https?)形式。 4 | 5 | # 示例: 6 | # Einstein and Einstein 7 | # https://movie.douban.com/subject/25716096/ 8 | 9 | Cinderella.Chef # 萌妻食神 10 | https://douban.com/subject/30395527/ 11 | 12 | Great.Journey.Of.Teenagers # 少年歌行 13 | https://douban.com/subject/30345127/ 14 | 15 | Douro.Mainland # 斗罗大陆 16 | https://douban.com/subject/27040807/ 17 | 18 | I'M.JOYBO.Words.From.My.Heart.s02 # 我是江小白第二季 19 | https://movie.douban.com/subject/30156271/ 20 | 21 | Set Sail.2019 # 启航 22 | https://douban.com/subject/30228393/ 23 | 24 | The.91th.Annual.Academy.Awards.2019 # 第91届奥斯卡金像奖颁奖典礼 25 | https://movie.douban.com/subject/30395844/ 26 | 27 | Martial.Universe.2019 # 武动乾坤 28 | https://movie.douban.com/subject/30223578/ 29 | 30 | Relying.on.Heaven.to.Slaughter.Dragons.E # 倚天屠龙记 31 | https://movie.douban.com/subject/25865815/ 32 | 33 | Game.of.Thrones.S08 34 | https://movie.douban.com/subject/26584183/ 35 | -------------------------------------------------------------------------------- /tmp/queue: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rachpt/AutoSeed/2fe4f723cbe00e0159af698e8aef8ee65ec91ec6/tmp/queue -------------------------------------------------------------------------------- /tmp/series-imdb.txt: -------------------------------------------------------------------------------- 1 | # 说明: '井' 号后面部分没有效果,空格空行不影响结果,大小写不敏感。 2 | # 奇数行(先)为电影电视剧名,豆瓣中文英文名, '.'和 空格 不影响结果。 3 | # 偶数行(接着)为imdb链接,全连接(https?) 形式。 4 | 5 | # 示例: 6 | Game.of.Thrones 7 | http://www.imdb.com/title/tt0944947 8 | 9 | -------------------------------------------------------------------------------- /transmission.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # FileName: transmission.sh 3 | # 4 | # Author: rachpt@126.com 5 | # Version: 3.1v 6 | # Date: 2019-02-22 7 | # 8 | #---------------------------------------# 9 | # 10 | #---path of transmission-remote---# 11 | tr_remote="$tr_remote ${tr_HOST}:${tr_PORT} --auth ${tr_USER}:${tr_PASSWORD}" 12 | 13 | #---------------------------------------# 14 | tr_set_ratio() { 15 | # transmission 具有排序特性,最后一个即是新添加的 16 | local Tr_ID name_in_tr tracker 17 | for Tr_ID in $($tr_remote -l|sed -En 's/^[ ]*([0-9]+).*/\1/gp'|sort -nr) 18 | do 19 | name_in_tr=$($tr_remote -t $Tr_ID -i|awk -F 'Name: ' '/Name/{print $2}') 20 | if [ "$one_TR_Name" = "$name_in_tr" ]; then 21 | debug_func 'tr:set-ratio' #----debug--- 22 | for tracker in ${!trackers[*]}; do 23 | [ "$($tr_remote -t $Tr_ID -i|grep "${trackers[$tracker]}")" ] && \ 24 | $tr_remote -t $Tr_ID -sr "$(eval echo '$'"ratio_$tracker")" && \ 25 | [[ $Allow_Say_Thanks == yes ]] && \ 26 | [[ "$(eval echo '$'"say_thanks_$tracker")" == yes ]] && \ 27 | if http --verify=no --ignore-stdin -f POST "${post_site[$tracker]}/thanks.php" \ 28 | id="$t_id" "$(eval echo '$'"cookie_$tracker")" &> /dev/null; then 29 | debug_func "tr:set-ratio-success[$tracker]" 30 | else 31 | case $? in 32 | 2) debug_func 'qbit[thx]:Request timed out!' ;; 33 | 3) debug_func 'qbit[thx]:Unexpected HTTP 3xx Redirection!' ;; 34 | 4) debug_func 'qbit[thx]:HTTP 4xx Client Error!' ;; 35 | 5) debug_func 'qbit[thx]:HTTP 5xx Server Error!' ;; 36 | 6) debug_func 'qbit[thx]:Exceeded --max-redirects= redirects!' ;; 37 | *) debug_func 'qbit[thx]:Other Error!' ;; 38 | esac 39 | curl -k -b "`eval echo '$'"cookie_$tracker"|sed -E 's/^cookie:[ ]?//i'`" -X POST \ 40 | -F "id=$t_id" -A "`echo "$user_agent"|sed -E 's/^User-Agent:[ ]?//i'`" \ 41 | "${post_site[$tracker]}/thanks.php" && debug_func 'tr:used-curl-say-thanks' 42 | fi && break 2 43 | done 44 | fi 45 | done 46 | } 47 | 48 | #------------add torrent--------------# 49 | tr_add_torrent_file() { 50 | $tr_remote --no-torrent-done-script &> /dev/null 51 | sleep 2 52 | debug_func 'tr:add-from-file' #----debug--- 53 | $tr_remote --add "${ROOT_PATH}/tmp/${t_id}.torrent" -w "$one_TR_Dir" 54 | $tr_remote --torrent-done-script "$ROOT_PATH/main.sh" &> /dev/null 55 | #---set seed ratio---# 56 | sleep 2 57 | tr_set_ratio 58 | } 59 | 60 | #------------add torrent--------------# 61 | tr_add_torrent_url() { 62 | debug_func 'tr:add-from-url' #----debug--- 63 | $tr_remote --no-torrent-done-script &> /dev/null 64 | $tr_remote --add "$torrent2add" -w "$one_TR_Dir" 65 | $tr_remote --torrent-done-script "$ROOT_PATH/main.sh" &> /dev/null 66 | #---set seed ratio---# 67 | sleep 2 68 | tr_set_ratio 69 | } 70 | 71 | #---------------------------------------# 72 | # call in main.sh 73 | tr_get_torrent_completion() { 74 | local id_t=$($tr_remote -l|grep "$org_tr_name"|head -1| \ 75 | awk '{print $1}'|grep -Eo '[0-9]+') 76 | [[ $id_t ]] && { 77 | #debug_func "tr:comp-id[$id_t]" #----debug--- 78 | completion=$($tr_remote -t $id_t -i|grep 'Percent Done:'|grep -Eo '[0-9]+'|head -1) 79 | one_TR_Dir="$($tr_remote -t $id_t -i|grep 'Location:'|grep -o '/.*$')" 80 | unset id_t; } 81 | #debug_func 'tr:complete-func' #----debug--- 82 | } 83 | 84 | #---------------------------------------# 85 | tr_reannounce() { 86 | $tr_remote -t all --reannounce 87 | } 88 | 89 | #---------------------------------------# 90 | 91 | --------------------------------------------------------------------------------