mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
Handle the new pirate bay
This commit is contained in:
parent
9a13c0308e
commit
7bfed1e5da
@ -36,6 +36,8 @@ from urllib.error import URLError
|
|||||||
from socket import timeout
|
from socket import timeout
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
headers = {'User-Agent': 'pirate get'}
|
||||||
|
|
||||||
categories = {
|
categories = {
|
||||||
'All': 0,
|
'All': 0,
|
||||||
'Applications': 300,
|
'Applications': 300,
|
||||||
@ -210,9 +212,9 @@ def remote(args, mirror):
|
|||||||
page, sort,
|
page, sort,
|
||||||
category))
|
category))
|
||||||
|
|
||||||
req = request.Request(mirror + path)
|
req = request.Request(mirror + path, headers=headers)
|
||||||
req.add_header('Accept-encoding', 'gzip')
|
req.add_header('Accept-encoding', 'gzip')
|
||||||
f = request.urlopen(req, timeout=2)
|
f = request.urlopen(req, timeout=5)
|
||||||
if f.info().get('Content-Encoding') == 'gzip':
|
if f.info().get('Content-Encoding') == 'gzip':
|
||||||
f = gzip.GzipFile(fileobj=BytesIO(f.read()))
|
f = gzip.GzipFile(fileobj=BytesIO(f.read()))
|
||||||
res = f.read().decode('utf-8')
|
res = f.read().decode('utf-8')
|
||||||
@ -317,7 +319,7 @@ def print_descriptions(chosen_links, mags, site, identifiers):
|
|||||||
for link in chosen_links:
|
for link in chosen_links:
|
||||||
link = int(link)
|
link = int(link)
|
||||||
path = '/torrent/%s/' % identifiers[link]
|
path = '/torrent/%s/' % identifiers[link]
|
||||||
req = request.Request(site + path)
|
req = request.Request(site + path, headers=headers)
|
||||||
req.add_header('Accept-encoding', 'gzip')
|
req.add_header('Accept-encoding', 'gzip')
|
||||||
f = request.urlopen(req)
|
f = request.urlopen(req)
|
||||||
|
|
||||||
@ -341,7 +343,7 @@ def print_fileLists(chosen_links, mags, site, identifiers):
|
|||||||
for link in chosen_links:
|
for link in chosen_links:
|
||||||
path = '/ajax_details_filelist.php'
|
path = '/ajax_details_filelist.php'
|
||||||
query = '?id=' + identifiers[int(link)]
|
query = '?id=' + identifiers[int(link)]
|
||||||
req = request.Request(site + path + query)
|
req = request.Request(site + path + query, headers=headers)
|
||||||
req.add_header('Accept-encoding', 'gzip')
|
req.add_header('Accept-encoding', 'gzip')
|
||||||
f = request.urlopen(req)
|
f = request.urlopen(req)
|
||||||
|
|
||||||
@ -436,7 +438,7 @@ def main():
|
|||||||
if args.database:
|
if args.database:
|
||||||
mags = local(args.database, args.search)
|
mags = local(args.database, args.search)
|
||||||
else:
|
else:
|
||||||
mags, mirrors = [], ['http://thepiratebay.se']
|
mags, mirrors = [], ['https://thepiratebay.se']
|
||||||
try:
|
try:
|
||||||
opener = request.build_opener(NoRedirection)
|
opener = request.build_opener(NoRedirection)
|
||||||
f = opener.open('https://proxybay.info/list.txt', timeout=5)
|
f = opener.open('https://proxybay.info/list.txt', timeout=5)
|
||||||
|
Loading…
Reference in New Issue
Block a user