From 3bf0176fab726b379e83c56dd6e2a5c22e5f52d6 Mon Sep 17 00:00:00 2001 From: fredrik Date: Wed, 31 May 2006 00:03:10 +0000 Subject: [PATCH] Use cwd instead of "$d/.autodl". git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@632 959494ce-11ee-0310-bf91-de5d638817bd --- autodlctl | 62 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/autodlctl b/autodlctl index b3c914c..3f390ce 100755 --- a/autodlctl +++ b/autodlctl @@ -4,26 +4,28 @@ paths=(/home/pub/video/anime $HOME/dc/autodl/cur) 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 "$d/.autodl/disabled" + 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" @@ -37,22 +39,22 @@ function getnext 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 & @@ -75,8 +77,8 @@ function getnext 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 @@ -84,16 +86,16 @@ function getnext 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 >"$HOME/dc/autodl/badmaxed" @@ -108,10 +110,10 @@ function getnext 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 -- 2.11.0