1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00

Fix another encoding bug

This commit is contained in:
Rnhmjoj 2014-12-03 20:21:16 +01:00
parent 6aaf69cfa7
commit 23570d75ff

View File

@ -412,16 +412,17 @@ def main():
def print_descriptions(chosen_links):
for link in chosen_links:
path = '/torrent/%s/' % identifiers[int(link)]
request = request.Request(mirror + path)
request.add_header('Accept-encoding', 'gzip')
f = request.urlopen(request)
link = int(link)
path = '/torrent/%s/' % identifiers[link]
req = request.Request(mirror + path)
req.add_header('Accept-encoding', 'gzip')
f = request.urlopen(req)
if f.info().get('Content-Encoding') == 'gzip':
f = gzip.GzipFile(fileobj=BytesIO(f.read()))
res = f.read()
name = re.search("dn=([^\&]*)", mags[int(link)][0])
res = f.read().decode('utf-8')
name = re.search("dn=([^\&]*)", mags[link][0])
torrent_name = parse.unquote(name.group(1)).replace("+", " ")
desc = re.search(r"<div class=\"nfo\">\s*<pre>(.+?)(?=</pre>)",
res, re.DOTALL).group(1)