Skip to content

Instantly share code, notes, and snippets.

@iGlitch
Last active February 13, 2019 10:05
Show Gist options
  • Save iGlitch/608ac70b8105bcc8e18626febcfa7aa6 to your computer and use it in GitHub Desktop.
Save iGlitch/608ac70b8105bcc8e18626febcfa7aa6 to your computer and use it in GitHub Desktop.
AutoDL RSS Torrents from Gazelle tracker cron
#!/bin/bash
#~ AutoGet Script ~#
#~ cron example, run every 10mn: ~#
#~ */10 * * * * /path/to/script/autodl.sh >/dev/null 2>&1 ~#
# variables
RSSKEY=####_#####################
USERID=#####
AUTH=################################
PASSKEY=################################
AUTHKEY=################################
SITE=################# (no https:// or trailing /)
# Server variables
USER=$(whoami)
SCRIPT_PATH=/home/$USER/torrent/
FILES_PATH=/home/$USER/torrent/torrents/
FEED=gz_rss
LIST=gz_list
DLED=gz_downloaded
# Get the feed
wget --no-check-certificate -q -O $SCRIPT_PATH$FEED "https://$SITE/feeds.php?feed=torrents_notify_$RSSKEY&user=$USERID&auth=$AUTH&passkey=$PASSKEY&authkey=$AUTHKEY";
# Create the list with only .torrent files URLs
cat $SCRIPT_PATH$FEED | grep "link" | sed -e 's/\(<.\?link>\)\|amp;//g' | \
sed '1d' | sed -e 's/^[ \t]*//' > $SCRIPT_PATH$LIST;
# Get the .torrent files
while read LINE;
do
ID=$(echo $LINE | awk -F"=" '{ print $5 }');
if [ -e $SCRIPT_PATH$DLED ]; then
# Check if torrent has alredy been downloaded
if !(grep -Fxq "$ID" $SCRIPT_PATH$DLED); then
# Needed for old versions of transmission-daemon?
rm -f $FILES_PATH*.added;
# Download .torrent files
wget --no-check-certificate -q -O $FILES_PATH$ID.torrent $LINE;
# Keep track of downloaded .torrent ID
echo "$ID" >> $SCRIPT_PATH$DLED;
fi
else
# Probably first run or file was deleted
touch $SCRIPT_PATH$DLED;
# Needed for old versions of transmission-daemon?
rm -f $FILES_PATH*.added;
wget --no-check-certificate -q -O $FILES_PATH$ID.torrent $LINE;
echo "$ID" >> $SCRIPT_PATH$DLED;
fi
done < $SCRIPT_PATH$LIST
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment