mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
detect when the pirate bay is blocked
This commit is contained in:
parent
5432de0b0e
commit
4cd591e47d
@ -8,6 +8,12 @@ from HTMLParser import HTMLParser
|
||||
import argparse
|
||||
from pprint import pprint
|
||||
|
||||
class NoRedirection(urllib2.HTTPErrorProcessor):
|
||||
|
||||
def http_response(self, request, response):
|
||||
return response
|
||||
|
||||
https_response = http_response
|
||||
|
||||
# create a subclass and override the handler methods
|
||||
class MyHTMLParser(HTMLParser):
|
||||
@ -104,7 +110,10 @@ def main():
|
||||
else:
|
||||
mirrors = ["http://thepiratebay.se"]
|
||||
try:
|
||||
f = urllib2.urlopen("http://proxybay.info/list.txt")
|
||||
opener = urllib2.build_opener(NoRedirection)
|
||||
f = opener.open("http://proxybay.info/list.txt")
|
||||
if f.getcode() != 200:
|
||||
raise Exception("The pirate bay responded with an error.")
|
||||
res = f.read()
|
||||
mirrors += res.split("\n")[3:]
|
||||
except:
|
||||
|
Loading…
Reference in New Issue
Block a user