From 3266af742a2b864b63a7d103c57b4d472ad5d543 Mon Sep 17 00:00:00 2001 From: fredrik Date: Wed, 31 May 2006 00:39:43 +0000 Subject: [PATCH] Find next ep more flexibly. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@633 959494ce-11ee-0310-bf91-de5d638817bd --- autodlctl | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/autodlctl b/autodlctl index 3f390ce..004f5cf 100755 --- a/autodlctl +++ b/autodlctl @@ -2,6 +2,26 @@ paths=(/home/pub/video/anime $HOME/dc/autodl/cur) +function findcurep +{ + if [ -r badlist ]; then + echo badlist `head -n 1 curep` + return 0 + fi + if [ -r curep ]; then + if [ -r maxep ]; then + if [ "`cat curep`" -le "`cat maxep`" ]; then + echo curep `cat curep` + fi + else + echo curep `cat curep` + fi + return 0 + fi + echo none + return 1 +} + function getnext { cd "$1/.autodl/" @@ -9,20 +29,15 @@ function getnext echo "checking $tag" sexpr="`cat sexpr`" unset badsizes - if [ -r "badlist" ]; then - read curep <"badlist" - echo "downloading bad files, curep $curep" - epfrom=badlist - elif [ -r curep ]; then - curep="`cat curep`" - echo "downloading series, curep $curep" - epfrom=curep - else + epinfo=(`findcurep`) + if [ "${epinfo[0]}" = none ]; then echo "no available episode of $tag" >&2 echo "$tag" >>"$HOME/dc/autodl/faulty" touch disabled return 1 fi + epfrom="${epinfo[0]}" + curep="${epinfo[1]}" unset badsizesl if [ -r badsizes ]; then badsizesl="$(sed -n "s/^0*$curep \([^#]*\)\( *#.*\)\?$/\1/p" badsizes)" @@ -90,13 +105,6 @@ function getnext mv -f newbadlist badlist if [ `wc -l >"$HOME/dc/autodl/badmaxed" fi @@ -113,13 +121,16 @@ function getnext 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 fi ;; esac + if ! findcurep; then + echo "no more episodes to download from $tag" + touch disabled + fi fi fi rm -f "$outfile" -- 2.11.0