mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-25 12:24:20 +01:00
Fix another encoding bug
This commit is contained in:
parent
6aaf69cfa7
commit
23570d75ff
@ -412,16 +412,17 @@ def main():
|
|||||||
|
|
||||||
def print_descriptions(chosen_links):
|
def print_descriptions(chosen_links):
|
||||||
for link in chosen_links:
|
for link in chosen_links:
|
||||||
path = '/torrent/%s/' % identifiers[int(link)]
|
link = int(link)
|
||||||
request = request.Request(mirror + path)
|
path = '/torrent/%s/' % identifiers[link]
|
||||||
request.add_header('Accept-encoding', 'gzip')
|
req = request.Request(mirror + path)
|
||||||
f = request.urlopen(request)
|
req.add_header('Accept-encoding', 'gzip')
|
||||||
|
f = request.urlopen(req)
|
||||||
|
|
||||||
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()
|
res = f.read().decode('utf-8')
|
||||||
name = re.search("dn=([^\&]*)", mags[int(link)][0])
|
name = re.search("dn=([^\&]*)", mags[link][0])
|
||||||
torrent_name = parse.unquote(name.group(1)).replace("+", " ")
|
torrent_name = parse.unquote(name.group(1)).replace("+", " ")
|
||||||
desc = re.search(r"<div class=\"nfo\">\s*<pre>(.+?)(?=</pre>)",
|
desc = re.search(r"<div class=\"nfo\">\s*<pre>(.+?)(?=</pre>)",
|
||||||
res, re.DOTALL).group(1)
|
res, re.DOTALL).group(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user