title 163subdownloaderhelper v1.0.1

@echo off
set "str=%~x1"
set film=%~n1%
set /p  film=%~n1%
ʹ÷
rem һȡƥĻid
curl -s -o %film%-utf8temp.txt http://www.163sub.com/Search?id=%film%
iconv.exe -c -f UTF-8 -t GBK  %film%-utf8temp.txt  > %film%-gbktemp.txt
sed "s#'#\n#g" %film%-gbktemp.txt | grep ^/download^/ > subidtemp.txt
sed  "s#../../download/##g"  subidtemp.txt | sed  "$d"> subid.txt
rem ڶĻ
for /f %%i in (subid.txt) do (
curl -# -o %%i-utf8temp.txt http://www.163sub.com/download/%%i -H "referer:http://www.163sub.com/Search?id=%film%"
iconv.exe -c -f UTF-8 -t GBK  %%i-utf8temp.txt  > %%i-gbktemp.txt
sed -i "s#'#\n#g;s#url=#\n#g" %%i-gbktemp.txt 
grep http %%i-gbktemp.txt  | egrep "\.srt|\.ass|\.smi" >>%film%-subdownloadhelpertemp.txt
)
sort %film%-subdownloadhelpertemp.txt | uniq >%film%-subdownloadhelper.txt
aria2c  -i %film%-subdownloadhelper.txt
rem 
if exist *.srt ren *.srt %film%-*.srt
if exist *.ass ren *.ass %film%-*.ass
if exist *.smi ren *.smi %film%-*.smi
rem Ĳ
del *.
del *temp.*