From 30b9e30fd68baef3bd64c14516a563f8d55d7dea Mon Sep 17 00:00:00 2001 From: Viktor Stanchev Date: Thu, 15 Nov 2012 23:52:09 -0800 Subject: [PATCH] initial commit --- README.md | 18 ++++++++++++++++++ install.sh | 1 + pirate-get.py | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 README.md create mode 100755 install.sh create mode 100755 pirate-get.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..76ec102 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +pirate-get +--- + +pirate-get is a convenient command line tool to speed up your trip to the pirate bay and get your completely legal torrents more quickly. + +Tested only on Ubuntu. + +Installation +--- + +Make sure you have python (2.7.3?) installed. + +Run install.sh + +Usage +--- + +pirate-get diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..5723a58 --- /dev/null +++ b/install.sh @@ -0,0 +1 @@ +cp pirate-get.py /usr/bin/pirate-get diff --git a/pirate-get.py b/pirate-get.py new file mode 100755 index 0000000..dcf1318 --- /dev/null +++ b/pirate-get.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +import webbrowser +import urllib +import urllib2 +import sys +import re + +if(len(sys.argv) == 1): + print "usage: pirate-get " + exit() +q = sys.argv[1] +f = urllib2.urlopen('http://thepiratebay.se/search/'+q.replace(" ", "+")+'/0/7/0') + +mag = re.findall(""""(magnet\:\?xt=[^"]*)""", f.read()) + +if mag: + for m in range(len(mag)): + name = re.search("dn=([^\&]*)", mag[m]) + print str(m)+".", urllib.unquote(name.group(1).encode('ascii')).decode('utf-8').replace("+", " ") + l = raw_input("Select a link: ") + webbrowser.open(mag[int(l)]) +else: + print "no results"