#!/bin/sh # # by Sairon Istyar, 2012 # distributed under the GPLv3 license # http://www.opensource.org/licenses/gpl-3.0.html # # program to use for torrent download program='/opt/usr/bin/transmission-remote' progopts='-a' # show N first matches by default limit=15 # colors numbcolor='\x1b[1;35m' namecolor='\x1b[1;33m' sizecolor='\x1b[1;36m' seedcolor='\x1b[1;31m' peercolor='\x1b[1;32m' nonecolor='\x1b[0m' printhelp() { echo -e "Usage:\n\t$0 [options] search query\n\nAvailable options:\n\t-h\t\tShow help\n\t-n [num]\tShow only first N results (default 15; max 50)\n\t-C\t\tDo not use colors" } while getopts :hCn: opt ; do case "$opt" in h) printhelp; exit 0;; n) limit="$OPTARG";; C) unset numbcolor; unset namecolor; unset sizecolor; unset seedcolor; unset peercolor; unset nonecolor;; *) echo -e "Unknown option(s)."; printhelp; exit 1;; esac done shift `expr $OPTIND - 1` q=`echo "$*" | tr -d '\n' | od -t x1 -A n | tr ' ' '%'` r=`curl -s "http://torrentz.eu/search?f=$q" \ | grep -Eo '