function getnext
{
+ cd "$1/.autodl/"
+ tag="$2"
echo "checking $tag"
- sexpr="`cat "$d/.autodl/sexpr"`"
+ sexpr="`cat sexpr`"
unset badsizes
- if [ -r "$d/.autodl/badlist" ]; then
- read curep <"$d/.autodl/badlist"
+ if [ -r "badlist" ]; then
+ read curep <"badlist"
echo "downloading bad files, curep $curep"
epfrom=badlist
- elif [ -r "$d/.autodl/curep" ]; then
- curep="`cat "$d/.autodl/curep"`"
+ elif [ -r curep ]; then
+ curep="`cat curep`"
echo "downloading series, curep $curep"
epfrom=curep
else
echo "no available episode of $tag" >&2
echo "$tag" >>"$HOME/dc/autodl/faulty"
+ touch disabled
return 1
fi
unset badsizesl
- if [ -r "$d/.autodl/badsizes" ]; then
- badsizesl="$(sed -n "s/^0*$curep \([^#]*\)\( *#.*\)\?$/\1/p" "$d/.autodl/badsizes")"
+ if [ -r badsizes ]; then
+ badsizesl="$(sed -n "s/^0*$curep \([^#]*\)\( *#.*\)\?$/\1/p" badsizes)"
fi
if [ -n "$badsizesl" ]; then
read -a badsizes <<<"$badsizesl"
fsexpr="$fsexpr & ! S=$badsize"
done
fi
- infofile="$d/.autodl/rtinfo"
- estatfile="$d/.autodl/estat"
+ infofile=rtinfo
+ estatfile=estat
args=(-e "$fsexpr" -t "$tag $curep" -I "$infofile" -E "$estatfile" -x "curep=$curep")
- if [ -e "$d/.autodl/wait" ]; then
+ if [ -e wait ]; then
args=("${args[@]}" -w)
fi
- if [ -r "$d/.autodl/uarg" ]; then
- uarg="`cat "$d/.autodl/uarg"`"
- elif [ -e "$d/.autodl/autouarg" ]; then
- uarg="rename:$tag - %02i.avi:move:../autodl/cur/$tag"
+ if [ -r uarg ]; then
+ uarg="`cat uarg`"
+ elif [ -e autouarg ]; then
+ uarg="rename:$tag - %02i.ext:move:../autodl/cur/$tag"
fi
if [ -n "$uarg" ]; then
fuarg="`printf "$uarg" "$curep"`"
args=("${args[@]}" -a "$fuarg")
fi
- outfile="$d/.autodl/output"
+ outfile=output
echo "trying to download -- autodl ${args[@]}"
intr=n
autodl "${args[@]}" >"$outfile" 2>&1 &
echo "Connection error on $tag"
elif [ "$stat" -eq 3 ]; then
echo "Configuration error, disabling $tag"
- cp "$outfile" "$d/.autodl/conferr"
- touch "$d/.autodl/disabled"
+ cp "$outfile" conferr
+ touch disabled
echo "$tag" >>"$HOME/dc/autodl/faulty"
fi
else
case "$epfrom" in
badlist)
echo -en "${tag}\n${curep}\n" >>"$HOME/dc/autodl/baddone"
- egrep -v "^$curep( |\$)" "$d/.autodl/badlist" >"$d/.autodl/newbadlist"
- mv -f "$d/.autodl/newbadlist" "$d/.autodl/badlist"
- if [ `wc -l <"$d/.autodl/badlist"` -eq 0 ]; then
- rm "$d/.autodl/badlist"
- if [ -r "$d/.autodl/curep" ]; then
- if [ -r "$d/.autodl/maxep" ] && [ "`cat "$d/.autodl/curep"`" -gt "`cat "$d/.autodl/maxep"`" ]; then
- touch "$d/.autodl/disabled"
+ egrep -v "^$curep( |\$)" badlist >newbadlist
+ mv -f newbadlist badlist
+ if [ `wc -l <badlist` -eq 0 ]; then
+ rm badlist
+ if [ -r curep ]; then
+ if [ -r maxep ] && [ "`cat curep`" -gt "`cat maxep`" ]; then
+ touch disabled
fi
else
- touch "$d/.autodl/disabled"
+ touch disabled
fi
echo "$tag has no more bad episodes"
echo "$tag" >>"$HOME/dc/autodl/badmaxed"
echo -en "${tag}\n${curep}\n" >>"$HOME/dc/autodl/done"
let curep++
fi
- echo "$curep" >"$d/.autodl/curep"
- if [ -r "$d/.autodl/maxep" ]; then
- if [ "$curep" -gt "`cat "$d/.autodl/maxep"`" ]; then
- touch "$d/.autodl/disabled"
+ echo "$curep" >curep
+ if [ -r maxep ]; then
+ if [ "$curep" -gt "`cat maxep`" ]; then
+ touch disabled
echo "$tag has reached max"
echo "$tag" >>"$HOME/dc/autodl/maxed"
fi