mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-24 12:14:20 +01:00
make timeouts higher and the same
This commit is contained in:
parent
ef18c3a688
commit
4185242caa
@ -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
|
||||||
|
|
||||||
|
default_timeout = 10
|
||||||
|
|
||||||
headers = {'User-Agent': 'pirate get'}
|
headers = {'User-Agent': 'pirate get'}
|
||||||
|
|
||||||
categories = {
|
categories = {
|
||||||
@ -214,7 +216,7 @@ def remote(args, mirror):
|
|||||||
|
|
||||||
req = request.Request(mirror + path, headers=headers)
|
req = request.Request(mirror + path, headers=headers)
|
||||||
req.add_header('Accept-encoding', 'gzip')
|
req.add_header('Accept-encoding', 'gzip')
|
||||||
f = request.urlopen(req, timeout=5)
|
f = request.urlopen(req, timeout=default_timeout)
|
||||||
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')
|
||||||
@ -321,7 +323,7 @@ def print_descriptions(chosen_links, mags, site, identifiers):
|
|||||||
path = '/torrent/%s/' % identifiers[link]
|
path = '/torrent/%s/' % identifiers[link]
|
||||||
req = request.Request(site + path, headers=headers)
|
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, timeout=default_timeout)
|
||||||
|
|
||||||
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()))
|
||||||
@ -345,7 +347,7 @@ def print_fileLists(chosen_links, mags, site, identifiers):
|
|||||||
query = '?id=' + identifiers[int(link)]
|
query = '?id=' + identifiers[int(link)]
|
||||||
req = request.Request(site + path + query, headers=headers)
|
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, timeout=default_timeout)
|
||||||
|
|
||||||
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()))
|
||||||
@ -440,7 +442,7 @@ def main():
|
|||||||
mags, mirrors = [], ['https://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=default_timeout)
|
||||||
if f.getcode() != 200:
|
if f.getcode() != 200:
|
||||||
raise IOError('The pirate bay responded with an error.')
|
raise IOError('The pirate bay responded with an error.')
|
||||||
mirrors.extend([i.decode('utf-8').strip()
|
mirrors.extend([i.decode('utf-8').strip()
|
||||||
|
Loading…
Reference in New Issue
Block a user