Skip to content

Instantly share code, notes, and snippets.

@mappu
Last active December 17, 2015 15:29
Show Gist options
  • Save mappu/5632522 to your computer and use it in GitHub Desktop.
Save mappu/5632522 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Nyaaget (mappy 2013)
# Downloads torrents from nyaa and automatically adds them to transmission
#
# Usage: ./nyaaget "search terms"
#
# To run automatically every two hours:
# Run crontab -e to edit your user's crontab, and add a line like
# 0 */2 * * * /home/me/nyaaget/nyaaget.sh "Miya-k Miyakawa-ke no Kuufuku"
TORRENT_FILE_DIR=./
if [ "$#" -ne 1 ] ; then
echo "Usage: $1 \"search terms\""
exit 1
fi
URLS=$(
curl -s "http://www.nyaa.eu/?page=rss&term=`echo "$1" | sed 's/ /+/g'`" |\
grep -Eo "http://www.nyaa.eu/\?page=download[^<]*" |\
sed 's/#38;//'
)
for url in $URLS ; do
TID=`echo "$url" | sed 's/.*tid=//'`
if [ ! -f ${TORRENT_FILE_DIR}nyaa_$TID.torrent ]; then
# Torrent file hasn't been downloaded before
curl -s "$url" > ${TORRENT_FILE_DIR}nyaa_$TID.torrent
#transmission-cli --download-dir "$DOWNLOAD_DEST" "nyaa_$TID.torrent"
transmission-remote -a "${TORRENT_FILE_DIR}nyaa_$TID.torrent" >/dev/null
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment