'|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 |
"; }
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]\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="
以下是
\
81 | 自动完成的截图,不喜勿看。
"; } || {
82 | _ext_desc="[b]以下是 [img]\
83 | https://s2.ax1x.com/2019/05/04/Ea3qbQ.png[/img] 自动完成的截图,不喜勿看。[/b]"
84 | _ext_html="
以下是
自动完成的截图,不喜勿看。
"; }
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' "
" >> "$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
,欢迎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 |
--------------------------------------------------------------------------------