#!/bin/bash #############==============-------------- # Mininova SSATEUR: Site-Specific Automatic Torrent Extractor Using RSS # Authored By: Andrew Rowls # !--> Works ONLY with torrent feeds from http://www.mininova.org/ # !--> If this script successfully parses feeds from any other site, it's sheer coincidence # #####==============-------------- # IMPORTANT: While mininova has not implemented CAPTCHAs, you should still be courteous towards them # While I don't believe this script will particularly tax mininova's servers simply by being run # once, you should not be so rude as to run it many times within a short time span, especially # if you have many feeds you check. Since TV shows typically don't air more than once a week, # ideally you should only run this script once a week. However, since it is typically desirable # to have a copy of a show by the day after it airs, I would recommend running the script no more # than once per day, at least several hours after the latest show of interest has aired. For # example, my shows typically air around 8-10PM EDT. The torrents for these shows are guaranteed # to show up by 5AM the next morning. Therefore, I have cron set to run this script once per day at # 5AM. This almost guarantees that I will be able to start downloading shows from the # previous night. # Again, please be courteous when setting this script to run. And don't blame me if mininova # bans your IP for excessive bandwidth usage (or any other reason, for that matter) # #####==============-------------- # See the README for an explanation of the script # #####==============-------------- # # Fixes some issues with CRON's default env. Change HOME to your home directory, or remove if appropriate PATH=/bin:/usr/bin:/usr/sbin:$PATH HOME=/home/andrew db=~/bin/mininovarss/gotten.txt dest=/torrents/loading feeds=~/bin/mininovarss/feeds.txt #cookies=~/bin/mininovarss/cookies.txt #cookies=`echo "$cookies" | replace " " "\ "` #wgetopts="--keep-session-cookies --load-cookies $cookies --save-cookies $cookies" wgetopts="" # Check if Mininova is up. If not, wait 2hrs before trying again. Etc. ping=`ping -c 1 -t 60 mininova.org 2>&1 | grep "\(unknown host\)\|\(Time to live exceeded\)\|\(opendns.com\)" -c` while [ $ping -eq 1 ]; do #echo -e "`date`\tMiniNova.org is down." sleep 120m ping=`ping -c 1 -t 60 xtvi.com 2>&1 | grep "\(unknown host\)\|\(Time to live exceeded\)\|\(opendns.com\)" -c` done feeds=`cat "$feeds" | grep -v "^#"` for RSS in $feeds; do titles=`wget $RSS -O- 2>/dev/null | sed "s/<\/item>/<\/item>\n/" | grep -io "[^<]*" | replace "" "" "" "" " " "~"` i=0 for title in $titles; do file=`echo $title | replace "~" " "` # echo $file # avoid private trackers, let eztv through private=`echo "$file" | grep -iv "\[eztv\]" | grep -ioc "\[[^]]*\]"` if [ $private -ne 0 ]; then i=$(($i+1)) #echo "Private tracker, skip" continue fi # extract seed/leech info. Skip if seeds or leeches drop below 1 seedleech=`echo "$file" | grep -io "(-\?[0-9]\+S\/-\?[0-9]\+L)"` seeds=$((`echo "$seedleech" | grep -io "\-\?[0-9]\+S" | sed 's/s//i'`)) leeches=$((`echo "$seedleech" | grep -io "\-\?[0-9]\+L" | sed 's/l//i'`)) if [ $seeds -lt 1 -o $leeches -lt 0 ]; then # echo -e "\tskipping\n" i=$(($i+1)) continue fi # Strip seed/leech info file=`echo "$file" | sed "s/ (\-\?[0-9]\+S\/\-\?[0-9]\+L)//i"` show=`echo "$file" | grep -io ".*S[0-9]\{1,2\}E[0-9]\{1,2\}"` if [ -z "$show" ]; then i=$(($i+1)) continue fi name=`echo "$show" | grep -io ".*[ \.]" | replace "." " " "-" " " "_" " "` while [ -n "`echo "$name" | grep \" \{2\}\"`" ]; do name=`echo "$name" | replace " " " "` done name=`echo "\`expr "$name" : '[ ]*\(.*\)[ *]$'\`"` # echo -e "\t\"$show\"" # echo -e "\t\"$name\"" season=$((`echo "$show" | grep -io "S[0-9]\{1,2\}" | replace "S" "" "s" ""`)) if [ $season -ne 0 ]; then #echo -e "\t$season" episode=$((`echo "$show" | grep -io "E[0-9]\{1,2\}" | replace "E" "" "e" "" | sed 's/^0//'`)) #echo -e "\t$episode" if [ $episode -ne 0 ]; then #echo -e "\t$name $season $episode" gotten=`cat "$db" | grep -v "^#" | grep -ic "$name $season $episode"` if [ $gotten -eq 0 ]; then echo "$name $season $episode" >> "$db" links=`wget $RSS -O- 2>/dev/null | sed "s/<\/item>/<\/item>\n/" | grep -io "[^<]*" | replace "" "" "" "" " " "~"` j=0 for link in $links; do if [ $j -eq $i ]; then link=`echo $link | replace "~" " " "&" "&" "/tor/" "/get/"` #echo $file #echo -e "\t$link" wget -O "$dest/$file.torrent" "$link" 2>/dev/null fi j=$(($j+1)) done fi fi fi i=$(($i+1)) done done