Tpbss

Aus Ethersex_Wiki
Wechseln zu: Navigation, Suche

The Piratebay Season stripper

On piratebay you can find listings like these these, where all torrents to an specific season of an tv series are listed. But when you want to have all of these nice torrent files? click every single one? Too exhausting!!! Search for every episode for the best torrent? Too exhausting!!! So write an awk script:

#!/bin/sh
#
# thepiratebay season stripper
# example: ./tpbss http://thepiratebay.org/tv/54/S16/  

mkdir -p $HOME/.tpbss
ESfile=`echo $1 | base64`

wget -O- -q $1  2>/dev/null| awk '/http:\/\/torrents.thepiratebay.org/ { 
  url = gensub("^href=\"(.*)\"$", "\\1", 1,  $2);
  episode = int(gensub(".*[sS][0-9][0-9][eE]([0-9][0-9]).*", "\\1", 1, url));
  linecount = 1;
}
linecount == 3  { seeder = gensub(".*>(.*)<.*", "\\1", 1, $0) }
linecount == 4  { leecher = gensub(".*>(.*)<.*", "\\1", 1, $0);
                  t_index = int(seeder) * 2 + int(leecher);
                  if (! episodes[episode, "index"]  || t_index > episodes[episode, "index"]) {
                    episodes[ episode, "url" ] = url;
                    episodes[ episode, "index" ] = t_index;
                  }
                }
linecount > 0 { linecount += 1}
END { for (val in episodes) {
      if (match(val, "url")) {
        print episodes[val];
      }
    } 
  }
' | while read url; do
  episode=`echo $url | egrep -o 'S[0-9]{1,2}E[0-9]{1,2}'`
  if ! fgrep -q  "$episode" $HOME/.tpbss/$ESfile >/dev/null 2>&1 ; then
    echo New torrent downloaded: $url

    wget -q $url

    echo $episode >> $HOME/.tpbss/$ESfile

  fi
done

This will find for every episode the best torrent, and prints out the link to the torrent file. And then you can have fun with all of your new funny torrent files :)