#!/bin/bash # v1.0 # Melyik mappát figyelje a script: watchdir="/home/xbmc/Dropbox/XBMC/" # Végső letöltés helye downloaddir="/media/usb/"; # Ideiglenes tároló incomplite="/home/transmission/" # Authentication "username:password": tr_auth="transmission:transmission" # Transmission host "ip:port": tr_host="127.0.0.1:9091" # Verbose? verbose=1 ############################################# time=$(date "+%Y-%m-%d (%H:%M:%S)") if [ -n "$tr_auth" ]; then tr_auth="--auth=$tr_auth" fi # Biztonsági indítás transmission-remote "$tr_host" "$tr_auth" -t all -s; for category in `ls -1 $watchdir` do if [ -d $watchdir$category ] ; then for file in "$watchdir$category/"*.torrent do if [ -f "$file" ]; then if [ -n "$verbose" ]; then echo "$time: $file added to queue."; fi text=$(basename $file); #TAG=`expr index "$text" "]"`; #if [ $TAG -ne 0 ] ; then # let "TAG -= 2"; # label=`expr substr "$text" 2 $TAG`; #fi if [ "$category" = "Sorozat" ] ; then searchtag=`expr index "$text" "]"`; while [ $searchtag -ne 0 ]; do text=${text:$searchtag}; searchtag=`expr index "$text" "]"`; done se=`expr "$text" : '.*\(S[0-9]*E[0-9]*\)'`; if [ "$se" = "" ]; then se=`expr "$text" : '.*\(S[0-9]*\)'`; season=`expr ${se:1:2} : '[0]\?\([1-9]*\)'`; movie=`expr "$text" : '\(.*\).S[0-9]*'`; movie=${movie//\./\ } transmission-remote "$tr_host" "$tr_auth" -a "$file" -c "$incomplite" -w "$downloaddir$category/$movie/Season $season" > /dev/null else epos=`expr index "$se" "E"`; let "epos -= 2"; season=`expr ${se:1:epos} : '[0]\?\([1-9]*\)'`; movie=`expr "$text" : '\(.*\).S[0-9]*E[0-9]*'`; movie=${movie//\./\ } transmission-remote "$tr_host" "$tr_auth" -a "$file" -c "$incomplite" -w "$downloaddir$category/$movie/Season $season/" > /dev/null fi else transmission-remote "$tr_host" "$tr_auth" -a "$file" -c "$incomplite" -w "$downloaddir$category/" fi # give the remote some time to process sleep 5 rm "$file" else if [ -n "$verbose" ]; then echo "$time: No torrent in $watchdir."; fi fi done fi done exit 0