Name: Anonymous 2011-10-06 9:06
Any code you work with right now, and we'll criticize it(or not).
#!/bin/bash
root=`echo ~`
watched_folder="$root/downloads/torrents/links"
if [ ! 1 -eq $# ]; then
echo This script needs one argument
exit 1
fi
file="$root/scripts/torrents/$1"
if [ ! -f "$file" ]; then
# History file does not exist yet
touch "$file"
echo Created a history file
fi
url="http://api.dailytvtorrents.org/1.0/torrent.getLatest?show_name=$1&just_link=yes"
link=`curl -s "$url"`
old_link=`cat "$file"`
# Change this by checking if .torrent file already there
if [ ! "$old_link" = "$link" ]; then
# Last download of the torrent != current try
# Do we need to start deluged?
ps=`pgrep deluged`
if [ "$ps" = "" ]; then
sudo /etc/rc.d/deluged start
fi
cd "$watched_folder"
curl -s -O "$link"
echo "Got one"
# We remember it
echo $link > $file
else
echo "Nothing new"
fi